What is the proper way to write conditional statement inside flatMap with Promise.all in Javascript

I am working on a FlatMap with Promise.all, however, I don’t know how to do when conditional statement inside flatMap.

function async foo(){
  const eventPromises = events.flatMap(async (event) => {
      if (event.state.matchPhase == "1H") {
        // simpleQuery is async function
        const originalObj = await simpleQuery({ id: event.id });
        if (originalObj.state == false) {
          // insertRealStartTime is async function
          await insertRealStartTime(event.id);
        }
      }
      // Event.updateMany is async function
      await Events.updateMany(
        { ...event, expireAt: event["startTime"] },
      );
    }
  );
  const all = await Promise.all(eventPromises);
  console.log(all)
}

I got an array of undefined in console.log(all); I think I probably shouldn’t use await inside flatMap because it lost the meaning of using Promise.all; however, how should I deal with all these if-statement to make sure the async function will execute base on the if-statement with Promise.all?