since it gains happiness when its at the front of your team does it lose happiness when its at the back of your party?
To put it simple
NO
No, Pokemon do lose happiness when they faint and also there are some items that may reduce a Pokemons happiness. (Powders, Roots and some Herbs) Also when a Pokemon is traded its happiness will reset. Hope I helped.