Why is this true?
$$\int_{0}^{1}u^0(x)\sin(l\pi x)dx = \int_{0}^{1}u(0,x)\sin(l\pi x)dx$$ $$ = \int_{0}^{1} \sum_{m=1}^{\infty} a_m \sin(m\pi x)sin(l\pi x)dx$$ $$ = \frac{a_l}{2}$$
where coefficients ${a_m}$ are determined by $u(0,x) = u^0(x)$ which are the initial conditions to $u_t(t,x) = u_{xx}(t,x)$
It is true because of the trigonometric identity $$ \sin(A)\sin(B)=\frac12\left[\cos\frac{A-B}2-\cos\frac{A+B}2\right] $$
Series and integral can be switched in position if $\sum_{m=0}^\infty a_m^2<\infty$, which is the case if $u^0\in L^2([0,1])$.