This famous hadith teaches that the value of any deed depends on the intention behind it — a person is rewarded according to what they truly intend. It is a foundational principle placing sincerity at the heart of worship.
References
Sahih al-Bukhari 1Sahih Muslim 1907
Informational, not a personal fatwa. Consult a qualified scholar for rulings on your situation.