Converting to Islam does not erase the reward for any of the good done before Islam
I asked the Messenger of Allah ﷺ, "Before embracing Islam I used to do good deeds like giving in charity, freeing slaves, and the keeping of good relations with kith and kin. Shall I be rewarded for those deeds?" The Prophet ﷺ replied, "You became Muslim ˹along˺ with ˹the rewards for˺ all those good deeds ˹you have done in the past and without carrying the sin of any of the bad deeds of the past˺."
قُلْتُ يَا رَسُولَ اللَّهِ، أَرَأَيْتَ أَشْيَاءَ كُنْتُ أَتَحَنَّثُ بِهَا فِي الْجَاهِلِيَّةِ مِنْ صَدَقَةٍ أَوْ عَتَاقَةٍ وَصِلَةِ رَحِمٍ فَهَلْ فِيهَا مِنْ أَجْرٍ؟ فَقَالَ النَّبِيُّ ﷺ: «أَسْلَمْتَ عَلَى مَا سَلَفَ مِنْ خَيْرٍ.»