diff --git a/packages/server/src/db/linkedRows/index.ts b/packages/server/src/db/linkedRows/index.ts index 037e53d02f..2da7e212b9 100644 --- a/packages/server/src/db/linkedRows/index.ts +++ b/packages/server/src/db/linkedRows/index.ts @@ -229,12 +229,12 @@ function getPrimaryDisplayValue(row: Row, table?: Table) { invalid = INVALID_DISPLAY_COLUMN_TYPE.includes(primaryDisplaySchema.type) } if (invalid || !primaryDisplay) { - const validKey = Object.keys(table?.schema || {}).filter( + const validKey = Object.keys(table?.schema || {}).find( key => table?.schema[key].type && !INVALID_DISPLAY_COLUMN_TYPE.includes(table?.schema[key].type) ) - return validKey[0] ? row[validKey[0]] : undefined + return validKey ? row[validKey] : undefined } else { return row[primaryDisplay] }