Solution (source code)

= Solution

Construct independent copies $Y_1,Y_2,\ldots$ of $Y$, also independent of $X$, and define the <random sum> $Z=\sum_{j=1}^X Y_j$, taking the empty sum to be zero. Independence gives, conditional on $X=n$,
$$
\mathbb E[e^{tZ}\mid X=n]=M_Y(t)^n.
$$
The <law of total expectation> gives the <transform composition for an independent random sum>
$$
\boxed{M_Z(t)=\sum_{n=0}^{\infty}\mathbb P(X=n)M_Y(t)^n=G_X(M_Y(t)).}
$$
The summands are nonnegative, so this equality is valid also as an extended-valued expectation. Where the right-hand side is finite, it is the ordinary <moment-generating function> of the constructed <random sum>. The construction does not assert a finite <moment-generating function> near zero for arbitrary $X,Y$: heavy tails can prevent this. For example a nonnegative $Y$ with no positive exponential moments and $X\equiv1$ already shows the necessary qualification.