Got 1099-R for excess contribution made to Roth IRA

Here is my situation and I really appreciate if you could please help me with some pointers.

- In 2018, I contributed to Roth IRA. In late 2020 I realized that I was not eligible to contribute.

- Immediately, I asked the custodian to return the excess contribution made ($5k). Also filed an amended return and paid the penalty of $300 for each year of such excess contribution.

 

Come 2020 taxes, I received 1099-R with Code J.  Looks like I have to pay a penalty of 10% though it is really not a distribution but have withdrawn what was excess contribution.

 

Is this really a Code J requiring me to pay penalty or is there an exception.  Please help.