In Oslo, near the university, there used by a "cave dweller". A by all accounts bright student who at 25 decided to stop washing himself. He was soon thrown out of his student accommodation because of the smell. He then decided to take up residence under a tarp in a makeshift "cave" in a hillside next to the university where he stayed for the following two and half decades. In 1987, he was refused the opportunity to take his astrophysics exam because of the smell, and later given a blanket restriction on participating in any exams unless he washed first.
He was repeatedly institutionalised against his will, but in 1988 he won a supreme court decision that made it clear that his unorthodox lifestyle was insufficient grounds for forcing him into mental health institutions. He later sued the University of Oslo over lost income due to the exam ban, but lost.
It may seem obvious that this guy had mental problems. The problem is that in court and during psychological examinations he was fully coherent and defended his choices with references to traditions of asceticism and spiritual beliefs. He understood what he was doing. (EDIT: This does not mean that he necessarily didn't have mental problems, but that he was coherent enough to be able to justify his decisions sufficiently that the court found he was competent to make his own decisions about whether or not he needed treatment)
This poses a challenge, because it can be superficially extremely hard to distinguish actual mental illness from "crazy" lifestyle choices that the person making them are perfectly happy with.
The guy mentioned above was very bright and able to get the resources he needed to protect what he saw as his own best interests in court (all the way to the supreme court 3 times, with one win), but most don't.
Many of these people are mentally ill and need treatment, but we also need to protect those who aren't, and especially those who aren't yet are not resourceful enough to mount vigorous legal campaigns to protect their choices.
At the same time setting the bar high means there are potential high costs and lots of resources involved in helping people that makes it harder to help those who need it out of a concern for e.g. distinguishing resistance and refusals grounded in mental illness from resistance and refusals from people who are mentally competent.
Getting the balance right is hard.