How to exclude HSA contributions from CA income tax, if those contributions are made before moving to CA? I was MA resident for part of 2021 and moved to CA.

I used to be MA resident in 2021 and made contributions with high-deductible health insurance from previous employer. Then I moved to California mid-year (the new company does not provide HSA).
Now, I see that CA is taxing the contributions made towards HSA, even though they were made with income outside CA while working for a company outside CA. (note that CA, in general, does not deem HSA contributions tax-free).
It make sense to include this if those contributions were made inside CA. Is it possible to exclude them in this case?
Thanks!