When someone is in a bad spot, it is difficult for them to see a way out of it. When they are told "You are in control of your own happiness", they feel guilty and attacked because they are struggling to take control of their own actions, let alone mood.
So when they see you improving and building a better life for yourself, they compare themselves and think "River's doing a lot better for herself, and I feel like trash". Some people silently compare and despair, while others lash out of you, especially when guarded by an electronic screen.
I'm sorry people try to bring you down like this, but please understand that the problem is not you, it's their depression