Excess after-tax contributions to a traditional 401(k) - An unusual situation

Hello,

 
I'd be very grateful for any information on how to appropriately resolve the following issue.
 
In 2021, I made after-tax unmatched contributions to my traditional 401(k), and in the same year, rolled over the contributions and earnings to a Roth and Traditional IRA, respectively (the "mega backdoor Roth" strategy).
 
In 2022, I learned that due to an error by the 401(k) administrator, the 2021 after-tax contributions exceeded the plan limit (not the IRS limit). The 401(k) administrator requested that I send the funds back to them to be reprocessed for tax purposes. As a result, I recently completed "withdrawal of excess IRA contributions" processes for the Roth and Traditional IRAs to reclaim the funds at their current value (there were losses since the rollover). I sent a check back to the 401(k) administrator for the full value of the after-tax contributions and the earnings at the time of the rollover. I believe they should be sending me back the full amount of the after-tax contributions and treating the earnings prior to rollover as taxable income. 
 
My questions are as follows:
  • Do I need to amend my 2021 tax return to include the earnings on the excess 2021 after-tax contributions as taxable income, or would they be reported in 2022?
  • Are there any penalties applicable to this situation? Specifically, do I have to pay a penalty on the earnings from the excess after-tax contributions while they were in the 401(k)? There should be no penalties associated with the actual after-tax contributions, right?
  • Lastly - are the following assumptions regarding the IRA rollovers correct? Having removed the excess IRA contributions before 10/17/22, I'll avoid the 6% penalty. With no earnings on those funds since the rollover, I also avoid the 10% penalty on earnings. As a result of no taxable events or penalties in this situation, this wouldn't require an amended 2021 tax return. 
Thanks in advance for any information!