function extractEnumsAndFlattenPhrases(
  phrases: $ReadOnlyArray<Phrase>,
): Array<Phrase> {
  return _flatMap<Phrase, Phrase>(phrases, phrase => {
    const {jsfbt} = phrase;
    const {enums, metadata} = _extractEnumsFromMetadata(jsfbt.m);
    return _buildTablesWithoutEnums(jsfbt.t, enums, []).map(table => {
      // $FlowFixMe[incompatible-indexer]
      // $FlowFixMe[incompatible-variance]
      // $FlowFixMe[incompatible-call]
      const leaf = coerceToTableJSFBTTreeLeaf(table);
      invariant(
        (metadata.length === 0) === (leaf != null),
        'If the JSFBT table depth is 1, then the metadata array should be empty; ' +
          'otherwise, when the depth is greater than 1, the metadata array should not be empty. Metadata length: %s, ',
        metadata.length,
      );
      return {
        ...phrase,
        jsfbt: {
          t: table,
          m: metadata,
        },
      };
    });
  });
}
Used by collectFbt to output multiple phrases in a flat array.
See FbtShiftEnumsTest for example input and output.