Xi thought China could win the political battle without losing the economic one. He assumed the alliance would split apart, and the US would be forced to back down. At that point China would be free to project it's power across most of Asia without interference from the West. Whether that's taking back Taiwan, or at least the entirety of the nine-dash line islands. The US or any other foreign vessel couldn't transit the South China sea without the OK from China.
He tried to pick off the members of the alliance one by one (the trade battle with Australia is a great example), but failed. Eventually the US and other nations said "enough is enough" and instituted sanctions on China. In addition private companies decided the political uncertainty was too high a risk. Combine that with the demographic bomb the country is facing, the debt-bomb from Chinese real estate and Xi realized he lost his gamble. The Chinese economy couldn't survive long enough under sanctions for China to win the political battle.
But to be honest, he burned too many bridges. The Chinese economy is struggling. The embargo on technology is going to hurt China way more than it hurts the West. He came to San Francisco in hopes of repairing enough of the relationship as to not entirely sink the Chinese economy.