Why does TurboTax deduct HSA distributions when calculating medical expenses for Schedule A when some of those distributions might have been for a previous years expense?

I understand that the way TurboTax works, it expects you to enter ALL expenses in Medical and Dental for Schedule A, then it will ask you for the amount of insurance reimbursements so it can subtract that, and then TurboTax will automatically subtract the HSA distributions. But what if my HSA distributions included expenses (say, $1000) that were paid for out of pocket in the previous year, but reimbursed this year? Hypothetically, if I have $12,000 in OOP medical expenses in 2017, and requested and received HSA distributions for $5000, then I should be able to itemize $7000 worth of expenses on Schedule A. But if my actual HSA distributions for the year, also included a $1000 reimbursement for an expense incurred last year, but refunded this year, then TurboTax will only put $6,000 of itemized medical expenses on Schedule A.