Envelope Theorem in Hopkins and Kornienko (2010) This is from Hopkins and Kornienko (2010). In this model, $x$ is investments, $s$ is status, and $y=z-x$ is leisure, where $z$ is endowments. $x(r)$ is the optimal investment, and the relative investments determine the status in the model. Here they characterize the agent with the rank, $r$, and derive the reduced form utility. But, I am not quite sure about how the envelope theorem works here. 

If I differentiate $U(r)$ with respect to $r$ and suppress the arguments, I have that
$$U_x x' + U_y(y'-x') + U_s s'.$$
I know that $Z'(r) = \frac{1}{g(Z(r))}$, where $g$ is the density of $z$. This implies that the first term and third term and $U_yx'$ turn out to be zero to make the above equation equal to Equation (8). My understanding is that $U_x = U_s = 0$ since $x(r)$ is the optimal investment. But, I don't know how to explain the elimination of $U_yx'$. Can anyone give me some help?
From the first order condition for optimality, we know that (equation (4) in the paper):

$$U_x(x,Z(r)-x,S(r))x'(r) - U_y(x,Z(r)-x,S(r))x'(r) + U_s(x,Z(r)-x,S(r))S'(r)=0.$$ 

When differentiating ${\bf U}(r)$ with respect to $r$, we find your expression:
$$U_x(x(r),Z(r)-x(r),S(r))x'(r) + U_y(x(r),Z(r)-x(r),S(r))(Z'(r)-x'(r)) + U_s(x(r),Z(r)-x(r),S(r))S'(r).$$ 

Replacing the first equation into the last one yields
$${\bf U}'(r)=U_y(x(r),Z(r)-x(r),S(r))Z'(r).$$ 

Now, $Z'(r)=1/g(Z(r))$ which gives equation (8).