function filterCategoriesByGatherMode(categories, mode) {
  if (!categories) return null;

  const categoriesToKeep = Object.entries(categories)
    .filter(([_, category]) => {
      return !category.supportedModes || category.supportedModes.includes(mode);
    });
  return Object.fromEntries(categoriesToKeep);
}
Optional `supportedModes` property can explicitly exclude a category even if some audits are available.

@param {LH.Config.ResolvedConfig['categories']} categories
@param {LH.Gatherer.GatherMode} mode
@return {LH.Config.ResolvedConfig['categories']}