The ḥadith is agreed upon.
[Explanation]
Imam al-Nawawī—may Allah have mercy on him—cited these aḥadīth in Riyāḍ al-Ṣāliḥīn under the heading “What is to be said at the time of death,” meaning: when a person loses someone, what should he say? We have already referred to the two reports with which the author opened this chapter, both narrated from Umm Salama, may Allah be pleased with her. When her husband passed away she said, “Indeed we belong to Allah and to Him we shall return. O Allah, reward me in my calamity and grant me something better in exchange.” Allah then compensated her with someone better than him: the Messenger of Allah ﷺ.
The remaining three ḥadīths concern the one whose child dies; if he praises Allah, utters the istirjaʿ (“Indeed we belong to Allah and to Him we shall return”), and remains patient, Allah Most High will reward him with Paradise. As the ḥadīth states: when the angels seize the soul of his child, Allah, Exalted is He, says to the angels, “Have you taken the child of My servant?” They reply, “Yes,” though He already knows; He asks in order to make manifest that servant’s virtue—how he praised Allah and recited the istirjaʿ at the moment of this tremendous trial. He says, “Have you taken the very apple of his heart?” They answer, “Yes.” He then says, “What did My servant say?” They respond, “He praised You and uttered the istirjaʿ,” meaning he said, “All praise is due to Allah; indeed we belong to Allah and to Him we shall…"