Using HSA to pay for medical expenses for a child with shared custody

beI have a nine-year old son from a previous marriage.  My ex-wife and I share joint legal custody but she has physical custody and only she claims him as a dependent on her tax return, I do not.  I also understand that I can still use my HSA account to pay for his medical expense according to IRS publication 969: "a child of parents that are divorced, separated, or living apart for the last 6 months of the calendar year is treated as the dependent of both parents whether or not the custodial parent releases the claim to the child’s exemption."  My ex-wife do not have an HSA account, only I do.  Finally, our divorce agreement says we are each obligated to 50% of the reasonable uninsured health-care costs for the child, as well as to 50% of extracurricular and other school expenses (non-healthcare costs) of the child.  Suppose that my son incurs $1000 of healthcare costs and $1000 of non-healthcare costs, would both of the following payment arrangements be acceptable by the tax code, or could any of them be disallowed?

 

Arrangement 1:   I use my HSA to pay $500 of my son's uninsured healthcare costs and use my regular checking account to pay $500 of his non-healthcare costs.  My ex-wife uses her checking account to pay $500 for his healthcare costs and $500 for non-healthcare costs.  We each pay a total of $1000.

 

Arrangement 2:   I use my HSA to pay $1000 of my son's uninsured healthcare costs.  My ex-wife uses her checking non-HSA funds to pay $1000 of my son's non-healthcare costs.  We still each pay a total of $1000, but in this scenario I take more advantage of my HSA account.