dmertz
Level 15

Get your taxes done using TurboTax

The fact that the returned contribution was used to fund a 2022 contribution has no effect on the 2021 tax return.  It's equivalent to the distribution being paid to you in cash and you using that same amount of cash to make a new contribution.  You just need to make sure that you understand that the amount contributed for 2022 is the gain/loss amount distributed for the return of contribution, not the amount of contribution returned (unless there was no gain or loss, in which case the amount distributed equals the amount returned).