Repository: twentyhq/twenty
File: packages/twenty-front/src/modules/workflow/workflow-steps/workflow-actions/find-records-action/components/WorkflowEditActionFindRecords.tsx (TypeScript)

Code before:
          Icon: getIcon(objectMetadataItem.icon),
          label: objectMetadataItem.labelPlural,
          value: objectMetadataItem.nameSingular,
        })),
    [objectMetadataItems, getIcon],
  );

  const activeSystemObjectOptions = useMemo(
    () =>
      objectMetadataItems
        .filter(
          (objectMetadataItem) =>
            objectMetadataItem.isActive && objectMetadataItem.isSystem,
        )
        .map((objectMetadataItem) => ({
          Icon: getIcon(objectMetadataItem.icon),
          label: objectMetadataItem.labelPlural,
          value: objectMetadataItem.nameSingular,
        })),
    [objectMetadataItems, getIcon],
  );

  const selectedOption =
    [...activeStandardObjectOptions, ...activeSystemObjectOptions].find(
      (option) => option.value === action.settings.input.objectName,
    ) || DEFAULT_SELECTED_OPTION;

  const filteredStandardObjectOptions = useMemo(
    () =>
      activeStandardObjectOptions.filter((option) =>
        option.label.toLowerCase().includes(searchInputValue.toLowerCase()),
      ),
    [activeStandardObjectOptions, searchInputValue],
  );

  const filteredSystemObjectOptions = useMemo(
    () =>
      activeSystemObjectOptions.filter((option) =>
        option.label.toLowerCase().includes(searchInputValue.toLowerCase()),
      ),
    [activeSystemObjectOptions, searchInputValue],
  );

  const [formData, setFormData] = useState<FindRecordsFormData>(() => ({
    objectNameSingular: action.settings.input.objectName,
    limit:
      isNumber(action.settings.input.limit) &&
      action.settings.input.limit > QUERY_MAX_RECORDS
        ? QUERY_MAX_RECORDS
        : (action.settings.input.limit ?? 1),
    filter: action.settings.input.filter as FindRecordsActionFilter,

Review comment (performance):
The `selectedOption` is computed on every render without memoization, which could cause unnecessary re-renders when passed to `SelectControl`. Consider wrapping this in `useMemo` for better performance:

```typescript
const selectedOption = useMemo(
  () =>
    [...activeStandardObjectOptions, ...activeSystemObjectOptions].find(
      (option) => option.value === action.settings.input.objectName,
    ) || DEFAULT_SELECTED_OPTION,
  [activeStandardObjectOptions, activeSystemObjectOptions, action.settings.input.objectName],
);
```
```suggestion
  const selectedOption = useMemo(
    () =>
      [...activeStandardObjectOptions, ...activeSystemObjectOptions].find(
        (option) => option.value === action.settings.input.objectName,
      ) || DEFAULT_SELECTED_OPTION,
    [activeStandardObjectOptions, activeSystemObjectOptions, action.settings.input.objectName],
  );
```

Code after:
  const instanceId = `workflow-edit-action-record-find-records-${action.id}-${formData.objectNameSingular}`;

  const selectedObjectMetadataItem = objectMetadataItems.find(
    (item) => item.nameSingular === formData.objectNameSingular,
  );
  const { getIcon } = useIcons();

  const selectedOption = selectedObjectMetadataItem
    ? {
        Icon: getIcon(selectedObjectMetadataItem?.icon),
        label: selectedObjectMetadataItem?.labelPlural,
        value: selectedObjectMetadataItem?.nameSingular,
      }
    : DEFAULT_SELECTED_OPTION;

  const { objectPermissionsByObjectMetadataId } = useObjectPermissions();

  const {
    fieldDefinitionByFieldMetadataItemId,
    fieldMetadataItemByFieldMetadataItemId,
    labelIdentifierFieldMetadataItem,
    recordFieldByFieldMetadataItemId,
  } = useRecordIndexFieldMetadataDerivedStates(
    selectedObjectMetadataItem,
    instanceId,
  );

  const saveAction = useDebouncedCallback(
    async (formData: FindRecordsFormData) => {
      if (actionOptions.readonly === true) {
        return;
      }

      const {
        objectNameSingular: updatedObjectName,
        limit: updatedLimit,
        filter: updatedFilter,
        orderBy: updatedOrderBy,
      } = formData;

      actionOptions.onActionUpdate({
        ...action,
        settings: {
          ...action.settings,
          input: {
            objectName: updatedObjectName,
            limit: updatedLimit ?? 1,
            filter: updatedFilter,
            orderBy: updatedOrderBy as Record<string, any[]> | undefined,
          },
        },