Repository: twentyhq/twenty
File: packages/twenty-front/src/modules/views/utils/convertCoreViewToView.ts (TypeScript)

Code before:
    coreView.openRecordIn,
  );
  const convertedType = convertCoreViewTypeToViewType(coreView.type);

  return {
    id: coreView.id,
    name: coreView.name,
    type: convertedType,
    key: convertedKey,
    objectMetadataId: coreView.objectMetadataId,
    isCompact: coreView.isCompact,
    viewFields: coreView.viewFields.map((viewField) =>
      convertCoreViewFieldToViewField(viewField),
    ),
    viewGroups: coreView.viewGroups.map((viewGroup) =>
      convertCoreViewGroupToViewGroup(viewGroup),
    ),
    viewFilters: coreView.viewFilters.map((viewFilter) =>
      convertCoreViewFilterToViewFilter(viewFilter),
    ),
    viewFilterGroups: coreView.viewFilterGroups?.map(
      convertCoreViewFilterGroupToViewFilterGroup,
    ),
    viewSorts: coreView.viewSorts,
    mainGroupByFieldMetadataId: coreView.mainGroupByFieldMetadataId ?? null,
    shouldHideEmptyGroups: coreView.shouldHideEmptyGroups ?? false,
    kanbanAggregateOperation: coreView.kanbanAggregateOperation ?? null,
    kanbanAggregateOperationFieldMetadataId:
      coreView.kanbanAggregateOperationFieldMetadataId ?? null,
    calendarFieldMetadataId: coreView.calendarFieldMetadataId ?? null,
    calendarLayout: coreView.calendarLayout ?? null,
    position: coreView.position,
    icon: coreView.icon,
    openRecordIn: convertedOpenRecordIn,
    anyFieldFilterValue: coreView.anyFieldFilterValue ?? null,
    visibility: coreView.visibility ?? ViewVisibility.UNLISTED,
    createdByUserWorkspaceId: coreView.createdByUserWorkspaceId,
    __typename: 'View',
  };
};


Review comment (suggestion):
coreView.shouldHideEmptyGroups is never undefined in my understanding

Code after:
    coreView.openRecordIn,
  );
  const convertedType = convertCoreViewTypeToViewType(coreView.type);

  return {
    id: coreView.id,
    name: coreView.name,
    type: convertedType,
    key: convertedKey,
    objectMetadataId: coreView.objectMetadataId,
    isCompact: coreView.isCompact,
    viewFields: coreView.viewFields.map((viewField) =>
      convertCoreViewFieldToViewField(viewField),
    ),
    viewGroups: coreView.viewGroups.map((viewGroup) =>
      convertCoreViewGroupToViewGroup(viewGroup),
    ),
    viewFilters: coreView.viewFilters.map((viewFilter) =>
      convertCoreViewFilterToViewFilter(viewFilter),
    ),
    viewFilterGroups: coreView.viewFilterGroups?.map(
      convertCoreViewFilterGroupToViewFilterGroup,
    ),
    viewSorts: coreView.viewSorts,
    mainGroupByFieldMetadataId: coreView.mainGroupByFieldMetadataId ?? null,
    shouldHideEmptyGroups: coreView.shouldHideEmptyGroups,
    kanbanAggregateOperation: coreView.kanbanAggregateOperation ?? null,
    kanbanAggregateOperationFieldMetadataId:
      coreView.kanbanAggregateOperationFieldMetadataId ?? null,
    calendarFieldMetadataId: coreView.calendarFieldMetadataId ?? null,
    calendarLayout: coreView.calendarLayout ?? null,
    position: coreView.position,
    icon: coreView.icon,
    openRecordIn: convertedOpenRecordIn,
    anyFieldFilterValue: coreView.anyFieldFilterValue ?? null,
    visibility: coreView.visibility ?? ViewVisibility.UNLISTED,
    createdByUserWorkspaceId: coreView.createdByUserWorkspaceId,
    __typename: 'View',
  };
};