This is a commonly held belief but is not accurate.
One can pay all expenses from a 529 and still claim the AOTC. The net result is simply a tax, but not penalty, on the earnings portion of 4k of the 529 distribution. The IRS explains how to coordinate these benefits in the QTP section of Pub 970, which is the go to resource for education tax benefits: