Remove non battling actors from party in MV?

I'm using yanfly's party system plugin. If the player selects 3 characters for the battle, how do I remove non selected characters from the party? (Change party cannot work here since it is up to the player to know which character they want to pick). Is there any other way to achieve that through events or scripts? Is there a script call that can identify actors not participating in the battle?

EDIT: Found the solution here

$gameParty.removeActor($gameParty.members()[4].actorId())

if you're using 4 battlers, this script will remove the fifth actor who is in the party and who is not fighting.

Original thread: https://forums.rpgmakerweb.com/threads/remove-non-battling-actors-from-party-in-mv.95109/