It varies by state. In California, it’s essentially impossible to commit someone (source: I tried and failed, despite written permission from the person pre-episode, the blessing of their doctor, and the blessing of their family, multiple police reports from third parties, a divorce, eviction, repos, etc, etc.)
In CA if you do somehow manage to maliciously commit someone, they’re held for up to 24 hours, and an independent doctor assesses them. Also, there can be civil penalties (as in the article you cite, where the victim successfully sued the hospital).
If I had to choose between the two ridiculous extremes, I’d choose the Texas model.