During the lifetime of Messenger of Allah ﷺ, some men among the hypocrites used to remain behind him (i.e. did not accompany him) when he went out for a Ghazwa and they would be pleased to stay at home behind Messenger of Allah ﷺ When Messenger of Allah ﷺ returned (from the battle) they would put forward (false) excuses and take oaths, wishing to be praised for what they had not done. So there was revealed:-- "Think not that those who rejoice in what they have done, and love to be praised for what they have not done.." (3.188)
عَنْ أَبِي سَعِيدٍ الْخُدْرِيِّ ؓ أَنَّ رِجَالاً مِنَ الْمُنَافِقِينَ عَلَى عَهْدِ رَسُولِ اللَّهِ ﷺ كَانَ إِذَا خَرَجَ رَسُولُ اللَّهِ ﷺ إِلَى الْغَزْوِ تَخَلَّفُوا عَنْهُ وَفَرِحُوا بِمَقْعَدِهِمْ خِلاَفَ رَسُولِ اللَّهِ ﷺ فَإِذَا قَدِمَ رَسُولُ اللَّهِ ﷺ اعْتَذَرُوا إِلَيْهِ وَحَلَفُوا وَأَحَبُّوا أَنْ يُحْمَدُوا بِمَا لَمْ يَفْعَلُوا فَنَزَلَتْ {لاَ يَحْسِبَنَّ الَّذِينَ يَفْرَحُونَ} الآيَةَ