Goodhart’s Law applies to bragging about donations too—if you make it a norm, people will optimize for visibility instead of doing good; there will be charities helping them to optimize for this goal… and soon you may get a culture where people donate a lot to charities that actually don’t do much good, because most of their spending goes on increasing the visibility somehow.
That is pretty much what Jesus said in the cited passage:
So when you give to the needy, do not announce it with trumpets, as the hypocrites do in the synagogues and on the streets, to be honored by others.
And similarly, further on:
And when you pray, do not be like the hypocrites, for they love to pray standing in the synagogues and on the street corners to be seen by others.
...
When you fast, do not look somber as the hypocrites do, for they disfigure their faces to show others they are fasting
That is pretty much what Jesus said in the cited passage:
And similarly, further on:
...