Plan Administrator or TPA need to issue payment to IRA for balance due to bring the gross deposit up to $40k. Recordkeeper needs to file amended 945(IRS) and whatever state form to get back taxes incorrectly withheld. Corrected 1099's need to be issued, showing 40k rollover, and 0 cash distribution with 0 taxes. Returned taxes can be paid to whoever fronted the corrective deposit. TPA and Plan Administrator can then bicker over fees and responsibility.
Basic tenant of any correction, put the participant in the position they should have been in without the error, without harm. That would mean 40k in the IRA, and no tax shenanigans!!