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?