Immediately after Jennifer Lopez‘s debuted her new single, “Ain’t Your Mama,” with a killer performance on last week’s American Idol finale, the Internet picked up on the fact that the catchy pop song was co-produced by Dr. Luke, the write-producer who’s been locked in a legal battle with Kesha since she sued him in 2014 for alleged sexual abuse.

What followed was a rash reaction from the Twitterverse that had weeks ago pleaded with Sony Music to #FreeKesha from her contract that kept her legally connected to Dr. Luke.

But as E! News previously reported, Lopez never actually worked with Dr. Luke on the song—and now Trainor, who co-wrote the female-empowerment tune with Jacob Kashner, has gone to bat for her girl, saying that Lopez was not at all aware of Dr. Luke’s involvement in the early production of the song. A source told us that Trainor wrote “Ain’t Your Mama” and worked with Dr. Luke years ago—before Kesha filed her lawsuit.

“I felt terrible when Jennifer got all the hate for [“Ain’t Your Mama”], and it’s just all ridiculous,” Trainor said in a chat with reporters. “[It was] not fair on her, not at all. I texted her the song and she had no idea—she thought I did it alone by myself at my house, which a lot of people think because I do do that.”

Kevin Winter/Getty Images

The “All About That Bass” singer went on to explain that she has written three songs on J.Lo’s upcoming album, “Ain’t Your Mama” being one of them, and that Lopez seems to be a fan of her writing.

“She told me she just wrote a book about [self-confidence] and said, ‘This is real!'” Trainor recalled. “I said, ‘J.Lo, if you say these things, everyone will relate to that too.’ I’m so proud of her and this new album is going to be huge for her.”