There’s a lot of gray area with a recontribution and, as noted here by DigitalDad, different 529 plans will have different procedures.
My personal and anecdotal experience happened when a scholarship posted to a student’s account late, after the original balance due had already been paid in part with 529 funds. The school refunded the overpayment (no form of any kind to complete and sign), and within 60 days the refund amount was deposited in the student’s 529 account. The 529 plan didn’t care that it was a recontribution, and on the next account statement it was designated as a regular contribution. One of my thoughts was that the earnings portion of the refunded amount was effectively “washed” when the plan administrator designated the full amount as a new contribution (even though they were clearly on notice that the deposit was really a recontribution of part of an earlier distribution).