"What is your concern with this verse? It was revealed only about the People of the Book." Then Ibn Abbas recited, "And when Allah took a covenant from those who were given the Scripture, that you shall make it clear to the people and not conceal it" [Al Imran 3:187], and he recited, "Do not think that those who rejoice in what they have brought about and love to be praised for what they have not done" [Al Imran 3:188].Ibn Abbas explained, "The Prophet ﷺ asked them about something, and they concealed it and told him something else instead. They left having given him the impression that they had informed him about what he had asked them, and they sought his praise for that, and they rejoiced in what they had gained by concealing what he had asked them about."
حدثنا الحسن بن محمد الزعفراني حدثنا الحجاج بن محمد قال قال ابن جريج أخبرني ابن أبي مليكة أن حميد بن عبد الرحمن بن عوف أخبره أن مروان بن الحكم قال اذهب يا رافع لبوابه إلى ابن عباس فقل له لئن كان كل امرئ فرح بما أوتي وأحب أن يحمد بما لم يفعل معذبا لنعذبن أجمعون
ما لكم ولهذه الآية إنما أنزلت هذه في أهل الكتاب ثم تلا ابن عباس {وإذ أخذ الله ميثاق الذين أوتوا الكتاب لتبيننه للناس ولا تكتمونه} وتلا {لا تحسبن الذين يفرحون بما أتوا ويحبون أن يحمدوا بما لم يفعلوا} قال ابن عباس سألهم النبي ﷺ عن شيء فكتموه وأخبروه بغيره فخرجوا وقد أروه أن قد أخبروه بما قد سألهم عنه فاستحمدوا بذلك إليه وفرحوا بما أوتوا من كتمانهم ما سألهم عنه
Agreed upon (by Bukhari and Muslim). Bukhari narrated it in the Book of Tafsir, Chapter, "Do not think that those who rejoice in what they have been given" (Hadith 4568), and Muslim narrated it (Hadith 2778), both from the hadith of Hajjaj bin Muhammad, with this wording.