SERVER-76486 added a new implementation of refineCollectionShardKey that resumes migrations in the same phase of the release of the critical section. If there is a stepdown while trying to resume migrations, but the operation succeeds, then the balancer might start sending _shardsvrMoveRange commands to shards while the coordinator is retrying the phase, which causes a race for the critical section, if the migration wins this race, then the refineCollectionShardKey will fail because it will try to release a critical section with a different reason.
We should set the allowMigrations flag in a different phase than the release of the critical section.