Break from while loops after specific time

OK. Then it is probably something like this if you simply want to carry on following a timeout. Assuming the timeout is the same for each while loop:

bool initiateSession() {
  const uint32_t timeoutMs = 4000 ;
  uint32_t startAtMs  ;

  startAtMs = millis()
  while ( <condition1 not met> ) {
    if ( millis() - startAtMs > timeoutMs ) break ;
    /*
        do activity 1 here
    */
  }

  startAtMs = millis()
  while ( <condition2 not met> ) {
    if ( millis() - startAtMs > timeoutMs ) break ;
    /*
        do activity 2 here
    */
  }
  
  return true ;  // OK
}