All perfect praise be to Allah, The Lord of the Worlds. I testify that there is none worthy of worship except Allah, and that Muhammad is His slave and Messenger.
Sincerity is dear, and there is nothing more difficult on the soul than sincerity, as it was quoted from some predecessors.
Just as minor show-off is part of the hidden polytheism, which is difficult to drop from the heart except with diligence and continuous monitoring, show-off grows in the heart in different forms.
And what you asked about becomes clear by knowing that worshiping other than Allah is divided into categories, which were mentioned by Al-Hafidh Ibn Rajab Al-Hanbali in Jaami' Al-'Uloom wa Al-Hikam.
We summarize them into these categories:
The first category: is that it is pure show-off, which is not meant for anything other than to show oneself to people for a worldly purpose, such as the case of the hypocrites in their prayers, as Allah the Almighty says (what means): {Indeed, the hypocrites [think to] deceive Allah, but He is deceiving them. And when they stand for prayer, they stand lazily, showing [themselves to] the people and not remembering Allah except a little.} [Quran 4:142]
The second category: is that the deed is performed for the sake of Allah, but showing off is involved in it at its origin. The authentic texts indicate its invalidity.
The third category: is that the origin of the deed is for Allah, then showing off arises from the intention of the worshipper; if it was just a passing thought and he pushed it away, then it does not harm him and there is no disagreement among scholars regarding this, and if he was carried away with it, then does his work become nullified or does that not harm him and he would be rewarded according to his original intention? In this regard, there is a difference of opinion among the scholars from the predecessors. Imam Ahmad and Ibn Jareer at-Tabari quoted it, and they held that the preponderant view is that this does not invalidate the worshiper's deed and that he is rewarded for his first intention. This was narrated on the authority of Hassan al-Basri and others.
So it became clear from these details that if the worshiper is of the first and second category, then his prayer is invalid and it must be repeated, and he deserves punishment unless he repents to Allah.
In case he is from the third category, then his deed is not invalidated, but he must repent for being carried away with this showing off that arose which exposes him to the punishment of Allah the Almighty.
As for your question about a supplication that helps purify our intentions from showing off, we recommend to you what the Prophet recommended to Abu Bakr when he said to him: “Say ‘O Allah! I seek refuge in you lest I associate anything with you while I know it, and I seek your forgiveness for what I do not know.’” Reported by Al-Bukhari in Al-Adab Al-Mufrad, and authenticated by Al-Albani, and Imam Ahmad narrated in Al-Zuhd on the authority of Al-Hassan that 'Umar Ibn Al-Khattab used to say: “‘O Allah, make my work be righteous and make it purely for You, and do not make anything for anyone in it.” [End Of Quote].
Allah knows best.