How to make a state that doesn't allow the whole party to escape?

I want to make a state where, if even ONE of the party members is inflicted, the whole party can't leave the battle.

I was trying to look it up, and research a little, but there isn't a clear way to do so as far as I can tell.

Does anyone know how I could do this?
Are you just using the default Fight/Escape commands before each round of battle? Copy the below code, paste it into a text editor and include it as a plugin. Replace the indicated X with the ID of your state, no leading zeros.

Code:
BattleManager.processEscape = function() {
    $gameParty.performEscape();
    SoundManager.playEscape();
    var success = this._preemptive ? true : (Math.random() < this._escapeRatio);
// Replace X in the next line
    if ($gameParty.aliveMembers().some(actor => actor.isStateAffected(X)))
        success=false;
    if (success) {
        this.displayEscapeSuccessMessage();
        this._escaped = true;
        this.processAbort();
    } else {
        this.displayEscapeFailureMessage();
        this._escapeRatio += 0.1;
        $gameParty.clearActions();
        this.startTurn();
    }
    return success;
};
Are you just using the default Fight/Escape commands before each round of battle? Copy the below code, paste it into a text editor and include it as a plugin. Replace the indicated X with the ID of your state, no leading zeros.

Code:
BattleManager.processEscape = function() {
    $gameParty.performEscape();
    SoundManager.playEscape();
    var success = this._preemptive ? true : (Math.random() < this._escapeRatio);
// Replace X in the next line
    if ($gameParty.aliveMembers().some(actor => actor.isStateAffected(X)))
        success=false;
    if (success) {
        this.displayEscapeSuccessMessage();
        this._escaped = true;
        this.processAbort();
    } else {
        this.displayEscapeFailureMessage();
        this._escapeRatio += 0.1;
        $gameParty.clearActions();
        this.startTurn();
    }
    return success;
};

Thank you!
By any chance, is there a way to include multiple states?

Like, if the actor is affected by X,Y, or Z state?
Code:
BattleManager.processEscape = function() {
    $gameParty.performEscape();
    SoundManager.playEscape();
    var success = this._preemptive ? true : (Math.random() < this._escapeRatio);
// List IDs in the next line
    [X, Y, Z].forEach(state => success=$gameParty.aliveMembers().some(actor => actor.isStateAffected(state)) ? false : success);
    if (success) {
        this.displayEscapeSuccessMessage();
        this._escaped = true;
        this.processAbort();
    } else {
        this.displayEscapeFailureMessage();
        this._escapeRatio += 0.1;
        $gameParty.clearActions();
        this.startTurn();
    }
    return success;
};

Replace X Y Z with the IDs of the states, list however many you like, separated by commas.

Original thread: https://forums.rpgmakerweb.com/threads/how-to-make-a-state-that-doesnt-allow-the-whole-party-to-escape.155797/