Q: A Muslim man peforms an action that causes a palace to be built for him in Paradise, and that a tree is planted in Paradise with his name on it, etc. Then, he performs sins that make Hell obligatory for him. So, if he enters Hell, how can it be that he is supposed to be in Paradise while he is in Hell?
A: If he repents from his sins in a sincere way, Allah will forgive him, and will not prevent him from what He has Promised him. Rather, He will give this to him.
If he doesn’t repent, his good deeds will be weighed against his bad deeds. If they are heavier than his bad deeds, he will receive the reward. If his bad deeds outweigh his good deeds, he will receive the punishment, and whatever was prepared for him of reward will be nullified due to his sins that outweighed his good deeds. Likewise, if he performs bad deeds that make him deserving of Hell, and followed them up with good actions, his bad deeds will be wiped away.
And Allah Knows best.
[Shaykh ul Islam Ibn Taymiyyah in ‘Majmu’ al-Fatawa’; 4/160] (Translation by Tarek Mehanna – may Allah keep him steadfast and hasten his release ameen)