From @Cretin2's comment I figured what the original answer was missing was splitting the equation into homogenous and inhomogeneous parts.So I start with that:-
$$
u_t=Ku_{xx} \\
u(x=0,t)=f(t) \\
u(x=L,t)=g(t) \\
u(x,t=0)=\phi(x)\\
$$
$u$ is composed of a homogenous and inhomogeneous term, represented by $u_h$ and $u_{ih}$ respectively
$$
u=u_{ih}+u_h \\
\frac{\partial^2u_{ih}}{\partial x^2}=0 \\
\implies u_{ih}=c_1x+c_2 \\
$$
Substituting-
$$
u_{ih}(x=0,t)=f(t) \\
u_{ih}(x=L,t)=g(t) \\
$$
we get,
$$
c_2=f(t) \\
c_1=\frac{g(t)-f(t)}{L} \\
\implies u_{ih}=\frac{g(t)-f(t)}{L}x+f(t)
$$
Plugging this into the equation for $u$, we get,
$$
u=\frac{g(t)-f(t)}{L}x+f(t)+u_h \\
\frac{\partial u}{\partial t}=\frac{\dot{g(t)}-\dot{f(t)}}{L}x+\dot{f(t)} + \frac{\partial u_h}{\partial t} \\
\frac{\partial^2 u}{\partial x^2}=\frac{\partial^2 u_h}{\partial x^2} \\
\implies \frac{\partial u_h}{\partial t}=K\frac{\partial^2 u_h}{\partial x^2}+\frac{\dot{f(t)}-\dot{g(t)}}{L}x-\dot{f(t)}
$$
Let $\frac{\dot{f(t)}-\dot{g(t)}}{L}x-\dot{f(t)}=F(x,t)$ which is now the "source term"
$$
\frac{\partial u_h}{\partial t}=\frac{\partial^2 u_h}{\partial x^2}+F(x,t)
$$
with boundary conditions :-
$$
u_h(x=0,t)=0 \\
u_h(x=L,t)=0 \\
u_h(x,t=0)=u(x,t=0)-u_{ih}(x,t=0) \\
\implies u_h(x,t=0)=\phi(x)-\frac{g(0)-f(0)}{L}x-f(0)=\psi(x)
$$
To solve this PDE, I can now use eigenfunction epansion. If there was no source term, by using separation of variables we could solve $u_h$
$$
u_h(x,t)=\sum_{n=1}^\infty u_n(t) \sin(\lambda_n x) \\
\lambda=\frac{n \pi}{L}
$$
Where $u_n(t)$ is the time dependent factor of $u_h(x,t)$.
$$
\frac{\partial u_h}{\partial t}=\sum_{n=1}^\infty v_n(t) \sin(\lambda_n x) \\
\frac{\partial^2 u_h}{\partial x^2}=\sum_{n=1}^\infty w_n(t) \sin(\lambda_n x) \\
$$
where,
$$
v_n(t)=\frac{d u_n}{dt} \\
w_n(t)=-\lambda_n^2 u_n(t)
$$
Let $F(x,t)=\sum_{n=1}^\infty f_n(t) \sin(\lambda_n x)$
Wecan substitute all of these in the original equation and after some simplification we get,
$$
\frac{du_n}{dt}=-K\lambda_n^2u_n(t)+f_n(t)
$$
This is a simple ODE in $u_n$ which I solved by multiplying by an integrating factor to get -
$$
u_n(t)=e^{-\lambda_n^2Kt}\int_0^t e^{\lambda_n^2 K\tau}f_n(\tau) d\tau + e^{-\lambda_n^2Kt} c
$$
where $c$ is a constant of integration
$$
u_n(0)=0+c
$$
So we need to now find u_n(0) and f_n(t). We know,
$$
\int_0^L \sin(\lambda_mx)\sin(\lambda_nx) dx=0, m\neq n \\
= L/2, m=n
$$
we have,
$$
u_h(x,t)=\sum_{n=1}^\infty u_n(t) \sin(\lambda_n x) \\
\int_0^L u_h(x,t)\sin(\lambda_n x) dx = u_n(t) L/2 \\
u_n(0)=\frac{2}{L}\int_0^L u(x,t=0) \sin(\lambda_nx) dx \\
\implies u_n(0)=\frac{2}{L}\int_0^L \psi(x) \sin(\lambda_nx) dx
$$
Similarly for $f_n(t)$ we have,
$$
f_n(t)=\frac{2}{L}\int_0^L F(x,t) \sin(\lambda_n x) dx
$$
Plugging everything in, we get,
$$
u(x,t)=\frac{g(t)-f(t)}{L}x+f(t)+\sum_{n=1}^\infty u_n(t) \sin(\frac{n \pi}{L} x) \\
u_n(t)=e^{-(\frac{n \pi}{L})^2 Kt}\int_0^t e^{(\frac{n \pi}{L})^2 K\tau}\frac{2}{L}\int_0^L \frac{\dot{f(\tau)}-\dot{g(\tau)}}{L}x-\dot{f(\tau)} \sin(\frac{n \pi}{L} x) dx d\tau \\
+ e^{-(\frac{n \pi}{L})^2Kt} \frac{2}{L}\int_0^L \psi(x) \sin(\frac{n\pi}{L}x) dx
$$
This satisfies all the BCs without the need to introduce any additional conditions