Abu Saeed Khudri reported,

Some of the hypocrites in the time of the Messenger of Allah ﷺ would stay behind whenever the Prophet ﷺ set out on a military campaign, and they rejoiced at remaining seated at home in opposition to the Messenger of Allah ﷺ. Then, when the Prophet ﷺ 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, do not think them safe from the punishment" [Al Imran 3:188].

Azami 12111

Sahih

عن أبي سعيد الخدري

أن رجالا من المنافقين في عهد رسول الله ﷺ كانوا إذا خرج النبي ﷺ إلى الغزو تخلفوا عنه، وفرحوا بمقعدهم خلاف رسول الله ﷺ، فإذا قدم النبي ﷺ اعتذروا إليه، وحلفوا، وأحبوا أن يحمدوا بما لم يفعلوا، فنزلت: {لا تحسبن الذين يفرحون بما أتوا ويحبون أن يحمدوا بما لم يفعلوا فلا تحسبنهم بمفازة من العذاب}.

الأعظمي 12111صحيح
Contents
Reference
Commentary
Ayat
Collection
Jami al-Kamil
Book
Tafsir of the great Quran
Chapter
Virtues of Surah Baqarah
Section
His saying, "Do not think that those who rejoice in what they have done and love to be praised for what they have not done, do not think them safe from punishment, and for them is a painful punishment" (188)
Numbering
Jami al-Kamil 12111 (2nd edition)
Azami 12111