So this is a tad complicated.... I'll explain via an example.
Let's say I had a Snorlax with the move return. Snorlax's happiness value is maxed (i.e. Return has maximum base power). If I trade Snorlax to a friend, and then back in Gen 6, then the happiness value is restored to the value that I left off with Snorlax before I traded it to my friend (so return still has maximum base power).
However, let's change the situation so that Snorlax is now being deposited in the Gen 6 GTS because I want a Lv.1 Magikarp. When I realize that depositing it for Magikarp is stupid, I will take Snorlax back out of the GTS deposit. Does Snorlax still have maxed happiness value (i.e. Return still has maximum base power)?
There are two variables that determine the answer.
1. Does it count as trading?
2. Does it follow the same rules as other forms of trading?
My research from other sites has brought up surprising results (which is why I'm asking this here). It appears that the happiness is reset according to other likely unreliable sources.
Also, if anyone happens to know if this worked differently before the previous owner happiness rule introduced in Gen 6, then this is a convenient place to post findings.