function categorizeStringsInPhrase(
  newPhrase,
  legacyPhraseMaybeInLegacyShape,
  newStringByCategory,
) /*: void */ {
  const legacyPhrase = convertLegacyPhraseToNewShape(
    legacyPhraseMaybeInLegacyShape,
  );
  const legacyLeaves = legacyPhrase[HASH_TO_LEAF];
  const newLeaves = newPhrase[HASH_TO_LEAF];
  if (areNewAndLegacyLeavesIdentical(newLeaves, legacyLeaves)) {
    const commonResult = {
      project: newPhrase.project,
      filepath: newPhrase.filepath,
      lineBeg: newPhrase.line_beg,
      lineEnd: newPhrase.line_end,
      hashKey: newPhrase.hash_key,
      legacyHashKey: legacyPhrase.hash_key,
    };
    if (
      newPhrase.hash_key !== legacyPhrase.hash_key &&
      shouldReturnPhraseWithNewHashKey
    ) {
      for (const [hash, {desc, text}] of Object.entries(newLeaves)) {
        newStringByCategory[CATEGORY.SAME_HASH_BUT_UPDATED_HASH_KEY][hash] = {
          ...commonResult,
          legacyHash: hash,
          text,
          legacyText: text,
          desc,
          legacyDesc: desc,
        };
      }
      return;
    }
    const {m: mNew} = newPhrase.jsfbt;
    const {m: mOld} = legacyPhrase.jsfbt;
    if (mNew.length > mOld.length) {
      for (const [hash, {desc, text}] of Object.entries(newLeaves)) {
        newStringByCategory[
          CATEGORY.SAME_HASH_BUT_ADDITIONAL_IMPLICIT_VARIATIONS
        ][hash] = {
          legacyHash: hash,
          text,
          legacyText: text,
          desc,
          legacyDesc: desc,
          legacyM: JSON.stringify(mOld),
          m: JSON.stringify(mNew),
          ...commonResult,
        };
      }
    }
    return;
  }
  // Categorize each leaf(which is potentially upgraded) in the new phrase
  const legacyTexts = Object.values(legacyLeaves).map(({text}) => text);
  Object.entries(newLeaves).map(newLeaf => {
    if (legacyTexts.includes(newLeaf[1].text)) {
      categorizeLeafWithUnchangedText(
        newLeaf,
        legacyLeaves,
        newStringByCategory,
        newPhrase,
        legacyPhrase,
      );
      return;
    }
    categorizeLeafWithUpdatedText(
      newLeaf,
      legacyLeaves,
      newStringByCategory,
      newPhrase,
      legacyPhrase,
    );
  });
}
Compare a phrase with its legacy phrase and categorize every new string