The city uses an expanded definition of homelessness that includes people who are "doubled-up" in the homes of family or friends [1]. The survey referenced in the source you've linked counts people dealing with LGBTQ-related issues that, while terrible, aren't what most people think of when they picture homelessness in SF.
The "man shooting heroin on the street" sorts of homeless folks are, in my limited experience volunteering, generally not from SF but some other part of CA.
69% of people had housing in San Francisco before they became homeless and 72% of those people have been in San Francisco for at least five years.
https://atthecrossroads.org/news/myths-facts-about-homelessn...