Solution (source code)

= Solution

Assume $h(x)>0$, so the conditioning event has positive probability. For a continuous-time <Markov chain>, write $\tau_y=\int_0^{T_A}\mathbf1_{\{X_s=y\}}\,ds$. At each time $s<T_A$, the <Markov property> gives $\mathbb P(T_A<\infty\mid\mathcal F_s)=h(X_s)$. Using <Tonelli theorem> for the nonnegative occupation integral,
$$
\mathbb E_x[\tau_y\mathbf1_{\{T_A<\infty\}}]
=\int_0^\infty\mathbb E_x[\mathbf1_{\{s<T_A,X_s=y\}}h(y)]\,ds
=h(y)\mathbb E_x\tau_y.
$$
Division by $h(x)$ yields $\boxed{\mathbb E_x[\tau_y\mid T_A<\infty]=[h(y)/h(x)]\mathbb E_x\tau_y}$. The discrete-time proof replaces the integral by a sum. Infinite expectations are allowed in the nonnegative sense; if $h(y)=0$, the numerator is zero directly, avoiding an ambiguous product of zero and infinity.