Filter one array based on values of another, is this the best way?
Normally there are a lot of categories, so I'd go through the voucher.categories array:

const filterCategories = (voucher, categories) =&gt; (
  Array.isArray(voucher.categories) ?
    voucher.categories
      .map(categoryId =&gt; {
        const categoryFound = categories.find(c =&gt; c.id === categoryId);
        return categoryFound ? categoryFound.name : null;
      })
      .filter(categoryName =&gt; categoryName !== null)
      .sort()
      .join() :
    ""
);


This way you don't have to go through the entire list of 'master' categories (which in practice may be very long) doing a search on the voucher categories in each iteration.

Note: it would be much faster if you could have the categories as an object with the id as index:

categories = {
  ["761601bc-4daf-4db2-a0cf-fe7f443fcb94"]: {name: "Shoes"},
  ["601ebcfe-fcbd-4075-a4b4-a42e356c5747"]: {name: "Hats"},
  ["238933cf-77a5-4443-b290-7d7c836f80ff"]: {name: "Eyewear"}
};

const filterCategories = (voucher, categories) =&gt; (
      Array.isArray(voucher.categories) ?
        voucher.categories
          .map(categoryId =&gt; {
            const categoryFound = categories[categoryId];
            return categoryFound ? categoryFound.name : null;
          })
          .filter(categoryName =&gt; categoryName !== null)
          .sort()
          .join() :
        ""
    );