Charging all night has nothing to do with the problem.
The problem is that Lithium batteries last longest if they are kept between 50-80%. If you always top them off or if you let them drain to nothing, they degrade faster. There are apps that will cap charging at 80%.
If you upgrade your phone every 2 years the amount of degradation won't matter that much as you'll just upgrade by the time it gets bad. But if you hold onto your phones longer you should certainly look into that.
I always keep my Tesla between 50-80%. They recommend always just keeping it plugged in with an 80% cap, though that's mostly so that it doesn't drain to zero.