Al-Hasan al-Basri narrates: We came to Sayyiduna Imran bin Husayn (may Allah be pleased with him); this was during the severe illness that had afflicted him. He said: "I express my sorrow to you over the condition I see." Sayyiduna Imran bin Husayn (may Allah be pleased with him) said: "O my nephew! Do not do so. By Allah! The thing most beloved to me is what is most pleasing to Allah Almighty. Allah Almighty has said: 'Whatever calamity befalls you is because of what your own hands have earned, and He pardons much.' So this is what my own hands have earned, and then the pardon of my Lord will come to me for what remains."
Al-Tabarani recorded it in al-Mu'jam al-Kabir, and its chain is hasan (good).
Hadith Referenceمجمع الزوائد ومنبع الفوائد / كتاب الجنائز / 3802