1099Q and 1099Q mismatching over a small timing issue. How to avoid paying undue tax?

I am a parent, working on our 2023 family return. My son is a student. He's a dependent. His college tuition bills are paid from a 529 QTP fund we had set up for him. I ran into a small issue that is entirely due to tuition payment timing. 

 

Here's what happened. I am rounding the numbers, just keeping the essence here:

His 2022 1099Q was for 5,000 gross distribution (box 1), his 2022 1098T was for for 15,000 in tuition expenses (box 1) and 5,000 in grants (box 5).  

His 2023 1099Q was for 15,000 (box 1), his 2022 1098T was (again) for for 15,000 in tuition expenses (box 1) and 5,000 in grants (box 5).  

As you can see, 2022 distributions are $5,000 short of tuition we paid in 2022, and 2023 distributions are $5,000 in excess of what we paid in 2023. 

This is because I made the following payments:

$5,000 in Aug 2022 for 2022 fall semester
$5,000 in Jan 2023 last moment payment for 2023 spring semester
$5,000 in Aug 2023 for 2023 fall semester
$5,000 in Dec 2023 advanced payment for 2024 spring semester.

 

Now, Turbotax is taxing the $5,000 excess of 2023. I'd like to reconcile this problem so we can claim the American Opportunity credit for my son this year. Is there a way to do that?