is.checkBreakouts({ breakouts: [] });
  }

  componentDidUpdate(oldProps) {
    this.checkBreakouts(oldProps);
  }

  checkBreakouts(oldProps) {
    const {
      breakouts,
      mountModal,
      currentBreakoutUser,
      getBreakoutByUser,
      breakoutUserIsIn,
      amIModerator,
    } = this.props;

    const {
      didSendBreakoutInvite,
    } = this.state;

    const hadBreakouts = oldProps.breakouts.length > 0;
    const hasBreakouts = breakouts.length > 0;
    if (!hasBreakouts && hadBreakouts) {
      closeBreakoutJoinConfirmation(mountModal);
    }

    if (hasBreakouts && !breakoutUserIsIn && !amIModerator) {
      // Have to check for freeJoin breakouts first because currentBreakoutUser will
      // populate after a room has been joined
      const breakoutRoom = getBreakoutByUser(currentBreakoutUser);
      const freeJoinBreakout = breakouts.find(breakout => breakout.freeJoin);
      if (freeJoinBreakout) {
        if (!didSendBreakoutInvite) {
          this.inviteUserToBreakout(breakoutRoom || freeJoinBreakout);
          this.setState({ didSendBreakoutInvite: true });
        }
      } else if (currentBreakoutUser) {
        const currentInsertedTime = currentBreakoutUser.insertedTime;
        const oldCurrentUser = oldProps.currentBreakoutUser || {};
        const oldInsertedTime = oldCurrentUser.insertedTime;
        if (currentInsertedTime !== oldInsertedTime) {
          const breakoutId = Session.get('lastBreakoutOpened');
          if (breakoutRoom.breakoutId !== breakoutId) {
            this.inviteUserToBreakout(breakoutRoom);
          }
        }
      }
    }

    if (!hasBreakouts && didSendBreakoutInvite) {
      this.setState({ didSendBreakoutInvite: false });
    }
  }

  inviteUserToBreakout(breakout) {
    const {
      mountModal,
    } = this.props;
    // There's a race condition on page load with modals. Only one modal can be shown at a
    // time and new ones overwrite old ones. We delay the opening of the breakout modal
    // because it should always be on top if bre