The only requirement is that both are defeated, the order in which that happens does not matter. Nomura said that both variants can result in the restoration of the original being.
Director's Secret Report said:
VIII. When the heartless are defeated, what becomes of the stolen hearts? Also, when members of Organization XIII and other Nobodies are defeated, do they return to their original form?
When heartless are defeated, essentially the owner's hearts are rejoined with their once extenguished body, whichever world it may be on.*1 As for the whereabouts of hearts in KHII that turn up, this time they remarkably went to the Organization (there is a foot note here that says "In Kingdom Hearts II after heartless were defeated, the many hearts were absorbed by the Kingdom Hearts of "people's hearts"). However, in the rare case that the body changed into a Nobody and when there is no container for the heart, it resorts to a state of suspension.
In the case of a Nobody being defeated, it's a little more complicated. If the above mentioned hearts are liberated, they return to their original form.*2 However, if the heart is still stolen by the heartless, the Nobody's body is swallowed by darkness. If somewhere in the world their hearts are taken back, perhaps they might be able to return to their original human form.*3
For further understanding and elaboration:
*1 explains the normal (usual) case when there is only a Heartless since Nobodies are rare and the next sentence says what happens to the heart when there is a Nobody still in existence.
*2 explains the case when the Heartless is already defeated and then the Nobody is destroyed.
*3 explains what happens when the Nobody is destroyed while the Heartless is still at large. Nomura speaks about what happens to the body(and soul) in that case and that if the Heart is liberated later, the return as a full human being is still possible as well.
In essence, both variants when a Nobody is involved end in the same result, the order of which they are destroyed only determines which part of the existence is put in a state of suspension. If the Heartless is offed first, the Heart goes into(or remains) in limbo, while if the Nobody is vanquished first it is the body/soul that is put in limbo.
The latter is practically the same as if there had never been born a Nobody, as Hearts who are stolen/turn into Heartless that aren't strong enough to produce a Nobody get also revived without much problem and their "once extinguished" body is restored.
The interesting tidbit comes when we take into account that Nobodies can grow their own hearts when the right conditions are met.
Now if the Nobody that has grown a heart (or was in the process of doing so), what happens to the heart-bud that was located in the body? Does it go into suspension together with the body and then waits until the Heartless with the original heart is defeated? Is it send to Kingdom Hearts?