= Solution
Fix a proposal $y$ with $\widetilde q(y)>0$, and abbreviate $B=M\widetilde q(y)$, $H=h(y)$ and $P=\widetilde p(y)$. The envelope says $0\leq H\leq P\leq B$. Assuming fresh <independent> <uniform distribution> draws at both stages, the <law of total probability> gives
$$
\begin{aligned}
\mathbb P(\mathrm{accept}\mid Y=y)
&=\frac HB+\left(1-\frac HB\right)\frac{P-H}{B-H}\\
&=\frac HB+\frac{P-H}{B}
=\boxed{\frac{\widetilde p(y)}{M\widetilde q(y)}}.
\end{aligned}
$$
The second term includes both reaching the residual test and passing it. If $H=B$, the envelope forces $P=B$ and the first test accepts with <probability> one; the second-stage $0/0$ ratio is never evaluated. This is <squeeze rejection sampling>.
Back to article page