A bastardization of a parable

I'm pretty sure this was only verbally mentioned in an exurb1a video – but my recollection of the story goes like this:

A rich man goes to a priest to ask on advice on how to do good. The priest tells him to do charity, and expect nothing in return. After a while, the man comes back and mentions how he was going to do charity but had put his name on the donation, and as a result any good he did would be tainted by the desire for accolades, and asked the priest if he would ruin the good act. The priest replied how the people receiving the charity don't care about his intentions, and just care about the support, and told the man to do it anyway.

Does it matter if I have twisted intentions as long as at the end of the day I am kind?