Al-Bukhari recorded that Abu Hurayrah said, "A man came to the Prophet and said, ‘O Allah’s Messenger! Poverty has stuck me.’ The Prophet sent a messenger to his wives (to bring something for that man to eat) but they said that they had nothing.
"Then Allah’s Messenger said, ‘Who will invite this person or entertain him as a guest tonight; may Allah grant His mercy to him who does so.’ An Ansari man said, ‘I, O Allah’s Messenger!’ So he took him to his wife and said to her, ‘Entertain the guest of Allah’s Messenger generously.’ She said, ‘By Allah ! We have nothing except the meal for my children.’ He said, ‘Let your children sleep if they ask for supper. Then turn off the lamp and we go to bed tonight while hungry.’ She did what he asked her to do."
"In the morning the Ansari went to Allah’s Messenger who said, ‘Allah wondered (favorably) or laughed at the action of so-and-so and his wife.’ Then Allah revealed, ‘and they give them preference over themselves even though they were in need of that.’ (Surah al-Hashr:9)"
Al-Bukhari recorded this Hadith in another part of his Sahih. Muslim, At-Tirmidhi, An-Nasa’i collected this Hadith.
In another narration for this Hadith, the Companion’s name was mentioned, it was Abu Talhah Al-Ansari, may Allah be pleased with him