SPOILER WARNING: This article contains major spoilers for "Flashback," the latest episode of "The Flash."
In "Flashback," the latest episode of "The Flash," Barry Allen went back in time in order to learn from Reverse-Flash himself how to get even faster. During his trip to the past, he didn't just learn how to speed up -- he made a major change to the timeline. Thanks to his trip down memory lane, Hartley Rathaway -- aka Pied Piper -- is now on Team Flash's side.
When Barry traveled back in time, he went to the day he captured Rathaway. A time wraith followed him there and interrupted his mission, which caused some havoc at STAR Labs. The time wraith forced Cisco and Caitlin into the Pipeline cell with Rathaway, who used his sonic technology to chase the time wraith off and save all three of them.
It seems Rathaway enjoyed his fight on the side of the angels, because -- when Barry returned to the present -- he was on Team Flash's side. The time wraith followed Barry back to his time and attacked him when Cisco's tech didn't work against it. Barry was at death's door when Rathaway used his own tech to defeat the time wraith once and for all. Much to Barry's surprise, Cisco and Caitlin greeted Rathaway like old friends. During the year in between Barry's journey, it seems he worked with Team Flash to develop anti-time wraith measures.
In the comics, Pied Piper was also originally a villain; in fact, he was a member of the Rogues. However, over time, he eventually became a friend of the Flash -- albeit with Wally West, not Barry Allen. In New 52 continuity, he has even dated David Singh, the captain of the Central City Police Department.