Two things:
During the final room of the first Gym, the second step of both the regular combination and secret combination are Red, Blue, and Green (Variable 0334: Poison Mix = 8). This means that if you enter in the secret combo first and open the door, any time to try and open the normal path the second combination assumes you are attempting the secret code (as Switch 0777: SecretPoison is on).
During the fight with Geara in the basement of the Forsaken Laboratory; I had a Cacturne use Sucker Punch against his Treevenant as it was using Phantom Force. This combination caused a few errors to pop up just from this attempt
After these errors showed, my Cacturne could no longer attack (attempting caused the errors again). After my other Pokemon out besides Cacturne was defeated, I was not given an option to send in a replacement. Replacing my Cacturne with something else fixed this issue and allowed me to then replace the missing second pokemon.