When exiting drain mode, we check that we are in the proper state to complete our transition to primary after taking the global X lock. After that check, we release the repl coord mutex, write our on election oplog entry, reacquire the repl coord mutex, then complete our transition to primary.
In TopologyCoordinatorImpl::completeTransitionToPrimary, we invariant that we still are in in leaderElect mode or in a stepdown attempt. We can also, however, be the leader mode for an unconditional stepdown, as we might have heard of a higher term while we had the repl coord mutex unlocked. In this case the proper thing to do is complete our transition to primary (since we've already logged the transition to primary oplog entry), then immediately step down.