Hasanaat depends upon Intentions
Narrated 'Umar bin Al-Khattab: I heard Allah's Apostle saying, "The reward of deeds depends upon the intentions and every person will get the reward according to what he has intended. So whoever emigrated for worldly benefits or for a woman to marry, his emigration was for what he emigrated for."
The Hasanaat we do are considered in Book of deeds according to our intentions in heart and rewarded in the same way.
Suppose, if someone do a good deed with the intention to show off between people as a pious person and want people call him pious person, that deed will rewarded in the way he wanted to get it's reward. Allah will make people to consider him pious and call him pious person but after that he will have no reward from Allah Almighty because he wanted to get reward from people so he got and on the day of judgement he'll be sorry for that but there he'll be so late to ask forgiveness.