diff --git a/packages/react-components/src/util/checkVisibility.tsx b/packages/react-components/src/util/checkVisibility.tsx index c29c1f81ce..3d804b7ae2 100644 --- a/packages/react-components/src/util/checkVisibility.tsx +++ b/packages/react-components/src/util/checkVisibility.tsx @@ -14,13 +14,16 @@ export function checkVisibility (api: ApiPromise, address: string, accountInfo: if (filterLower || onlyNamed) { if (accountInfo) { const { accountId, accountIndex, identity, nickname } = accountInfo; + const hasAddressMatch = (!!accountId && accountId.toString().includes(filterName)) || (!!accountIndex && accountIndex.toString().includes(filterName)); - if (!onlyNamed && (accountId?.toString().includes(filterName) || accountIndex?.toString().includes(filterName))) { + if (!onlyNamed && hasAddressMatch) { isVisible = true; } else if (isFunction(api.query.identity?.identityOf)) { - isVisible = - (!!identity?.display && identity.display.toLowerCase().includes(filterLower)) || - (!!identity?.displayParent && identity.displayParent.toLowerCase().includes(filterLower)); + isVisible = !!identity && (!!identity.display || !!identity.displayParent) && ( + hasAddressMatch || + (!!identity.display && identity.display.toLowerCase().includes(filterLower)) || + (!!identity.displayParent && identity.displayParent.toLowerCase().includes(filterLower)) + ); } else if (nickname) { isVisible = nickname.toLowerCase().includes(filterLower); }