Using a relationships entry title as a repeatable components entry title

Using @mcnaveen solution but adding a "0" between nestedObjectField and nestedObjectTitle seems to kind of work for me on 4.5.6. Seems like the nested object is an array nowadays :smile:

However, it looks like I have to open the accordion before the title gets loaded :thinking:

import { useMemo } from 'react';
import { get, toString } from 'lodash';
import { useCMEditViewDataManager } from '@strapi/helper-plugin';

function useSelect({ schema, componentFieldName }) {
  const {
    checkFormErrors,
    modifiedData,
    moveComponentField,
    removeRepeatableField,
    triggerFormValidation,
  } = useCMEditViewDataManager();

  const mainField = useMemo(() => get(schema, ['settings', 'mainField'], 'id'), [schema]);
  const nestedObjectTitle = schema.layouts.edit?.[0]?.[0]?.metadatas?.mainField?.name;
  const nestedObjectField = schema.layouts.edit?.[0]?.[0]?.name;
  const displayValuePath = (mainField === 'id' && !!nestedObjectTitle)
  ? [...componentFieldName.split('.'), nestedObjectField, "0", nestedObjectTitle]
  : [...componentFieldName.split('.'), mainField];

  const displayedValue = toString(
    get(modifiedData, displayValuePath, '')
  );

  return {
    displayedValue,
    mainField,
    checkFormErrors,
    moveComponentField,
    removeRepeatableField,
    schema,
    triggerFormValidation,
  };
}

export default useSelect;