What if locking people up indefinitely (as many were in institutions decades ago) and diagnosing them with subjective criteria isn't ideal? I'm not dismissing anybody's diagnosis or hand-waving real symptoms or illness - I'm merely suggesting that an authoritarian system where human rights are stripped with minimal outside observation (with sometimes flimsy criteria and fallible actors) is potentially damaging to mental health and is probably not conducive to healing. It can be a very imbalanced power dynamic, especially as it was in the institutions of the past as you pointed out.
We need an answer to retain the rights of those involuntarily held as best as possible. I think it's important to make courts more accessible to patients (and their loved ones), providing those held involuntarily with access to second opinions or different facilities (in some cases), and having established (and independently enforced) criteria for release - with appeals available for patients to argue their case for release with legal representation and other expert witnesses (e.g. other psychiatrists, qualified individuals directly involved in their care past or present) and perhaps even family members and other people who were involved with the patient.
Involuntary commitment (for any extended period) should be reserved for the severely mentally ill, who are determined by independent review to be in need of treatment to stabilize - and only those who are a danger to themselves or others, those who committed crimes, and those who are actively violent should be held in higher-security (locked) facilities.
I feel the rest would benefit greatly from conditions akin to a Soteria House (without locked doors, forced medication, or coercion) - the Soteria House model could be expanded, adapted, or modified. Treatment could be loosely mandated by courts, with reviews conducted and alternative treatment plans established if the patient wishes to modify or discontinue treatment before they are thought to be stabilized by their psychiatrist(s) and care team. I feel that maintaining consent, valuing patient input in forming treatment plans, and avoiding coercion is key to address certain states of trauma - otherwise patients are potentially faced with more trauma.
For those who are not thought to be severely ill, but who are thought to be in temporary crisis (and who are not thought to be violent or a threat to themselves or others), stabilization could be attempted in a temporary hold to assess their state, and continued onward with care akin to Soteria Houses or intensive outpatient care and other forms of observation and forms of support (e.g. with their environment and other distressing situations they are facing).
And to respond directly to you, I definitely feel like society was incapable or very underequipped to fix the institutions back then. Society is still largely unable to address distress and its very real manifestations or consequences - such as homelessness and the prevention of individuals from becoming homeless against their will.
And a great deal of the rights violations persist to this day, regardless of some of the treatments being viable presently to stabilize individuals.
Lifelong prescriptions are misappropriated and are too common (see Soteria Houses - they use psychiatric drugs in first-episode psychosis/schizophrenia with consent for stabilization and only for a few months to achieve remission in some individuals), people are kidnapped (sometimes in the middle of the night) and taken without due process by individuals who aren't able to assess mental illness, medicalized rape or forced psychiatry is rampant (patient choice is disregarded), there is essentially zero outside oversight, court access is wholly insufficient, you generally can't get second opinions, forced treatment orders still exist (so even when you're released you have to get court-ordered intramuscular shots), and so forth.
Some medications like neuroleptics carry a pretty big risk (20%~) of causing a condition known as Tardive Dyskinesia, which can be permanent and extremely debilitating. Polypharmacy is rampant and unregulated (some people can be on a pretty extreme cocktail of drugs).
There's still atrocities and those who fall through the cracks in the system, but there are success stories presently, which is contrasted by the horrors even in the 80's (which was fairly tame compared to psychiatry in the decades that came before it).
Psychiatry is in need of reform, and it doesn't seem like psychiatrists or the for-profit hospitals behind them are interested in enacting that serious reform.