Most Harmless Econometrics: Chapter 3.3.1, how to simplify Equation (3.3.6)? I have one questions about the simplification steps of Equation 3.3.6 in the Chapter 3.3.1 in Most Harmless Econometrics. We know that
$$
\delta_R = \frac{E \{ (D_i - E[D_i|X_i]) E[Y_i|D_i, X_i] \}}{E[(D_i - E[D_i|X_i])^2]}, \tag{1}
$$
and
$$
E[Y_i|D_i, X_i] = E[Y_i|D_i=0, X_i] + \delta_X D_i, \tag{2}
$$
where,
\begin{align*}
    \delta_X  &\equiv E[Y_{1i}|X_i, D_i=1] - E[Y_{0i}|X_i, D_i=0] \\
    &= E[Y_{i}|X_i, D_i=1] - E[Y_{i}|X_i, D_i=0],
\end{align*}
Now, we substitute (2) into the numerator of (1), and get
\begin{align*}
    E \{ (D_i - E[D_i|X_i]) E[Y_i|D_i, X_i] \}
    &= E \{ (D_i - E[D_i|X_i]) E[Y_i|D_i=0, X_i] \} \\
    &\quad + E \{ (D_i - E[D_i|X_i]) \delta_X D_i \}
\end{align*}
The first term on the RHS is zero because $D_i - E[D_i|X_i]$ is uncorrelated with $E[Y_i|D_i=0, X_i]$. My question is how to simplify the second term such that
$$
E \{ (D_i - E[D_i|X_i]) \delta_X D_i \} = E \{ (D_i - E[D_i|X_i])^2 \delta_X \}
$$

Write $$ \left(D_i - \mathbb{E}[D_i \mid X]\right) D_i \delta_X = \left(D_i - \mathbb{E}[D_i \mid X]\right)^2 \delta_X + \delta_X \mathbb{E}[D_i \mid X]\left(D_i - \mathbb{E}[D_i \mid X]\right) $$ and take expectations, noting that the second term becomes zero by the covariance matching/orthogonal projection property of conditional expectations.
