A man said, "Messenger of Allah, what about a man who does a deed in secret, but when people come to know of it, he is pleased by that?"The Messenger of Allah ﷺ replied, "He has two rewards, the reward of secrecy and the reward of openness."
حدثنا محمد بن المثنى حدثنا أبو داود حدثنا أبو سنان الشيباني عن حبيب بن أبي ثابت عن أبي صالح
قال رجل يا رسول الله الرجل يعمل العمل فيسره فإذا اطلع عليه أعجبه ذلك قال رسول الله ﷺ له أجران أجر السر وأجر العلانية
[Its chain is daif]. Ibn Majah narrated it in the Book of Zuhd, chapter on Good Praise, hadith no. 4226, from Abu Dawud Tayalisi, hadith no. 2430. Habib narrated it using "an" (indicating an unspecified link), and the rest of the chain matches the hadith of Abu Sinan through him. It is found in the Musnad, hasan.