This was a problem of my own in my twenties. Experience, getting a bit older, and spending time on myself helped bring me around to a much healthier and happier place. During this process I sort of naturally picked up a group of friends who are healthy, and I disengaged myself from the ones who aren't healthy.
Some of that process was because I shifted how I get self-esteem. Before, I felt like I wasn't a "good" person unless I helped people... and helping people meant I listened to their problems, and I didn't judge them, and I let them be as sad as they wanted to be.... and I thought, I am awesome! I am "helping" my friend! When in reality, I wasn't really helping anyone at all.
In constrast, I get my self-esteem almost entirely from just within myself now. I still enjoy being a good listener for someone, but I am no longer willing to let someone complain ad infinitum about a problem that they themselves can solve.