The game-winner came when Evander Kane carried the puck down the left side and threaded an accurate pass to Hainsey, who tipped a shot past Sergei Bobrovsky.
Atlanta entered the third period trailing 3-0 but outscored Philadelphia 4-1 down the stretch to force an overtime and then take its third win in four games.
Kane and Andrew Ladd each collected a goal and an assist, and Zach Bogosian and Tobias Enstrom also scored in the final period for Atlanta.
Chris Mason got victory, stopping 11-of-12 shots after relieving starter Ondrej Pavelec, who had yielded three goals on 12 shots through two periods before being pulled.
Ville Leino scored a hat trick but it wasn't enough to prevent Philadelphia's fifth loss in seven games.
Bobrovsky ended up allowing five goals on 41 shots for the Flyers.
Lytro unveils camera that can focus a photo after shooting it
Easer Egg Roll brings thousands to White House