New York State used to keep their mentally ill convicts in prison beyond their release dates. That was many years ago. Then one or more inmates sued the State, and the court ordered the State to release them, because "being mentally ill isn't a crime."
So how does San Francisco plan on legally forcing mentally ill drug users to undergo treatment, when it still isn't against the law to be mentally ill.
Needles are not the same as drugs. It's a cheap precaution to minimize a chance of extremely costly disease outbreaks from groups of people sharing needles in the streets. Eventually those diseases would pass to non drug users