The Messenger of Allah ﷺ said, "When a servant accepts Islam and his Islam becomes sincere, Allah records for him every good deed he had previously done, and every bad deed he had previously committed is erased. After that, the reckoning begins. A good deed is rewarded tenfold up to seven hundred times, and a bad deed is recorded as one, unless Allah overlooks it."
قال رسول الله ﷺ: إذا أسلم العبد فحسن إسلامه، كتب الله له كل حسنة كان أزلفها، ومحيت عنه كل سيئة كان أزلفها، ثم كان بعد ذلك القصاص، الحسنة بعشر أمثالها إلى سبعمائة ضعف والسيئة بمثلها إلا أن يتجاوز الله عز وجل عنها.
Nasai narrated it (4998) via Walid - that is, ibn Muslim - and Bayhaqi in Shuab al-Iman (24) via Ismail bin Abu Uways. Both of them said, "Malik narrated to us, from Zayd bin Aslam, from Ata bin Yasar, from Abu Saeed Khudri," and he related the hadith, and their wordings are identical. Except that Bayhaqi said, "Malik gave it a connected chain, while Ibn Uyayna narrated it as mursal," then he related the hadith through his route as mursal.I say, the ruling goes to the one who gave it a connected chain, because of the additional knowledge it contains.Bukhari mentioned it in the Book of Faith (41) as a suspended narration from Malik, and he did not give it a connected chain anywhere else, except that he omitted his statement, "Allah would record for him every good deed he had put forward (azlafaha)," because it poses a difficulty according to the principles. This is because the disbeliever is not rewarded for a righteous deed coming from him during his disbelief and his associating partners with Allah, since one of the conditions for someone seeking closeness to Allah is that he must know the One to whom he is drawing near, and the disbeliever is not so. This was mentioned by Maziri and others, and Qadi Iyad followed him in affirming this difficulty. Nawawi rejected it and said,"The correct view held by the rigorous scholars - indeed some of them have reported a consensus on it - is that if a disbeliever performs good deeds such as giving charity and maintaining family ties, then embraces Islam and dies as a Muslim, the reward for those deeds is recorded for him..." End of his statement, summarized.Hafiz mentioned in Fath al-Bari (1/99) other possibilities, the strongest of which is his statement, "The truth is that recording the reward for the Muslim once he embraces Islam, as a favor and kindness from Allah, does not necessarily mean that his deed performed during disbelief was accepted. The hadith only concerns the recording of the reward and does not address acceptance. It is possible that acceptance becomes contingent upon his embracing Islam, so it is accepted and rewarded if he becomes a Muslim, and otherwise not." End.I say, the hadith of Hakeem bin Hizam preceding this one points to this.As for his saying "azlafaha," it means he advanced and put forward.