The Messenger of Allah ﷺ said that Allah said, "When My servant intends to commit a bad deed, do not record it against him until he commits it. If he commits it, record it as one bad deed. But if he abandons it for My sake, record it for him as a good deed. And when he intends to do a good deed but does not do it, record it for him as a good deed. If he does it, record it for him as ten good deeds, up to seven hundred."
قال رسول الله ﷺ: قال الله عز وجل: إذا أراد عبدي أن يعمل سيئة فلا تكتبوها عليه حتى يعملها، فإن عملها فاكتبوها بمثلها، وإن تركها من أجلي فاكتبوها له حسنة، وإذا أراد أن يعمل حسنة فلم يعملها فاكتبوها له حسنة، فإن عملها فاكتبوها له بعشر أمثالها إلى سبعمائة.
Bukhari narrated it in the Book of Tawhid (7501), and Muslim in the Book of Faith (128), both through the route of Abu Zinad, from Araj, from Abu Hurairah, and he mentioned the hadith. The wording given here is Bukhari's. As for Muslim, he did not mention "up to seven hundred." This addition is established in Sahih Muslim in other narrations of Abu Hurairah through a different route.His statement, "so do not write it down," is speech directed at the angels.As for what was narrated from Ammar bin Yasir, "The angels do not go near the corpse of a disbeliever, nor someone smeared with saffron, nor someone in a state of major ritual impurity," this is daif. Abu Dawud narrated it (4176) from Musa bin Ismail, who said, Hammad (that is, Ibn Salama) narrated to us, Ata Khurasani informed us, from Yahya bin Yamar, from Ammar bin Yasir, who said, I came to my family at night, and my hands had become chapped, so they perfumed me with saffron. In the morning I went to the Messenger of Allah ﷺ and greeted him, but he did not return my greeting nor welcome me, and he said, "Go and wash this off yourself." So I went and washed it, then I came back, but some of it still remained on me. I came and greeted the Prophet, but he did not return my greeting nor welcome me, and he said, "Go and wash this off yourself." So I went and washed it, then I came and greeted him, and he returned my greeting and welcomed me, and said, "The angels do not attend the funeral of a disbeliever with any good, nor of someone smeared with saffron, nor of someone in a state of major ritual impurity." He also said, "A person in a state of major ritual impurity is permitted, if he sleeps or eats or drinks, to perform wudu."Tirmidhi narrated it (613) through the route of Hammad bin Salama in abridged form and said, "hasan sahih." That is what he said, but the correct view is that it is defective, as Abu Dawud stated (225) after narrating it through this same route, "Between Yahya bin Yamar and Ammar bin Yasir in this hadith there is a man." So the hadith is disconnected, and more than one scholar has stated that Yahya bin Yamar never met Ammar.Daraqutni said, "He did not meet Ammar, but his hadith from those he did meet is sahih." I say, this is as he said, for Imam Ahmad narrated it (18890) through the route of Umar bin Ata bin Abu Khuwar, that he heard Yahya bin Yamar reporting from a man who informed him, from Ammar bin Yasir, Umar claimed that Yahya had named that man but Umar forgot it, and he mentioned the hadith in similar fashion. This version is connected, but it contains an unknown narrator.Likewise, what Abu Dawud narrated (4180) through the route of Hasan bin Abu Hasan, from Ammar bin Yasir, that the Messenger of Allah ﷺ said, "Three things the angels do not go near, the corpse of a disbeliever, one smeared with perfume, and one in a state of major ritual impurity unless he performs wudu," is also not sahih, because Hasan bin Abu Hasan did not hear from Ammar bin Yasir.