HSAs are not tax-exempt in those states. You have to calculate your own short- and long-term capital gains, dividends, interest, etc. and pay state taxes on them every year.
• This can be especially tricky if you hit a home run... imagine if you're daytrading or speculating in your HSA because it's triple-tax-advantaged, and figure if you are going to get rich, there's no better account to do it in than an HSA. So you take your $3500 annual contribution and in 2019 buy 350 shares of Gamestop at $10. You sell those 350 shares in 2021 at $420.69 for $147,241.50.
You now have a long-term capital gain of $143,741.50 which your state considers regular income. Your marginal state tax rate might be about ~9.5% in California, for example, so you owe $13,655.44 in state taxes.
However, you cannot withdraw the profits from your HSA to pay those state taxes... HSA withdraws can only be for medical reasons. You're going to have to come up with $13,655 of your own money out of pocket to pay the bill on April 15th.
• This is also difficult at tax time because most HSA providers (like Fidelity) do not provide 1099-DIV or 1099-B statements for HSA accounts. They figure they're tax-free accounts so why bother. This means you have to manually track all your ins & outs, dividends, and interest and report them yourself to the state. Sure, that also means the state is not getting a copy of your brokerage info, so, all this must be self-reported, and you could duck out on the state taxes... but... you're running the risk that they find out someday and start hitting you hard for avoiding back taxes.
• You might also figure you'll only buy things in your HSA that are long term holds and not sell until you retire, and then retire out of state to avoid the taxes on the gains. California thought of that... if/when you move out of state, you're supposed to tally up your HSA gains from before you left and cut them a check for their portion of the taxes as of the date you move out.
There are proposals in place, at least in California, to bring HSA treatment in line with federal rules, but, for now, the state really wants that income and those proposals are going nowhere.