\[3a + b - 3a^{3} + ab =\]
\[= 3a\left( 1 - a^{2} \right) + b(1 + a) =\]
\[= (1 + a)\left( 3a - 3a^{2} + b \right)\]