Entire amount of excess contribution to Roth IRA incorrectly marked as taxable.

I have incorrectly contributed $8000 to Roth IRA directly (I should have done a backdoor Roth instead due to income limit). So I withdrew it as soon as I found out, a total of $8002.07). I got a 1099-R that clearly states taxable amount (2a) as $2.07. the form has two codes (8J). When I check my finalized tax return 1040, I found that the entire $8002 is taxable. How do I fix this?