´It was narrated from Abu Hurairah that the Messenger of Allah (ﷺ) said:` “Allah says: ‘I am the Most Self-Sufficient and I have no need for an associate. Thus he who does an action for someone else’s sake as well as Mine will have that action renounced by Me to him whom he associated with Me.’”
Benefits and Issues: ➊ To associate someone else means to perform an act for show, through which worldly benefit is sought or so that one may be called pious and righteous in the eyes of people.
➋ Such an act is not accepted by Allah.
➌ If an act is done for someone else, it means that Allah does not grant any reward for it. If the ostentatious person seeks reward, then let him take the reward from the person for whom he performed the act to show off. Obviously, a human being cannot give another human being the recompense for good deeds, so on the Day of Resurrection, the ostentatious person will be humiliated. And he will receive no reward or benefit for his deed.
➍ Ostentation (riya) is minor shirk (shirk asghar); it destroys the act in which ostentation is present. However, it is not major shirk (shirk akbar), the punishment for which is eternal Hell.
Source: Commentary on Sunan Ibn Mājah by Mawlānā ‘Atā’ullāh Sājid, Page: 4202