When ʿAbdullah bin Ubai (the chief of hypocrites) died, his son came to the Prophet ﷺ and said, "O Messenger of Allah ﷺ! Please give me your shirt to shroud him in it, offer his funeral prayer and ask for Allah's forgiveness for him." So Messenger of Allah ﷺ gave his shirt to him and said, "Inform me (When the funeral is ready) so that I may offer the funeral prayer." So, he informed him and when the Prophet intended to offer the funeral prayer, ʿUmar took hold of his hand and said, "Has Allah not forbidden you to offer the funeral prayer for the hypocrites? The Prophet ﷺ said, "I have been given the choice for Allah says: '(It does not avail) Whether you (O Muhammad) ask forgiveness for them (hypocrites), or do not ask for forgiveness for them. Even though you ask for their forgiveness seventy times, Allah will not forgive them. (9.80)" So the Prophet ﷺ offered the funeral prayer and on that the revelation came: "And never (O Muhammad) pray (funeral prayer) for any of them (i.e. hypocrites) that dies." (9. 84)
أَنَّ عَبْدَ اللَّهِ بْنَ أُبَىٍّ لَمَّا تُوُفِّيَ جَاءَ ابْنُهُ إِلَى النَّبِيِّ ﷺ فَقَالَ يَا رَسُولَ اللَّهِ أَعْطِنِي قَمِيصَكَ أُكَفِّنْهُ فِيهِ وَصَلِّ عَلَيْهِ وَاسْتَغْفِرْ لَهُ فَأَعْطَاهُ النَّبِيُّ ﷺ قَمِيصَهُ فَقَالَ آذِنِّي أُصَلِّي عَلَيْهِ فَآذَنَهُ فَلَمَّا أَرَادَ أَنْ يُصَلِّيَ عَلَيْهِ جَذَبَهُ عُمَرُ ؓ فَقَالَ أَلَيْسَ اللَّهُ نَهَاكَ أَنْ تُصَلِّيَ عَلَى الْمُنَافِقِينَ فَقَالَ أَنَا بَيْنَ خِيرَتَيْنِ قَالَ {اسْتَغْفِرْ لَهُمْ أَوْ لاَ تَسْتَغْفِرْ لَهُمْ إِنْ تَسْتَغْفِرْ لَهُمْ سَبْعِينَ مَرَّةً فَلَنْ يَغْفِرَ اللَّهُ لَهُمْ} فَصَلَّى عَلَيْهِ فَنَزَلَتْ {وَلاَ تُصَلِّ عَلَى أَحَدٍ مِنْهُمْ مَاتَ أَبَدًا}