Some of the hypocrites in the time of the Messenger of Allah ﷺ would stay behind whenever he went out on a military expedition, delighting in sitting at home while the Messenger of Allah ﷺ was away. Then, when he returned, they would offer him excuses and swear oaths, wanting to be praised for what they had not done. So this verse was revealed, "Do not think that those who rejoice in what they have done and love to be praised for what they have not done..." [Al Imran 3:188].
حدثنا سعيد بن أبي مريم أخبرنا محمد بن جعفر قال حدثني زيد بن أسلم عن عطاء بن يسار
أن رجالا من المنافقين على عهد رسول الله ﷺ كان إذا خرج رسول الله ﷺ إلى الغزو تخلفوا عنه وفرحوا بمقعدهم خلاف رسول الله ﷺ فإذا قدم رسول الله ﷺ اعتذروا إليه وحلفوا وأحبوا أن يحمدوا بما لم يفعلوا فنزلت {لا تحسبن الذين يفرحون بما أتوا ويحبون أن يحمدوا بما لم يفعلوا} الآية