This issue reminds me of the refugee problems happening recently in Europe. The problem was refugees trying to get into Europe and should've been the responsibility of the entire EU to solve. But the problem was felt most acutely in the Greek islands where refugees were showing up. And when an national/continental issue is felt primarily by a single, smaller region, it's highly problematic.
As a thought experiment, what would happen if SF started sheltering the homeless and ensuring that all their needs were met. Well, suddenly those bus tickets bought by cities around the country become a lot more effective and more cities around the country start buying them. It's even the moral thing for social workers to do, since the political climate in their city means that it's better for the person being bussed out to go to SF. It becomes a tragedy of the commons situation where the disincentive for doing the right thing is that you get to deal with the problems from the places that do the wrong thing. A homeless person going elsewhere is a living externality.
This is a national problem (probably international, though deportation is considered entirely acceptable in that situation) and needs to be treated as such. If the Federal government doesn't want to deal with the problem, it could pass a law that allows the city that provides services to a homeless person to bill the cost to the homeless person's home city. Suddenly that bus ticket wouldn't seem like the cheapest option and SF could provide all the services necessary to solve its own homeless problem. Until then, the situation will remain fucked. SF is too liberal to be take a GTFO stance and too poor to comprehensively solve the problem for all the homeless that are there now and would show up if they started such a program.