Narrated Abu Sa`id Al-Khudri
During the lifetime of Allah's Messenger (ﷺ), 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 Allah's Messenger (ﷺ) When Allah's Messenger (ﷺ) 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)
Narrated Alqama bin Waqqas
Marwan said to his gatekeeper, "Go to Ibn `Abbas, O Rafi`, and say, 'If everybody who rejoices in what he has done, and likes to be praised for what he has not done, will be punished, then all of us will be punished." Ibn `Abbas said, "What connection have you with this case? It was only that the Prophet (ﷺ) called the Jews and asked them about something, and they hid the truth and told him something else, and showed him that they deserved praise for the favor of telling him the answer to his question, and they became happy with what they had concealed. Then Ibn `Abbas recited:-- "(And remember) when Allah took a Covenant from those who were given the Scripture..and those who rejoice in what they have done and love to be praised for what they have not done.' " (3.187-188) Humaid bin `Abdur-Rahman bin `Auf narrated that Marwan had told him (the above narration).