This need not be in conflict with TMP. These may be two different situations - it depends on what was meant by “the mains.” In TMP, the phasers were automatically cut off as a safety measure because of the engines imbalance in order to avoid a catastrophic failure.
In TWOK, for all we know there was nothing wrong with the warp engines per se, only with the power source to the warp drive. The phasers could still be channeled through the warp drive with no issues - they just wouldn’t have the added “punch” they would normally get from the warp engines because there was no power going to them.
Think of it like a hybrid car that depletes its battery and has to rely on its small motor for power.
Failures of the power systems, though relatively infrequent, are seen to occur numerous times theoughout the various films and episodes and we’re likely anticipated to sine deree as a result of battle, attack, stress and wear and tear. Designing a primary offensive system in such a way that it would become inoperative during these conditions - and arguably the conditions where offensive systems are most required - is orders of magnitudes more shortsighted than a safety cutoff from engine imbalance which is so rare that IIRC we only see that one time. We might be able to infer that, much like with tires/tyres “balancing” the warp engine only needs to be done one time for new warp nacelle. This is a very different case, and I can see how it could be decided that non-operation of phasers in this condition would be deemed acceptable as balancing would probably be handled by system testing well before the ship goes back into service. In TMP, Scotty seemed to think the engine balancing could have been handled with more time (his assertions that they needed 20 hours for launch likely accounted for that. I don’t think Scotty doubted that Kirk would want warp drive - he just didn’t expect it to be needed until after they cleared the solar system.
My inner nerd is running a bit wild here but here goes -
What would happen if phasers were fired within the gravimetric and temporal distortions of the wormhole created by warp engine imbalance ? A physical object like a torpedo might take an altered route or have disrupted timing as it rode these distortion waves and be able to have its self destruct activated if requred, But what might occur to a beam of coherent energy and what if it was deflected back towards an unshielded ship by the distortion effects of the wormhole ?
We saw something like this occur in TNG to a phaser beam fired within a nebula so the phaser cut off might be a safety feature to deal with this.