Excess Roth IRA contribution

I made a Roth IRA contribution in 2023 of $6500 and didn't realize my error until TurboTax flagged it as excess due to not having earned income. I did a return of excess (in 2024) with my brokerage, and it was determined that my withdrawal distribution would be $4352.59 as I had $2147.41in losses.  I have not yet filed my taxes for 2023 and am wondering how to input this information so I won't have to pay taxes on the difference as TT has me put $6500 in as a contribution and my brokerage says my 1099R will show a distribution of $4352.59 with a separate letter showing the losses that I won't get until next year.  Right now TT is wanting me to pay $129 of tax because I took out less than I contributed but exactly the amount the brokerage said I needed to.  I'm confused on how to do his properly, can someone help?