Excess 401k contributions in 2022, 1099-R in 2023

My employer messed up and deferred too much into my 401k in 2022. I included that excess amount as income on my 2022 tax return (and received in April 2023 a refund of the excess from the 401k folks). Now I received a 1099-R for that same excess amount with Code 8 in Box 7, which appears as additional income on my 2023 tax return.

How do I avoid paying double tax on that? I asked if the 1099-R box 7 should really have been code P, but the 401k person I spoke with didn't know much. Help!