HSA and medical funds for 2024

Hello --- I am single and under the age of 50. I have a HSA to which my employer contributes $1,000/year. This year (and next), I will be having a medical treatment for which I will need to spend nearly $3,300 this year and roughly $2,500 next year. I have slightly more than this combined amount in my HSA already.

 

I am interested in the best recourse to save on taxes. Is my following understanding correct? I can withdraw the $3,300 from my HSA and put back $3,100 this year. Next year, I can withdraw $2,500 and put back $3,100.