Bothersome Mean/Variance Analysis

I'm currently writing my thesis in which I compare a series of ESG General Equilibrium models. I fell over this proof in Pastor, Stambaugh, Taylor Sustainable Investing in Equilibrium (2019) page 42. Here, they prove going from a given utility function to the models portfolio weights. These are the calculations of which I simply don't understand how they start on the second line and arrive at the third: \begin{align} \mathbb{E}( V(\tilde{W}_{1i},X_i)) &=\mathbb{E}(-e^{-A_i(W_{0i}(1+r_f+X'_i \tilde{r})-b'_iX_i)} \\&= -e^{a_i(1+r_f)} \mathbb{E}( e^{-a_i X_i'(\tilde{r}+\frac{1}{a_i} b_i)})\\ &= -e^{a_i(1+r_f)} ( e^{-a_i X_i'(\mathbb{E}(\tilde{r})+\frac{1}{a_i} b_i)+\frac{1}{2}a^2_i X'_i\Sigma X_i}) \end{align} We've previously defined $$\tilde{r}\sim(\mu,\Sigma)$$.

I've been staring at this for hours. I hope somebody can help me out with a hint on what is happening between these two steps.

New contributor
MathyFoxy is a new contributor to this site. Take care in asking for clarification, commenting, and answering. Check out our Code of Conduct.

The equality in question follows from the expression for expectation of a log-normal distribution. For example, if $$X \stackrel{d}{\sim} N(\mu, \sigma^2)$$, then $$E[e^{a X}] = e^{a \mu + \frac12 a^2 \sigma^2}.$$ This is the reason that CARA/normal or CRRA/log-normal (agent utility/asset return distribution pair) set-ups reduce to the mean-variance case, up to certainty equivalence.