He died without doing Hajj and someone did Hajj on his behalf with funds from his estate before it was found out that he had an heir
If a person has wealth that is surplus to his needs and those of his dependents and is sufficient for him to do Hajj, then he must do Hajj for himself. If he is unable to do so because of sickness or old age, then he must delegate someone to do Hajj on his behalf with his money. If he dies without having done Hajj, then money must be taken out of his estate for Hajj to be done on his behalf, because Hajj is a debt that he owes, and a debt owed to Allaah is more deserving of being paid off, as al-Nasaa’i (2639) narrated that Ibn ‘Abbaas (may Allaah be pleased with him) said: A man said: O Messenger of Allaah, my father died and did not do Hajj; should I do Hajj on his behalf? He said: “Do you think that if your father owed a debt, wouldn't you pay it off?” He said: Yes. He said: “The debt of Allaah is more deserving (of being paid off).” Classed as saheeh by al-Albaani in Saheeh al-Nasaa’i.
Ibn Qudaamah (may Allaah have mercy on him) said: If a person for whom Hajj was obligatory dies and did not do Hajj, then money must be taken out from his entire wealth for Hajj and ‘Umrah to be done on his behalf, whether he failed to do it because of negligence or otherwise. This is the view of al-Hasan, Tawoos and al-Shaafa’i.
And because Ibn ‘Abbaas narrated that a woman asked the Prophet (blessings and peace of Allaah be upon him) about her father, who had died and did not do Hajj. He said: “Do Hajj on behalf of your father.” And it was narrated from him that a woman vowed to do Hajj then she died. Her brother came to the Prophet (blessings and peace of Allaah be upon him) and asked him about that. He said: “Don’t you think that if your sister owed a debt, you would pay it off?” He said: Yes. He said: “So pay the debt owed to Allaah, for it is more deserving of being paid off.” Narrated by al-Nasaa’i. And because it is a duty that may be done by proxy, so it is not waived if a person dies, as is also the case with debt. End quote from al-Mughni, 3/101.
But if when he was alive he did not possess funds for Hajj that were surplus to his needs and the needs of his dependents, then Hajj was not obligatory in his case and it is not obligatory to do Hajj on his behalf, unless someone does that voluntarily.
Shaykh Ibn ‘Uthaymeen (may Allaah be pleased with him) was asked: I have a nephew who got cancer -- I seek refuge for you and all the Muslims from that -- and he died this year at the age of 19, without having done the obligatory Hajj. Please note that he got this disease five years ago. Should we do Hajj on his behalf? Is there any expiation?
It is essential to ask: did this young man have wealth with which he could have done Hajj? If that is the case, then Hajj must be done on his behalf. But if he did not have any wealth, then Hajj was not obligatory for him and he has died free of any obligation. But if they want to do Hajj voluntarily on his behalf, there is nothing wrong with that. End quote from al-Liqa’ al-Shahri, 62/5.
Based on that, if the man who died had enough money to do Hajj, then Hajj was obligatory for him, and what the questioner has done of performing Hajj on his behalf was a correct action which takes precedence over the rights of the heir to the estate. But he should inform the heir of that, so that he will not do Hajj for him a second time, thinking that this is obligatory for him.
And Allaah knows best.