It had to be Katy or Bonnie, but Bonnie did write the song, so that gives us a big clue
Lola Blanc wrote the song for herself and then Dr. Luke asked if he could have it for Britney. Bonnie and other songwriters then changed some lyrics to better fit Britney.