The Messenger of Allah ﷺ said, "Whoever consoles one who is afflicted will receive a reward equal to his."
حدثنا عمرو بن رافع قال حدثنا علي بن عاصم عن محمد بن سوقة عن إبراهيم عن الأسود
قال رسول الله ﷺ من عزى مصابا فله مثل أجره
[Its chain is daif] Tirmidhi transmitted it in the Book of Funerals, the chapter on the reward of one who consoles a person afflicted by calamity, hadith no. 1073, from the hadith of Ali bin Asim, with this wording, and he said it is unusual. Bayhaqi said, Ali bin Asim alone transmitted it, and this is one of the things he was criticized for. It has been narrated from others as well, and it has corroborating narrations, none of which are sound. Ali, previously mentioned, hadith no. 1515.