I think the condition should read:
(shouldInvokeRemoteTxCommand || prepareSent) && !isOnePhaseCommit