From d26339a34b00dfed645222217261cd9294c95ad3 Mon Sep 17 00:00:00 2001 From: Bernhard Owen Josephus Date: Sat, 11 Jul 2026 15:46:41 +0800 Subject: [PATCH 1/6] fix personal detail lingering --- src/libs/Parser.ts | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/libs/Parser.ts b/src/libs/Parser.ts index 0f00f2920c67..d201d5ce2e98 100644 --- a/src/libs/Parser.ts +++ b/src/libs/Parser.ts @@ -6,8 +6,6 @@ import Onyx from 'react-native-onyx'; import Log from './Log'; -const accountIDToNameMap: Record = {}; - let reportIDToNameMap: Record = {}; Onyx.connect({ key: ONYXKEYS.COLLECTION.REPORT, @@ -29,9 +27,12 @@ Onyx.connect({ }, }); +let accountIDToNameMap: Record = {}; Onyx.connect({ key: ONYXKEYS.PERSONAL_DETAILS_LIST, callback: (personalDetailsList) => { + // Clear the map so removed personal detail don’t linger + accountIDToNameMap = {}; for (const personalDetails of Object.values(personalDetailsList ?? {})) { if (!personalDetails) { continue; From cf303a2cf9ddba7d08e3d258ebd3ef59e43c5f88 Mon Sep 17 00:00:00 2001 From: Bernhard Owen Josephus Date: Sat, 11 Jul 2026 15:47:12 +0800 Subject: [PATCH 2/6] simplify --- src/libs/OptionsListUtils/index.ts | 14 +------------- 1 file changed, 1 insertion(+), 13 deletions(-) diff --git a/src/libs/OptionsListUtils/index.ts b/src/libs/OptionsListUtils/index.ts index 7a4985c91c24..18d82b5bb08f 100644 --- a/src/libs/OptionsListUtils/index.ts +++ b/src/libs/OptionsListUtils/index.ts @@ -19,7 +19,7 @@ import Navigation from '@libs/Navigation/Navigation'; import {getIsOffline} from '@libs/NetworkState'; import Parser from '@libs/Parser'; import type {OptionData as PersonalDetailOptionData} from '@libs/PersonalDetailOptionsListUtils/types'; -import {getLoginByAccountID, getPersonalDetailByEmail, getPersonalDetailsByIDs, getPersonalDetailsListByIDs, temporaryGetDisplayNameOrDefault} from '@libs/PersonalDetailsUtils'; +import {getLoginByAccountID, getPersonalDetailByEmail, getPersonalDetailsListByIDs, temporaryGetDisplayNameOrDefault} from '@libs/PersonalDetailsUtils'; import {addSMSDomainIfPhoneNumber, parsePhoneNumber} from '@libs/PhoneNumber'; import { canSendInvoiceFromWorkspace, @@ -580,12 +580,6 @@ function isSearchStringMatchUserDetails(personalDetail: PersonalDetails, searchV return isSearchStringMatch(searchValue.trim(), memberDetails.toLowerCase()); } -function hasHiddenDisplayNames(accountIDs: number[], translate: LocalizedTranslate) { - return getPersonalDetailsByIDs({accountIDs, currentUserAccountID: 0}).some( - (personalDetail) => !temporaryGetDisplayNameOrDefault({passedPersonalDetails: personalDetail, shouldFallbackToHidden: false, translate}), - ); -} - function getLatestVisibleMoneyRequestAction( reportID: string, canUserPerformWrite: boolean | undefined, @@ -1019,12 +1013,6 @@ function getLastMessageTextForReport({ return lastMessageTextFromReport || (getReportLastMessage(reportID, isReportArchived, undefined).lastMessageText ?? ''); } - // When the last report action has unknown mentions (@Hidden), we want to consistently show @Hidden in LHN and report screen - // so we reconstruct the last message text of the report from the last report action. - if (!lastMessageTextFromReport && lastReportAction && hasHiddenDisplayNames(getMentionedAccountIDsFromAction(lastReportAction), translate)) { - lastMessageTextFromReport = Parser.htmlToText(getReportActionHtml(lastReportAction)); - } - // If the last report action is a pending moderation action, get the last message text from the last visible report action if (reportID && !lastMessageTextFromReport && isPendingRemove(lastOriginalReportAction)) { lastMessageTextFromReport = getReportActionMessageText(lastReportAction); From f06c0c2134da27aa7b408cca38049af5f1193e36 Mon Sep 17 00:00:00 2001 From: Bernhard Owen Josephus Date: Sat, 11 Jul 2026 15:51:53 +0800 Subject: [PATCH 3/6] add test --- tests/unit/OptionsListUtilsTest.tsx | 50 +++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) diff --git a/tests/unit/OptionsListUtilsTest.tsx b/tests/unit/OptionsListUtilsTest.tsx index a2baea1f76ca..144a0562eae8 100644 --- a/tests/unit/OptionsListUtilsTest.tsx +++ b/tests/unit/OptionsListUtilsTest.tsx @@ -5517,6 +5517,56 @@ describe('OptionsListUtils', () => { }); expect(result).toBe(expectedVisibleText); }); + it('should return "@Hidden" when last action is an ADD_COMMENT mentioning a user not in personal details', async () => { + // Given a chat report whose last action is an ADD_COMMENT that mentions a user who does not exist in personal details + const mentionedAccountID = 999999; + const report: Report = { + ...createRandomReport(0, undefined), + type: CONST.REPORT.TYPE.CHAT, + lastActionType: CONST.REPORT.ACTIONS.TYPE.ADD_COMMENT, + }; + const addCommentAction: ReportAction = { + ...createRandomReportAction(1), + actionName: CONST.REPORT.ACTIONS.TYPE.ADD_COMMENT, + created: DateUtils.getDBTime(), + message: [ + { + type: 'COMMENT', + html: ``, + text: '', + isEdited: false, + isDeletedParentAction: false, + whisperedTo: [], + }, + ], + originalMessage: { + html: ``, + mentionedAccountIDs: [mentionedAccountID], + }, + shouldShow: true, + pendingAction: null, + }; + await Onyx.merge(`${ONYXKEYS.COLLECTION.REPORT}${report.reportID}`, report); + await Onyx.merge(`${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${report.reportID}`, { + [addCommentAction.reportActionID]: addCommentAction, + }); + await waitForBatchedUpdates(); + + // When we get the last message text while the mentioned user is absent from personal details + const lastMessage = getLastMessageTextForReport({ + personalDetails: undefined, + translate: translateLocal, + report, + lastActorDetails: null, + policy: undefined, + isReportArchived: false, + lastAction: addCommentAction, + currentUserLogin: CURRENT_USER_EMAIL, + }); + + // Then the mention should fall back to the hidden placeholder + expect(lastMessage).toBe(`@${translateLocal('common.hidden')}`); + }); it('should return "No activity yet" for MoneyRequestReport with zero transactions', async () => { const report: Report = { ...createRandomReport(0, undefined), From 16c86b960c81c16081bc2ed56e028f0fd6b85963 Mon Sep 17 00:00:00 2001 From: Bernhard Owen Josephus Date: Sat, 11 Jul 2026 16:30:12 +0800 Subject: [PATCH 4/6] remove unused import --- src/libs/OptionsListUtils/index.ts | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/libs/OptionsListUtils/index.ts b/src/libs/OptionsListUtils/index.ts index 18d82b5bb08f..c60d5203693b 100644 --- a/src/libs/OptionsListUtils/index.ts +++ b/src/libs/OptionsListUtils/index.ts @@ -54,7 +54,6 @@ import { getLastVisibleMessage, getMarkedReimbursedMessage, getMccGroupCategoryMessage, - getMentionedAccountIDsFromAction, getMessageOfOldDotReportAction, getOneTransactionThreadReportID, getOriginalMessage, @@ -66,7 +65,6 @@ import { getRenamedCardFeedMessage, getReportAction, getReportActionActorAccountID, - getReportActionHtml, getReportActionMessageText, getRequireCompanyCardsEnabledMessage, getRoomAvatarUpdatedMessage, From d7136c90687af8194ab351701b450495e207f51f Mon Sep 17 00:00:00 2001 From: Bernhard Owen Josephus Date: Sat, 11 Jul 2026 16:47:42 +0800 Subject: [PATCH 5/6] fix test --- tests/unit/OptionsListUtilsTest.tsx | 29 ++++++++++++++--------------- 1 file changed, 14 insertions(+), 15 deletions(-) diff --git a/tests/unit/OptionsListUtilsTest.tsx b/tests/unit/OptionsListUtilsTest.tsx index 144a0562eae8..30b71d26c61f 100644 --- a/tests/unit/OptionsListUtilsTest.tsx +++ b/tests/unit/OptionsListUtilsTest.tsx @@ -858,6 +858,13 @@ describe('OptionsListUtils', () => { ); }); + beforeEach(async () => { + await act(async () => { + await Onyx.clear(); + }); + jest.clearAllMocks(); + }); + describe('getSearchOptions()', () => { it('should return all options when no search value is provided', () => { // Given a set of options @@ -2034,6 +2041,11 @@ describe('OptionsListUtils', () => { }); describe('getShareDestinationsOptions()', () => { + beforeEach(async () => { + await Onyx.set(`${ONYXKEYS.COLLECTION.REPORT}10`, REPORTS['10'] ?? {}); + await Onyx.set(`${ONYXKEYS.COLLECTION.REPORT_NAME_VALUE_PAIRS}10`, reportNameValuePairs); + }); + it('should exclude archived rooms and hidden threads from share destinations', () => { // Given a set of filtered current Reports (as we do in the component) before getting share destination options const filteredReports = Object.values(OPTIONS.reports).reduce((filtered, option) => { @@ -3546,6 +3558,7 @@ describe('OptionsListUtils', () => { it('createFilteredOptionList() localization', async () => { renderLocaleContextProvider(); // Given a set of reports and personal details + await Onyx.set(ONYXKEYS.PERSONAL_DETAILS_LIST, PERSONAL_DETAILS); // When we call createFilteredOptionList and extract the reports const reports = createFilteredOptionList(PERSONAL_DETAILS, REPORTS, undefined, EMPTY_PRIVATE_IS_ARCHIVED_MAP, allPolicies, {isSearching: true}).reports; @@ -5666,13 +5679,6 @@ describe('OptionsListUtils', () => { }); describe('DEW (Dynamic External Workflow)', () => { - beforeEach(async () => { - await act(async () => { - await Onyx.clear(); - }); - jest.clearAllMocks(); - }); - it('should show queued message for SUBMITTED action with DEW policy when offline and pending submit', async () => { const reportID = 'dewReport1'; const report: Report = { @@ -6435,13 +6441,6 @@ describe('OptionsListUtils', () => { }); describe('getReportOption', () => { - beforeEach(async () => { - await act(async () => { - await Onyx.clear(); - }); - jest.clearAllMocks(); - }); - it('should return option with correct workspace name when policy is provided', async () => { const reportID = '101'; const testPolicyID = 'policy123'; @@ -7656,7 +7655,7 @@ describe('OptionsListUtils', () => { }, }; - beforeAll(async () => { + beforeEach(async () => { const report1: Report = { reportID: formatReportID1, reportName: 'Archived Format Chat', From 774550239460bc369ae60818a677633e718524aa Mon Sep 17 00:00:00 2001 From: Bernhard Owen Josephus Date: Sat, 11 Jul 2026 17:19:53 +0800 Subject: [PATCH 6/6] remove unused export --- src/libs/ReportActionsUtils.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/src/libs/ReportActionsUtils.ts b/src/libs/ReportActionsUtils.ts index 08365d5dbb6d..6ad46a887e6b 100644 --- a/src/libs/ReportActionsUtils.ts +++ b/src/libs/ReportActionsUtils.ts @@ -4856,7 +4856,6 @@ export { isReportActionAttachment, isReportPreviewAction, isReversedTransaction, - getMentionedAccountIDsFromAction, isSentMoneyReportAction, isSplitBillAction, isTaskAction,