Ineligible 2024 Roth IRA Contribution - How are earnings treated?

I made a $8000 2024 Roth IRA Contribution in February 2024. Because I had no earned income last year, I learned in January 2025 that I was ineligible for the Roth IRA contribution. I reversed the contribution on January 17, 2025.

 

As a result, I earned about $1400 while the dollars were in the Roth Account. These dollars were returned to me in January 2025. Should the $1400 in earnings be treated as income for the 2024 or 2025 tax year? 

 

Note: The initial $8000 dollars came from taxable brokerage account.