Sayyiduna Anas bin Malik (may Allah be pleased with him) narrates that the Prophet (peace and blessings be upon him) said: "On the Day of Resurrection, sealed scrolls will be brought and placed before Allah Almighty, and Allah Almighty will say: 'Put this one aside and accept this one.' The angels will say: 'By Your might and Your majesty, (in the scroll You have ordered to be put aside) we see nothing but good.' Allah Almighty will say: 'This (that is, the deed recorded in this scroll) was for other than My Countenance, and today I will accept only that by which My Countenance (and My pleasure) was sought.'"
Hadith Referenceمجمع الزوائد ومنبع الفوائد / كتاب البعث / 18395