message: Minor cleanups to item creation
diff: @@ -8,6 +8,7 @@ import {
  uniqueEquipBuckets,
  } from 'app/search/d2-known-values';
  import { lightStats } from 'app/search/search-filter-values';
  +import { emptyArray, emptyObject } from 'app/utils/empty';
  import { errorLog, warnLog } from 'app/utils/log';
  import { countEnhancedPerks } from 'app/utils/socket-utils';
  import {
  @@ -21,6 +22,7 @@ import {
  DestinyItemInstanceComponent,
  DestinyItemResponse,
  DestinyItemSubType,
  + DestinyItemTooltipNotification,
  DestinyItemType,
  DestinyObjectiveProgress,
  DestinyProfileRecordsComponent,
  @@ -257,8 +259,9 @@ export function makeItem(
  ): DimItem | null {
  const itemDef = defs.InventoryItem.get(item.itemHash);
  - const itemInstanceData: Partial<DestinyItemInstanceComponent> =
  - itemComponents?.instances.data?.[item.itemInstanceId ?? ''] ?? {};
  + const itemInstanceData: Partial<DestinyItemInstanceComponent> = item.itemInstanceId
  + ? itemComponents?.instances.data?.[item.itemInstanceId ?? ''] ?? emptyObject()
  + : emptyObject();
  // Missing definition?
  if (!itemDef) {
  @@ -334,8 +337,8 @@ export function makeItem(
  const itemType = normalBucket.type || 'Unknown';
  const isEngram =
  - itemDef.itemCategoryHashes?.includes(ItemCategoryHashes.Engrams) ||
  normalBucket.hash === BucketHashes.Engrams ||
  + itemDef.itemCategoryHashes?.includes(ItemCategoryHashes.Engrams) ||
  false;
  // https://github.com/Bungie-net/api/issues/134, class items had a primary stat
  @@ -395,13 +398,14 @@ export function makeItem(
  const hiddenOverlay = itemDef.iconWatermark;
  - const tooltipNotifications = (item.tooltipNotificationIndexes ?? [])
  + const tooltipNotifications = item.tooltipNotificationIndexes?.length
  + ? item.tooltipNotificationIndexes
  // why the optional chain? well, somehow, an item can return tooltipNotificationIndexes,
  // but have no tooltipNotifications in its def
  .map((i) => itemDef.tooltipNotifications?.[i])
  - .filter(Boolean)
  // a temporary filter because as of witch queen, all tooltips are set to "on"
  - .filter((t) => t && t.displayStyle !== 'ui_display_style_info');
  + .filter((t) => t && t.displayStyle !== 'ui_display_style_info')
  + : emptyArray<DestinyItemTooltipNotification>();
  // null out falsy values like a blank string for a url
  const iconOverlay =
  @@ -466,7 +470,7 @@ export function makeItem(
  hash: item.itemHash,
  // This is the type of the item (see DimCategory/DimBuckets) regardless of location
  type: itemType,
  - itemCategoryHashes: itemDef.itemCategoryHashes || [], // see defs.ItemCategory
  + itemCategoryHashes: itemDef.itemCategoryHashes || emptyArray(), // see defs.ItemCategory
  tier: D2ItemTiers[itemDef.inventory!.tierType] || 'Common',
  isExotic: D2ItemTiers[itemDef.inventory!.tierType] === 'Exotic',
  name,
  @@ -676,10 +680,10 @@ export function makeItem(
  // Secondary Icon
  if (createdItem.sockets) {
  - const multiEmblem = createdItem.sockets.allSockets.filter(
  + const multiEmblem = createdItem.sockets.allSockets.find(
  (socket) => socket.plugged?.plugDef.itemType === DestinyItemType.Emblem
  );
  - const selectedEmblem = multiEmblem[0]?.plugged;
  + const selectedEmblem = multiEmblem?.plugged;
  if (selectedEmblem) {
  createdItem.secondaryIcon = selectedEmblem.plugDef.secondaryIcon;
  