Hayes returned to Glanford Park, two years after leaving, when his contract ran out at the Tykes.
As he was under 24 a transfer fee must be paid, with a tribunal on October 5 scheduled to decide a fee after the two clubs were unable to settle on a price.
But Iron chairman Steve Wharton met with his Barnsley counterpart on Saturday, when the Yorkshire side were 2-0 victors over United, and came to an agreement. The fee has not been disclosed.
United will also have to pay a fee for forward Martin Paterson, who joined from Stoke in the summer. The tribunal had also been set ofr October 5, but has been postponed as Potters officials were unavailable.