diff --git a/packages/desktop-client/src/components/modals/SelectLinkedAccountsModal.jsx b/packages/desktop-client/src/components/modals/SelectLinkedAccountsModal.jsx index b5730e0cc3..e29a4104e3 100644 --- a/packages/desktop-client/src/components/modals/SelectLinkedAccountsModal.jsx +++ b/packages/desktop-client/src/components/modals/SelectLinkedAccountsModal.jsx @@ -43,10 +43,10 @@ export function SelectLinkedAccountsModal({ syncSource = undefined, }) { const sortedExternalAccounts = useMemo(() => { - const toSort = [...externalAccounts]; + const toSort = externalAccounts ? [...externalAccounts] : []; toSort.sort( (a, b) => - a.institution?.localeCompare(b.institution) || + getInstitutionName(a)?.localeCompare(getInstitutionName(b)) || a.name.localeCompare(b.name), ); return toSort; @@ -234,6 +234,15 @@ export function SelectLinkedAccountsModal({ ); } +function getInstitutionName(externalAccount) { + if (typeof externalAccount?.institution === 'string') { + return externalAccount?.institution ?? ''; + } else if (typeof externalAccount.institution?.name === 'string') { + return externalAccount?.institution?.name ?? ''; + } + return ''; +} + function TableRow({ externalAccount, chosenAccount, @@ -254,7 +263,7 @@ function TableRow({ return ( - + - {externalAccount.institution} + {getInstitutionName(externalAccount)} diff --git a/upcoming-release-notes/4667.md b/upcoming-release-notes/4667.md new file mode 100644 index 0000000000..d925ace954 --- /dev/null +++ b/upcoming-release-notes/4667.md @@ -0,0 +1,6 @@ +--- +category: Bugfix +authors: [alecbakholdin] +--- + +Fixed bug where GoCardless doesn't work for SelectLinkedAccounts due to different institution structure