A man came to the Prophet ﷺ and said, "Messenger of Allah, if I do well in Islam, will I be held accountable for what I did in the time of ignorance?"He replied, "If you do well in Islam, you will not be held accountable for what you did in the time of ignorance. But if you do badly in Islam, you will be held accountable for both the former and the latter."
حدثنا أبو معاوية حدثنا الأعمش عن شقيق
أتى النبي ﷺ رجل فقال يا رسول الله إذا أحسنت في الإسلام أؤاخذ بما عملت في الجاهلية فقال إذا أحسنت في الإسلام لم تؤاخذ بما عملت في الجاهلية وإذا أسأت في الإسلام أخذت بالأول والآخر
Its isnad is sahih. Muslim reported it 1:45 through Amash from Abu Waail, who is Shaqiq. He also reported it through Mansur from Abu Waail, which is the route that will come at 3604. Bukhari and Ibn Majah also reported it, as mentioned in Dhakhair 4885.