I've been quite ill with anxiety and depression and been hospitalised when ill. And I've heard several versions of 'pull yourself together' over the years, but I think the intent behind the phrase is more important than the phrase itself. But, that the phrase has become negative and seen as something you should never say to anyone.
I've heard it with a meaning of "I can't be bothered to deal with you right now and you're just wallowing" to "I am going to help you, but that's not going to work unless you engage because I am struggling too"
The thing about depression, ime, is that you can't usually overcome it alone and need help, of varying degrees from family and friends support to medical intervention, but the one thing that you'll never overcome it without is the want to overcome it from within yourself (God, I sound like a bad self help book 🙄) but, that's the hardest thing to find when you're in that place, it takes a hell of a lot of inner strength and determination - both of which are usually hard to find when depressed.
Sometimes, unfortunately, people do hide behind the diagnosis and think that as they have that diagnosis and some therapy or tablets, they'll do all the work - but as with any illness, the support and treatment is only part of the recovery, the person who is ill needs to engage too. As I've said, this can be the hardest part because the thing impacted hardest by depression/anxiety is your sense of self.
Others are much more unwell than even they realise and very good at masking it, and when they stop outwardly coping, it's because they can't, they have been putting so much effort into 'keeping' themselves together that they just don't have anything left.
And being honest, I've been in both places and neither is a good place to be, but at least ime, the second is the most dangerous. On balance, I don't know if I'd say it to someone at all, because of the risk that they're in the second place and it tips them even further.
The professionals I have dealt with are actually pretty good at telling the difference, and I suspect that's sometimes that's why they're avoided.
And, I do wonder if in the past, we were more accepting of the negative emotions we feel, such as anger, feeling down, feeling hopeless, being upset or emotional, being nervous or anxious as being on the scale of normal, accepted and acceptable - for short periods and/or in response to issues in life.
I do feel sometimes that we're encouraged to think something is 'wrong' with us if we aren't permanently happy and content with our lot, and that actually makes things worse instead of better because we then feel inadequate for feeling normal human emotions.