A hadith transmitted widely enough to appear across several major collections has the Prophet warning his companions of what he most fears for them, not open disbelief but al shirk al asghar, the lesser associating of another with God, and when asked what that is, answering riya, naming the vice in terms drawn from the gravest category of theological error in Islam, shirk, associating a partner with God's uniqueness, while carefully qualifying it as the lesser, hidden form rather than the greater.
Ghazali's Ihya devotes sustained attention to riya precisely because of this classification, arguing that the vice is dangerous in proportion to how easily it hides even from the person committing it, since a worshipper can perform every outward element of prayer, fasting or charity correctly while directing the act, in some fraction of intention too subtle to notice without deliberate self examination, toward human witnesses rather than toward God, an act that satisfies its outward form while forfeiting the spiritual reward the tradition holds sincerity alone secures. The Quran addresses the same failing directly in its description of the hypocrites, who are said to stand for prayer lazily, showing off before people, language later exegesis reads as describing not merely reluctant worship but worship performed with an eye toward an audience rather than toward God.