The question is to let $y_1..., y_n$ denote a sample from a normal distribution with $\mu$ and $\sigma^2$. For testing $H_0: \sigma^2= \sigma_0^2$ and $H_a: \sigma^2 > \sigma^2_0$, show the likelihood ratio test is equivalent to a chi-squared test.
Below is the solution given:
I'm having trouble understanding the equation that comes after "If $\sigma^2 > \sigma^2_0$". From the looks of it, it seems like we're plugging in the MLE for $\sigma^2 = \frac{1}{n} \sum_{n=1}^n (y_i - \overline{y})^2$, but why are we doing this? Help would be much appreciated!

You start with $$ \hat{\sigma}^2 = \max\{\sigma_0^2,\frac{1}{n}\sum_{i=0}^n(y_i-\bar{y})^2\} $$ if $\hat{\sigma}\neq \sigma_0$ which occurs only for $$ \hat{\sigma}^2 = \frac{1}{n}\sum_{i=0}^n(y_i-\bar{y})^2> \sigma_0^2 $$ All other cases leads to $$ \hat{\sigma}^2 = \sigma_0^2 $$ Thus we know that $$ \hat{\sigma}^2 = \frac{1}{n}\sum_{i=0}^n(y_i-\bar{y})^2\ $$ then you can follow through the calculation.