Its not a sin to pray in public. I think Jesus was looking into the hearts of the Jews who intentionally pray in public only to be recognized by other people as holy. I think that is what He meant by they have already received their reward. Their reward is that the other people think they are holy.
I see this kind of thing all the time. I think its about being humble. One of my old roommates always insisted on telling me all the good things he did during the day. My response in my head was always, “congrats, want a cookie?” It was like he was always seeking approval, for someone to say, “wow, I wish I did great things like you”. People always look for that instant gratification. They want the reward for their actions right now. We shouldn’t need other people’s approval of how good and holy we are, what you do in private, God sees in private. People will know you by your actions but your heart has to be in the right place. Are you going on that retreat to talk to that pretty girl from school who is going, or are you going to have a spiritual revelation?
I may have missed the boat here, but its kind of like doing something nice for somebody who will never find out you did it for them. Its that kind of situation, IMO.