I accidentally made a mistake during my federal tax return for 2021 during the W2 income/tax data entry portion. As a result, the system interpreted that I owed $4,000 to the IRS. Before realizing the mistake I went ahead and made the payment (which the IRS has not withdrawn yet).
Now I am filing a 1040X to correct this error and am instead supposed to receive a refund of $5,000. On the 1040X Form Line 18: "Overpayment, if any, as shown on original return or as previously adjusted by the IRS" would I need to enter the $4,000 for the payment I made in error (even though it has not been withdrawn by the IRS yet)? I just want to make sure that I get my correct refund back of $5,000 and am not charged the $4,000 over the mistake on the original filing.
Separately, would I need to file the 1040X first with the IRS before I can amend my state tax filing since the original error transferred to the state filing portion as well?