بسم الله الرحمن الرحيم
Sheikh al-Tusi (ra) has mentioned in his book, ‘Kitāb al-G̲h̲ayba’ the hadith of the Prophets (saww) supposed ‘Will’ during the night of his death. It should be noted, that hadith contradicts with other hadith, which mention Prophets (saww) supposed ‘Will’.
However the hadith has been used to propagate the doctrine of ‘Ahmad al-Hassan’, despite it having very weak chain of narrators with many majhool [unknown] narrators, It should be noted also, that the hadith has been narrated through Ammah [i.e. Sunnis]. Let's see, what Sheikh al-Ḥurr al-‘Āmilī says about the hadith.
وأما الأول فقد عرفت انه من روايات العامة ومع ذلك يمكن حمله على دخول النبي صلىاللهعليهوآله مع الأحد عشر كما في أحاديث الرجعة والأقوى في الأحاديث ان رجعة الأئمة عليهمالسلام بعد وفاة المهدى عليهمالسلام وان المهدى عليهالسلام أيضا يرجع بعد وفاته وبعد رجعة آبائه (ع) ووفاتهم وانه لا دولة لهم ( لأحد ـ خ ل ) بعد ذلك بل يقوم القيمة ويظهر من بعض أحاديث الرجعة ان أهلها غير مكلفين وقد أوضحنا الأمر بعض الإيضاح في آخر رسالة الرجعة
[ Sheikh al-Ḥurr al-‘Āmilī says ]: "The first hadith [i.e. hadith of the "Will"] has been narrated through Ammah [i.e. Sunnis], but despite that we can intrepret it [i.e. the 12 Mahdis mentioned in it] as the Prophet (saww) and the eleven Imams (as), as it has been mentioned in the ahadith of Raj’ah.
And the more correct approach about the ahadith of Raj’ah of the A’immah (as) is that it will happen after the death of al-Mahdi (ajfs) and that al-Mahdi (ajfs) will also come back [i.e. he will do Raj’ah] after his death, after the Raj’ah of his forefathers (as) and their death. And there will be no rule after that, because the day of resurrection will happen and as it is obvious from some of the narrations of Raj’ah, the people of Raj’ah are not obliged and we explained it somewhat at the end of risala of Raj’ah."
Source: al-Fawā’id al-Ṭūsīyah by Sheikh al-Ḥurr al-‘Āmilī, page 120,
(Click on the image below - in order to enlarge ;)