Here is an alternative solution using energy conservation. I think it is a simpler approach.
Maximum acceleration occurs at maximum displacement of the spring where all kinetic energy terms are zero. From mechanical energy conservation we have, from the release point to maximum displacement, $$0=\Delta U_{\text{spring}}+\Delta U_{\text{grav.}}=\frac{1}{2}k~x_{\text{max}}^2-(m+3m)g~x_{\text{max}} \implies x_{\text{max}}=\frac{8mg}{k}.$$ At any other point ##x## we have $$\begin{align} & \Delta U_{\text{elastic}}+\Delta K_{wheel}+\Delta K_{\text{masses}}+\Delta U_{\text{gravity}}=0 \nonumber \\
& \left(\frac{1}{2}k~x^2\right)+\left(\frac{1}{2}mv^2+ \frac{1}{2}mR^2\omega^2\right)+\left(\frac{1}{2}(4m)v^2\right)+\left(-4mgx\right)=0.\nonumber
\end{align}$$ For rolling without slipping ##\omega=v/R## and the equation simplifies to $$\frac{1}{2}k~x^2+3mv^2-4mgx=0\implies \left(\frac{1}{2}v^2\right)=\frac{2}{3}gx-\frac{1}{12}\frac{kx^2}{m}.$$ We can now find the acceleration $$a=\frac{dv}{dt}=\frac{dv}{dx}\frac{dx}{dt}=v\frac{dv}{dx}=\frac{d}{dx}\left(\frac{1}{2}v^2\right)=\frac{2}{3}g-\frac{k}{6m}x.$$Thus, the initial value of the acceleration is ##a_0=\frac{2}{3}g.## It is positive, i.e. in the same direction as the displacement ##x.## The wheel accelerates to the right and the hanging masses accelerate down. As the spring is extended, the acceleration decreases until it reaches zero at the equilibrium position. Past that it turns negative, which means "to the left" for the wheel and "up" for the hanging masses.
The maximum acceleration is $$a_{\text{max}}=\frac{2}{3}g-\frac{k}{6m}x_{\text{max}}=\frac{2}{3}g-\frac{k}{6m}\frac{8mg}{k}=-\frac{2}{3}g$$ and is directed "up". Taking "down" as positive, we write Newton's second law for mass B as $$-T+3mg=(3m)\left(- \frac{2}{3}\right)g$$ and solve it to find the required tension.