A 529 distribution sent directly to the school by the account administrator is treated the same way as if it had been sent to the student. If the school subsequently refunds money that can reasonably be considered part or all of a payment made using 529 funds, the best thing to do (usually) is to return the refunded money to the 529 account within 60 days after the date of the refund, and in such case you can avoid the need to figure the taxable part of the distribution (it’s like the distribution of the refunded money never happened).
1 Like