This invariant in ReplicationCoordinator::canAcceptWritesFor() may fail during an index rebuild started by a rollback using the refetch method. The two phase index build should be running with the RSTL acquired. However, we check for general two phase index build support, which is dependent on the current FCV, to determine if we need to keep the RSTL lock.
Since the server supports running a mix of two and single phased index builds concurrently, one possible solution for the RSTL may be to use the index build method provided by the caller.