(Needless to say, this post contains spoilers for the final fight of the game.)

During the second phase of the final fight, Heroes come to aid you against X∞ and Y∞. The Heroes you get might seem totally random, but in reality there is an elaborated system behind it.

Let's start with some rules:

  • Nia, Melia, DLC, and unused/unreleased Heroes do not appear.
    • Technically, Manana doesn't appear either, but will spawn alongside Riku (see below for what this implies)
  • Heroes you haven't completed the Hero Quest for do not appear, except Monica. (see below)
    • On NG+, you just need the Hero to be fully unlocked.
  • Ethel only appears if you have completed Cammuravi's ascension quest in the current playthrough.
  • The hero that's currently in your party does not appear.
  • Heroes that appear retain the level they have in the roster, but no lower than 72.
  • When counting party members, Riku and Manana are considered separate characters. (see below)

As a side note, in the X∞ and Y∞ fights the hero you have in your party will choose the side representing their faction. This is not the case for Ino and Segiri, who will always join the X∞ team. Furthermore, Riku/Manana, Monica, Triton, Ghondor, and Gray don't follow this, instead choosing the side with the least members of their role (essentially the side with the least Tanks for Monica, and least Attackers for everyone else), choosing randomly if tied.

When heroes are to be picked (both parties are chosen at the start of the X∞ fight), they are divided into two groups, based on whether or not you have completed their ascension quest in the current playthrough. (Ethel is always in this group.)

Now, the game picks heroes for each party, starting from the X∞ one, and alternating between the two. (From now on, "party" refers to the split group in each fight, including previously summoned heroes.)
First, it counts the party members for each role. It searches for the role with the least members, following this order in case of a tie: Healer > Tank > Attacker. Then, it tries to get a random Hero with that role in the "ascended" group. If it can't find one, it repeats the process with the other hero group.

Now, if the party has no tanks, no tank Heroes could be found, and Monica is not the global party's Hero, Monica will appear, even if you haven't completed her quest yet. (Note that if you have completed her quest, she is not guaranteed because she can be found among the other heroes in the pool.)

If Riku is chosen, Manana will be guaranteed to win the next round, essentially making it so the other party gets to pick twice.

If there are no available heroes for the role, the game repeats the process for the next role with the fewest members, following the same order in case of a tie: Healer > Tank > Attacker.

If no heroes could be found, the process stops. The process also stops after 6 heroes have been picked per party. Additionally, Riku cannot be picked as the 6th member (because he'd also bring Manana). If he was the only eligible hero during that round, the party is left with 5 heroes instead. Similarly, if Riku is picked as the 5th member, the 6th round will be skipped.