This could be a naive question but I am just puzzled. I am learning the following proof of Rao-Blackwell theorem but get puzzled by the equation in the red box. Why the two expectations can be reduced to one expectation? Thank you.

This could be a naive question but I am just puzzled. I am learning the following proof of Rao-Blackwell theorem but get puzzled by the equation in the red box. Why the two expectations can be reduced to one expectation? Thank you.

This is an application of the law of total expectation.