Just to be clear the last response. If you take out a loan in Jan 2018 to pay a qualified expense and then in Dec 2018 you withdraw 529 fund and pay back the loan, that is ok. However, if you withdraw 529 funds in Jan 2019 and pay off the loan, that is not ok. Is that correct?
I guess this all comes down to loans have nothing to do with determining qualified expenses. For example, if I use a $1,000 loan to pay my tuition and my total tuition is $10,000, I can still withdraw $10,000 from my 529 as qualified expenses.