I know what you mean,its same like someone is giving charity from haram Ki kamaii,they won’t get reward for it but other person will get benefit ,
Depends on someones niyaat.we really can’t judge someone,sometimes it’s hard to judge our self,like why I did that? For me? For Allah SWT or for showing off?