 Hannon Lane co-wrote and co-produced the song, and Demacio Castellon recorded and mixed it in 2007 at Roc The Mic Studios in New York City.Rihanna's stint with Timbaland also resulted in "Sell Me Candy" and "Lemme Get That", produced for "Good Girl Gone Bad".Timberlake told "Entertainment Weekly" that he believed "Rehab" to be "the bridge for [Rihanna] to be accepted as an adult in the music industry".