function convertLegacyPhraseToNewShape(legacyPhrase) {
  const {desc} = legacyPhrase;
  const hashToText = legacyPhrase[HASH_TO_TEXT];
  if (desc == null && hashToText == null) {
    return legacyPhrase;
  }

  const hashToLeaf = {};
  for (const hash in hashToText) {
    hashToLeaf[hash] = {
      text: hashToText[hash],
      desc,
    };
  }
  legacyPhrase[HASH_TO_LEAF] = hashToLeaf;

  if (typeof legacyPhrase.jsfbt === 'string') {
    legacyPhrase.jsfbt = {
      t: {
        text: legacyPhrase.jsfbt,
        desc,
      },
      m: [],
    };
  }

  delete legacyPhrase.desc;
  delete legacyPhrase.type;
  return legacyPhrase;
}
If the phrase is in legacy format, this function converts it to the new
phrase format:
 1. Replace `hashToText` with `hashToLeaf`
 2. Replace plain text `jsfbt` with `{t: {text: ..., desc: ....}, m: []}`
 3. Remove `desc` and `type`