From b7f5709424ce0cbc6324a6436214f5ee6c8cd311 Mon Sep 17 00:00:00 2001 From: dmkt9 Date: Sun, 14 Dec 2025 20:53:23 +0700 Subject: [PATCH 01/14] Fix - No checkmark displayed for the selected recipient --- .../iou/request/step/IOURequestStepAmount.tsx | 19 ++++++++++++------- .../step/IOURequestStepParticipants.tsx | 6 +++++- 2 files changed, 17 insertions(+), 8 deletions(-) diff --git a/src/pages/iou/request/step/IOURequestStepAmount.tsx b/src/pages/iou/request/step/IOURequestStepAmount.tsx index 7036c547966f..dbe92b98374f 100644 --- a/src/pages/iou/request/step/IOURequestStepAmount.tsx +++ b/src/pages/iou/request/step/IOURequestStepAmount.tsx @@ -33,6 +33,7 @@ import { sendMoneyWithWallet, setDraftSplitTransaction, setMoneyRequestAmount, + setMoneyRequestParticipants, setMoneyRequestParticipantsFromReport, setSplitShares, trackExpense, @@ -269,6 +270,10 @@ function IOURequestStepAmount({ // Starting from global + menu means no participant context exists yet, // so we need to handle participant selection based on available workspace settings + const isReturningFromConfirmationPage = !!transaction?.participants?.length; + const firstParticipant = transaction?.participants?.at(0); + const isP2PChat = isParticipantP2P(firstParticipant, currentUserPersonalDetails.accountID); + const isNegativeAmount = convertToBackendAmount(Number.parseFloat(amount)) < 0; if ( iouType === CONST.IOU.TYPE.CREATE && isPaidGroupPolicy(defaultExpensePolicy) && @@ -278,7 +283,6 @@ function IOURequestStepAmount({ const activePolicyExpenseChat = getPolicyExpenseChat(currentUserAccountIDParam, defaultExpensePolicy?.id); const shouldAutoReport = !!defaultExpensePolicy?.autoReporting || !!personalPolicy?.autoReporting; const transactionReportID = shouldAutoReport ? activePolicyExpenseChat?.reportID : CONST.REPORT.UNREPORTED_REPORT_ID; - const isReturningFromConfirmationPage = !!transaction?.participants?.length; const resetToDefaultWorkspace = () => { setTransactionReport(transactionID, {reportID: transactionReportID}, true); @@ -288,10 +292,6 @@ function IOURequestStepAmount({ }; if (isReturningFromConfirmationPage) { - const firstParticipant = transaction?.participants?.at(0); - const isP2PChat = isParticipantP2P(firstParticipant); - const isNegativeAmount = convertToBackendAmount(Number.parseFloat(amount)) < 0; - // P2P chats don't support negative amounts, so reset to default workspace when amount is negative. if (isP2PChat && isNegativeAmount) { resetToDefaultWorkspace(); @@ -310,6 +310,11 @@ function IOURequestStepAmount({ } else { resetToDefaultWorkspace(); } + } else if (iouType === CONST.IOU.TYPE.CREATE && isP2PChat && isNegativeAmount && isReturningFromConfirmationPage) { + setTransactionReport(transactionID, {reportID: undefined}, true); + setMoneyRequestParticipants(transactionID, [], true).then(() => { + navigateToParticipantPage(iouType, transactionID, reportID); + }); } else { Navigation.setNavigationActionToMicrotaskQueue(() => { navigateToParticipantPage(iouType, transactionID, reportID); @@ -403,8 +408,8 @@ IOURequestStepAmount.displayName = 'IOURequestStepAmount'; /** * Check if the participant is a P2P chat */ -function isParticipantP2P(participant: {accountID?: number; isPolicyExpenseChat?: boolean} | undefined): boolean { - return !!(participant?.accountID && !participant.isPolicyExpenseChat); +function isParticipantP2P(participant: {accountID?: number; isPolicyExpenseChat?: boolean} | undefined, currentUserAccountID?: number): boolean { + return !!(participant?.accountID && !participant.isPolicyExpenseChat && (!currentUserAccountID || participant?.accountID !== currentUserAccountID)); } const IOURequestStepAmountWithCurrentUserPersonalDetails = withCurrentUserPersonalDetails(IOURequestStepAmount); diff --git a/src/pages/iou/request/step/IOURequestStepParticipants.tsx b/src/pages/iou/request/step/IOURequestStepParticipants.tsx index 3616e1ae714e..aaf12504ddc0 100644 --- a/src/pages/iou/request/step/IOURequestStepParticipants.tsx +++ b/src/pages/iou/request/step/IOURequestStepParticipants.tsx @@ -73,7 +73,11 @@ function IOURequestStepParticipants({ }, transaction: initialTransaction, }: IOURequestStepParticipantsProps) { - const participants = initialTransaction?.participants; + const participants = useMemo( + () => + iouType === CONST.IOU.TYPE.SPLIT ? initialTransaction?.participants : initialTransaction?.participants?.filter((participant) => !participant.isSender && participant.selected), + [initialTransaction?.participants, iouType], + ); const {translate} = useLocalize(); const styles = useThemeStyles(); const isFocused = useIsFocused(); From 2e75d3e2a6c266c9825bf81080274f9f17e4f935 Mon Sep 17 00:00:00 2001 From: dmkt9 Date: Mon, 15 Dec 2025 15:42:52 +0700 Subject: [PATCH 02/14] Fix - No checkmark displayed for the selected recipient --- src/libs/OptionsListUtils/index.ts | 1 + src/pages/iou/request/MoneyRequestParticipantsSelector.tsx | 5 +++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/libs/OptionsListUtils/index.ts b/src/libs/OptionsListUtils/index.ts index 231c0899e37a..978d73da5cee 100644 --- a/src/libs/OptionsListUtils/index.ts +++ b/src/libs/OptionsListUtils/index.ts @@ -393,6 +393,7 @@ function getParticipantsOption(participant: OptionData | Participant, personalDe isSelected: participant.selected, selected: participant.selected, // Keep for backwards compatibility searchText: participant.searchText ?? undefined, + isSelfDM: !!detail?.accountID && detail?.accountID === currentUserAccountID, }; } diff --git a/src/pages/iou/request/MoneyRequestParticipantsSelector.tsx b/src/pages/iou/request/MoneyRequestParticipantsSelector.tsx index 06b3c28572a8..ca2567e88ef9 100644 --- a/src/pages/iou/request/MoneyRequestParticipantsSelector.tsx +++ b/src/pages/iou/request/MoneyRequestParticipantsSelector.tsx @@ -218,7 +218,7 @@ function MoneyRequestParticipantsSelector({ [isIOUSplit, iouType, onParticipantsAdded], ); - const {searchTerm, setSearchTerm, availableOptions, selectedOptions, toggleSelection, areOptionsInitialized, onListEndReached, contactState} = useSearchSelector({ + const {searchTerm, setSearchTerm, availableOptions, selectedOptions, setSelectedOptions, toggleSelection, areOptionsInitialized, onListEndReached, contactState} = useSearchSelector({ selectionMode: isIOUSplit ? CONST.SEARCH_SELECTOR.SELECTION_MODE_MULTI : CONST.SEARCH_SELECTOR.SELECTION_MODE_SINGLE, searchContext: CONST.SEARCH_SELECTOR.SEARCH_CONTEXT_GENERAL, includeUserToInvite: !isCategorizeOrShareAction && !isPerDiemRequest, @@ -500,9 +500,10 @@ function MoneyRequestParticipantsSelector({ return; } + setSelectedOptions([{...option, isSelected: true, reportID: option.reportID ?? ''}]); addSingleParticipant(option); }, - [isIOUSplit, addParticipantToSelection, addSingleParticipant], + [isIOUSplit, addParticipantToSelection, addSingleParticipant, setSelectedOptions], ); const footerContentAbovePaginationComponent = useMemo(() => { From 8bba565e363b0a348671400d8e1498b7b40b164b Mon Sep 17 00:00:00 2001 From: dmkt9 Date: Mon, 15 Dec 2025 16:26:02 +0700 Subject: [PATCH 03/14] fix lint --- src/pages/iou/request/MoneyRequestParticipantsSelector.tsx | 1 + 1 file changed, 1 insertion(+) diff --git a/src/pages/iou/request/MoneyRequestParticipantsSelector.tsx b/src/pages/iou/request/MoneyRequestParticipantsSelector.tsx index ca2567e88ef9..7dc136531c44 100644 --- a/src/pages/iou/request/MoneyRequestParticipantsSelector.tsx +++ b/src/pages/iou/request/MoneyRequestParticipantsSelector.tsx @@ -500,6 +500,7 @@ function MoneyRequestParticipantsSelector({ return; } + // eslint-disable-next-line rulesdir/no-default-id-values setSelectedOptions([{...option, isSelected: true, reportID: option.reportID ?? ''}]); addSingleParticipant(option); }, From f522d0003d485b4bda9458322232b7411636d3bd Mon Sep 17 00:00:00 2001 From: dmkt9 Date: Mon, 15 Dec 2025 16:31:03 +0700 Subject: [PATCH 04/14] Fix - No checkmark displayed for the selected recipient --- .../iou/request/step/IOURequestStepParticipants.tsx | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/src/pages/iou/request/step/IOURequestStepParticipants.tsx b/src/pages/iou/request/step/IOURequestStepParticipants.tsx index aaf12504ddc0..0000c910751e 100644 --- a/src/pages/iou/request/step/IOURequestStepParticipants.tsx +++ b/src/pages/iou/request/step/IOURequestStepParticipants.tsx @@ -73,11 +73,11 @@ function IOURequestStepParticipants({ }, transaction: initialTransaction, }: IOURequestStepParticipantsProps) { - const participants = useMemo( - () => - iouType === CONST.IOU.TYPE.SPLIT ? initialTransaction?.participants : initialTransaction?.participants?.filter((participant) => !participant.isSender && participant.selected), - [initialTransaction?.participants, iouType], - ); + const isSplitRequest = iouType === CONST.IOU.TYPE.SPLIT; + const participants = useMemo(() => { + const allParticipants = initialTransaction?.participants; + return isSplitRequest ? allParticipants : allParticipants?.filter((participant) => !participant.isSender && participant.selected); + }, [initialTransaction?.participants, isSplitRequest]); const {translate} = useLocalize(); const styles = useThemeStyles(); const isFocused = useIsFocused(); @@ -104,7 +104,6 @@ function IOURequestStepParticipants({ const shouldAutoReport = useRef(true); const numberOfParticipants = useRef(participants?.length ?? 0); const iouRequestType = getRequestType(initialTransaction); - const isSplitRequest = iouType === CONST.IOU.TYPE.SPLIT; const isMovingTransactionFromTrackExpense = isMovingTransactionFromTrackExpenseIOUUtils(action); const headerTitle = useMemo(() => { if (action === CONST.IOU.ACTION.CATEGORIZE) { From 07bca03b8ab7d843aea6b1752f2ef2655896c05e Mon Sep 17 00:00:00 2001 From: dmkt9 Date: Mon, 22 Dec 2025 21:44:49 +0700 Subject: [PATCH 05/14] Fix - No checkmark displayed for selected recipient in choose recipient page --- src/libs/OptionsListUtils/index.ts | 36 ++++++++++++++----- src/libs/ReportUtils.ts | 1 + src/libs/actions/IOU.ts | 9 ++++- .../MoneyRequestParticipantsSelector.tsx | 8 ++++- .../step/IOURequestStepConfirmation.tsx | 2 +- .../step/IOURequestStepParticipants.tsx | 3 +- tests/unit/OptionsListUtilsTest.tsx | 18 ++++++++++ 7 files changed, 63 insertions(+), 14 deletions(-) diff --git a/src/libs/OptionsListUtils/index.ts b/src/libs/OptionsListUtils/index.ts index 863979a1513e..cf5f5ae66803 100644 --- a/src/libs/OptionsListUtils/index.ts +++ b/src/libs/OptionsListUtils/index.ts @@ -359,13 +359,17 @@ function isPersonalDetailsReady(personalDetails: OnyxEntry) /** * Get the participant option for a report. + * + * @param shouldAddCurrentUserPostfix - Whether to add the current user postfix (e.g., "(You)") when the participant is the current user */ -function getParticipantsOption(participant: OptionData | Participant, personalDetails: OnyxEntry): Participant { +function getParticipantsOption(participant: OptionData | Participant, personalDetails: OnyxEntry, shouldAddCurrentUserPostfix?: boolean): Participant { const detail = participant.accountID ? getPersonalDetailsForAccountIDs([participant.accountID], personalDetails)[participant.accountID] : undefined; // eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing const login = detail?.login || participant.login || ''; - // eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing - const displayName = participant?.displayName || formatPhoneNumberPhoneUtils(getDisplayNameOrDefault(detail, login || participant.text)); + const displayName = + // eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing + participant?.displayName || + formatPhoneNumberPhoneUtils(getDisplayNameOrDefault(detail, login || participant.text, true, shouldAddCurrentUserPostfix && currentUserAccountID === participant.accountID)); return { keyForList: String(detail?.accountID ?? login), @@ -2109,10 +2113,14 @@ function getValidOptions( // This prevents the issue of seeing the selected option twice if you have them as a recent chat and select them if (!includeSelectedOptions) { for (const option of selectedOptions) { - if (!option.login) { + if (option.login) { + loginsToExclude[option.login] = true; continue; } - loginsToExclude[option.login] = true; + + if (option.reportID) { + loginsToExclude[option.reportID] = true; + } } } const {includeP2P = true, shouldBoldTitleByDefault = true, includeDomainEmail = false, shouldShowGBR = false, ...getValidReportsConfig} = config; @@ -2525,6 +2533,8 @@ function shouldOptionShowTooltip(option: SearchOptionData): boolean { /** * Handles the logic for displaying selected participants from the search term + * + * @param shouldAddCurrentUserPostfix - Whether to add the current user postfix (e.g., "(You)") when the participant is the current user */ function formatSectionsFromSearchTerm( searchTerm: string, @@ -2535,6 +2545,7 @@ function formatSectionsFromSearchTerm( shouldGetOptionDetails = false, filteredWorkspaceChats: SearchOptionData[] = [], reportAttributesDerived?: ReportAttributesDerivedValue['reports'], + shouldAddCurrentUserPostfix?: boolean, ): SectionForSearchTerm { // We show the selected participants at the top of the list when there is no search term or maximum number of participants has already been selected // However, if there is a search term we remove the selected participants from the top of the list unless they are part of the search results @@ -2546,7 +2557,9 @@ function formatSectionsFromSearchTerm( data: shouldGetOptionDetails ? selectedOptions.map((participant) => { const isReportPolicyExpenseChat = participant.isPolicyExpenseChat ?? false; - return isReportPolicyExpenseChat ? getPolicyExpenseReportOption(participant, reportAttributesDerived) : getParticipantsOption(participant, personalDetails); + return isReportPolicyExpenseChat + ? getPolicyExpenseReportOption(participant, reportAttributesDerived) + : getParticipantsOption(participant, personalDetails, shouldAddCurrentUserPostfix); }) : selectedOptions, shouldShow: selectedOptions.length > 0, @@ -2559,7 +2572,10 @@ function formatSectionsFromSearchTerm( // This will add them to the list of options, deduping them if they already exist in the other lists const selectedParticipantsWithoutDetails = selectedOptions.filter((participant) => { const accountID = participant.accountID ?? null; - const isPartOfSearchTerm = getPersonalDetailSearchTerms(participant).join(' ').toLowerCase().includes(cleanSearchTerm); + const isPartOfSearchTerm = getPersonalDetailSearchTerms({...participant, login: participant.login ?? personalDetails[participant.accountID ?? CONST.DEFAULT_NUMBER_ID]?.login}) + .join(' ') + .toLowerCase() + .includes(cleanSearchTerm); const isReportInRecentReports = filteredRecentReports.some((report) => report.accountID === accountID) || filteredWorkspaceChats.some((report) => report.accountID === accountID); const isReportInPersonalDetails = filteredPersonalDetails.some((personalDetail) => personalDetail.accountID === accountID); @@ -2572,7 +2588,9 @@ function formatSectionsFromSearchTerm( data: shouldGetOptionDetails ? selectedParticipantsWithoutDetails.map((participant) => { const isReportPolicyExpenseChat = participant.isPolicyExpenseChat ?? false; - return isReportPolicyExpenseChat ? getPolicyExpenseReportOption(participant, reportAttributesDerived) : getParticipantsOption(participant, personalDetails); + return isReportPolicyExpenseChat + ? getPolicyExpenseReportOption(participant, reportAttributesDerived) + : getParticipantsOption(participant, personalDetails, shouldAddCurrentUserPostfix); }) : selectedParticipantsWithoutDetails, shouldShow: selectedParticipantsWithoutDetails.length > 0, @@ -2597,7 +2615,7 @@ function getPersonalDetailSearchTerms(item: Partial) { if (item.accountID === currentUserAccountID) { return getCurrentUserSearchTerms(item); } - return [item.participantsList?.[0]?.displayName ?? item.displayName ?? '', item.login ?? '', item.login?.replace(CONST.EMAIL_SEARCH_REGEX, '') ?? '']; + return [item.participantsList?.[0]?.displayName ?? item.displayName ?? '', item.login ?? '', item.login?.replace(CONST.EMAIL_SEARCH_REGEX, '') ?? '', item.text ?? '']; } function getCurrentUserSearchTerms(item: Partial) { diff --git a/src/libs/ReportUtils.ts b/src/libs/ReportUtils.ts index ef94108d66e2..8666d764198e 100644 --- a/src/libs/ReportUtils.ts +++ b/src/libs/ReportUtils.ts @@ -11361,6 +11361,7 @@ function createDraftTransactionAndNavigateToParticipantSelector( merchant, modifiedMerchant: '', mccGroup, + participants: undefined, } as Transaction); const filteredPolicies = Object.values(allPolicies ?? {}).filter((policy) => shouldShowPolicy(policy, false, currentUserEmail)); diff --git a/src/libs/actions/IOU.ts b/src/libs/actions/IOU.ts index b36d09212182..9b49bcc15dba 100644 --- a/src/libs/actions/IOU.ts +++ b/src/libs/actions/IOU.ts @@ -12445,7 +12445,14 @@ function getMoneyRequestParticipantsFromReport(report: OnyxEntry ({ - selectedOptions: participants as Participant[], + selectedOptions: participants.map((participant) => ({ + ...participant, + login: participant.login ?? personalDetails?.[participant.accountID ?? CONST.DEFAULT_NUMBER_ID]?.login, + })) as OptionData[], excludeLogins: CONST.EXPENSIFY_EMAILS_OBJECT, includeOwnedWorkspaceChats: iouType === CONST.IOU.TYPE.SUBMIT || iouType === CONST.IOU.TYPE.CREATE || iouType === CONST.IOU.TYPE.SPLIT || iouType === CONST.IOU.TYPE.TRACK, excludeNonAdminWorkspaces: action === CONST.IOU.ACTION.SHARE, @@ -188,6 +191,7 @@ function MoneyRequestParticipantsSelector({ preferRecentExpenseReports: action === CONST.IOU.ACTION.CREATE, isRestrictedToPreferredPolicy, preferredPolicyID, + shouldExcludeSelectedByReportID: true, }), [ participants, @@ -200,6 +204,7 @@ function MoneyRequestParticipantsSelector({ isPaidGroupPolicy, isRestrictedToPreferredPolicy, preferredPolicyID, + personalDetails, ], ); @@ -291,6 +296,7 @@ function MoneyRequestParticipantsSelector({ true, undefined, reportAttributesDerived, + true, ); newSections.push(formatResults.section); diff --git a/src/pages/iou/request/step/IOURequestStepConfirmation.tsx b/src/pages/iou/request/step/IOURequestStepConfirmation.tsx index b5a8418bde76..5ff06081bb25 100644 --- a/src/pages/iou/request/step/IOURequestStepConfirmation.tsx +++ b/src/pages/iou/request/step/IOURequestStepConfirmation.tsx @@ -293,7 +293,7 @@ function IOURequestStepConfirmation({ if (participant.isSender && iouType === CONST.IOU.TYPE.INVOICE) { return participant; } - return participant.accountID ? getParticipantsOption(participant, personalDetails) : getReportOption(participant, reportAttributesDerived, reportDrafts); + return participant.accountID ? getParticipantsOption(participant, personalDetails, true) : getReportOption(participant, reportAttributesDerived, reportDrafts); }) ?? [], [transaction?.participants, iouType, personalDetails, reportAttributesDerived, reportDrafts], ); diff --git a/src/pages/iou/request/step/IOURequestStepParticipants.tsx b/src/pages/iou/request/step/IOURequestStepParticipants.tsx index 60a15a275e8f..2f2edf01837a 100644 --- a/src/pages/iou/request/step/IOURequestStepParticipants.tsx +++ b/src/pages/iou/request/step/IOURequestStepParticipants.tsx @@ -41,7 +41,6 @@ import type SCREENS from '@src/SCREENS'; import type {Policy} from '@src/types/onyx'; import type {Participant} from '@src/types/onyx/IOU'; import type Transaction from '@src/types/onyx/Transaction'; -import getEmptyArray from '@src/types/utils/getEmptyArray'; import KeyboardUtils from '@src/utils/keyboard'; import StepScreenWrapper from './StepScreenWrapper'; import type {WithFullTransactionOrNotFoundProps} from './withFullTransactionOrNotFound'; @@ -431,7 +430,7 @@ function IOURequestStepParticipants({ /> )} { expect(results.recentReports).not.toEqual(expect.arrayContaining([expect.objectContaining({login: 'receipts@expensify.com'})])); }); + it('should exclude the person and the report from selected options', () => { + const selectedPerson = PERSONAL_DETAILS['3']; + const selectedReport = REPORTS['3'] as unknown as OptionData; + + const results = getValidOptions({reports: OPTIONS.reports, personalDetails: OPTIONS.personalDetails}, {}, nvpDismissedProductTraining, { + excludeLogins: CONST.EXPENSIFY_EMAILS_OBJECT, + selectedOptions: [selectedPerson, selectedReport], + }); + + // The person must be excluded + expect(results.recentReports.every((option) => option.login !== selectedPerson.login)).toBe(true); + expect(results.personalDetails.every((option) => option.login !== selectedPerson.login)).toBe(true); + + // The report must be excluded + expect(results.recentReports.every((option) => option.reportID !== selectedReport.reportID)).toBe(true); + expect(results.personalDetails.every((option) => option.reportID !== selectedPerson.reportID)).toBe(true); + }); + it('should limit recent reports when maxRecentReportElements is specified', () => { // Given a set of reports and personalDetails with multiple reports // When we call getValidOptions with maxRecentReportElements set to 2 From 663deb9a81f6f60261183e1d28e6edd3271dc5ce Mon Sep 17 00:00:00 2001 From: dmkt9 Date: Tue, 23 Dec 2025 17:55:39 +0700 Subject: [PATCH 06/14] Fix - No checkmark displayed for selected recipient in choose recipient page --- src/libs/OptionsListUtils/index.ts | 27 ++++++++++++++++++--------- 1 file changed, 18 insertions(+), 9 deletions(-) diff --git a/src/libs/OptionsListUtils/index.ts b/src/libs/OptionsListUtils/index.ts index 8c587ddfb710..4ed299baacb1 100644 --- a/src/libs/OptionsListUtils/index.ts +++ b/src/libs/OptionsListUtils/index.ts @@ -1047,8 +1047,12 @@ function getReportDisplayOption(report: OnyxEntry, unknownUserDetails: O /** * Get the option for a policy expense report. */ -function getPolicyExpenseReportOption(participant: Participant | SearchOptionData, reportAttributesDerived?: ReportAttributesDerivedValue['reports']): SearchOptionData { - const expenseReport = reportUtilsIsPolicyExpenseChat(participant) ? getReportOrDraftReport(participant.reportID) : null; +function getPolicyExpenseReportOption( + participant: Participant | SearchOptionData, + reportAttributesDerived?: ReportAttributesDerivedValue['reports'], + isIOUInvoiceRoom?: boolean, +): SearchOptionData { + const expenseReport = reportUtilsIsPolicyExpenseChat(participant) || isIOUInvoiceRoom ? getReportOrDraftReport(participant.reportID) : null; const visibleParticipantAccountIDs = Object.entries(expenseReport?.participants ?? {}) .filter(([, reportParticipant]) => reportParticipant && !isHiddenForCurrentUser(reportParticipant.notificationPreference)) @@ -1065,10 +1069,12 @@ function getPolicyExpenseReportOption(participant: Participant | SearchOptionDat reportAttributesDerived, ); - // Update text & alternateText because createOption returns workspace name only if report is owned by the user - option.text = getPolicyName({report: expenseReport}); + if (!isIOUInvoiceRoom) { + // Update text & alternateText because createOption returns workspace name only if report is owned by the user + option.text = getPolicyName({report: expenseReport}); + } // eslint-disable-next-line @typescript-eslint/no-deprecated - option.alternateText = translateLocal('workspace.common.workspace'); + option.alternateText = isIOUInvoiceRoom ? translateLocal('workspace.common.invoices') : translateLocal('workspace.common.workspace'); option.isSelected = participant.selected; option.selected = participant.selected; // Keep for backwards compatibility return option; @@ -2556,8 +2562,10 @@ function formatSectionsFromSearchTerm( data: shouldGetOptionDetails ? selectedOptions.map((participant) => { const isReportPolicyExpenseChat = participant.isPolicyExpenseChat ?? false; - return isReportPolicyExpenseChat - ? getPolicyExpenseReportOption(participant, reportAttributesDerived) + const isIOUInvoiceRoom = + participant.accountID === CONST.DEFAULT_NUMBER_ID && !!participant.reportID && 'iouType' in participant && participant.iouType === 'invoice'; + return isReportPolicyExpenseChat || isIOUInvoiceRoom + ? getPolicyExpenseReportOption(participant, reportAttributesDerived, isIOUInvoiceRoom) : getParticipantsOption(participant, personalDetails, shouldAddCurrentUserPostfix); }) : selectedOptions, @@ -2587,8 +2595,9 @@ function formatSectionsFromSearchTerm( data: shouldGetOptionDetails ? selectedParticipantsWithoutDetails.map((participant) => { const isReportPolicyExpenseChat = participant.isPolicyExpenseChat ?? false; - return isReportPolicyExpenseChat - ? getPolicyExpenseReportOption(participant, reportAttributesDerived) + const isIOUInvoiceRoom = participant.accountID === CONST.DEFAULT_NUMBER_ID && !!participant.reportID && 'iouType' in participant && participant.iouType === 'invoice'; + return isReportPolicyExpenseChat || isIOUInvoiceRoom + ? getPolicyExpenseReportOption(participant, reportAttributesDerived, isIOUInvoiceRoom) : getParticipantsOption(participant, personalDetails, shouldAddCurrentUserPostfix); }) : selectedParticipantsWithoutDetails, From af514f2dd4e58d60065f65df0e9eadb89d345b08 Mon Sep 17 00:00:00 2001 From: dmkt9 Date: Tue, 23 Dec 2025 18:47:26 +0700 Subject: [PATCH 07/14] fix test --- tests/unit/OptionsListUtilsTest.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/unit/OptionsListUtilsTest.tsx b/tests/unit/OptionsListUtilsTest.tsx index 18bf938d21c5..ad9db68b64cc 100644 --- a/tests/unit/OptionsListUtilsTest.tsx +++ b/tests/unit/OptionsListUtilsTest.tsx @@ -1230,7 +1230,7 @@ describe('OptionsListUtils', () => { const selectedPerson = PERSONAL_DETAILS['3']; const selectedReport = REPORTS['3'] as unknown as OptionData; - const results = getValidOptions({reports: OPTIONS.reports, personalDetails: OPTIONS.personalDetails}, {}, nvpDismissedProductTraining, { + const results = getValidOptions({reports: OPTIONS.reports, personalDetails: OPTIONS.personalDetails}, {}, nvpDismissedProductTraining, loginList, { excludeLogins: CONST.EXPENSIFY_EMAILS_OBJECT, selectedOptions: [selectedPerson, selectedReport], }); From 5ce8ae22d0fd06ab9b02131319e59f4a3117cffe Mon Sep 17 00:00:00 2001 From: dmkt9 Date: Thu, 15 Jan 2026 17:08:16 +0700 Subject: [PATCH 08/14] Fix - No checkmark displayed for selected recipient in choose recipient page --- src/libs/OptionsListUtils/index.ts | 53 +++++++++---------- src/libs/actions/IOU/index.ts | 9 +--- .../MoneyRequestParticipantsSelector.tsx | 2 - .../step/IOURequestStepConfirmation.tsx | 2 +- 4 files changed, 26 insertions(+), 40 deletions(-) diff --git a/src/libs/OptionsListUtils/index.ts b/src/libs/OptionsListUtils/index.ts index 99bc40bc111e..49d47f4ff2c5 100644 --- a/src/libs/OptionsListUtils/index.ts +++ b/src/libs/OptionsListUtils/index.ts @@ -354,17 +354,13 @@ function isPersonalDetailsReady(personalDetails: OnyxEntry) /** * Get the participant option for a report. - * - * @param shouldAddCurrentUserPostfix - Whether to add the current user postfix (e.g., "(You)") when the participant is the current user */ -function getParticipantsOption(participant: OptionData | Participant, personalDetails: OnyxEntry, shouldAddCurrentUserPostfix?: boolean): Participant { +function getParticipantsOption(participant: OptionData | Participant, personalDetails: OnyxEntry): Participant { const detail = participant.accountID ? getPersonalDetailsForAccountIDs([participant.accountID], personalDetails)[participant.accountID] : undefined; // eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing const login = detail?.login || participant.login || ''; - const displayName = - // eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing - participant?.displayName || - formatPhoneNumberPhoneUtils(getDisplayNameOrDefault(detail, login || participant.text, true, shouldAddCurrentUserPostfix && currentUserAccountID === participant.accountID)); + // eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing + const displayName = participant?.displayName || formatPhoneNumberPhoneUtils(getDisplayNameOrDefault(detail, login || participant.text)); return { keyForList: String(detail?.accountID ?? login), @@ -390,7 +386,6 @@ function getParticipantsOption(participant: OptionData | Participant, personalDe isSelected: participant.selected, selected: participant.selected, // Keep for backwards compatibility searchText: participant.searchText ?? undefined, - isSelfDM: !!detail?.accountID && detail?.accountID === currentUserAccountID, }; } @@ -2602,25 +2597,26 @@ function formatSectionsFromSearchTerm( shouldGetOptionDetails = false, filteredWorkspaceChats: SearchOptionData[] = [], reportAttributesDerived?: ReportAttributesDerivedValue['reports'], - shouldAddCurrentUserPostfix?: boolean, ): SectionForSearchTerm { // We show the selected participants at the top of the list when there is no search term or maximum number of participants has already been selected // However, if there is a search term we remove the selected participants from the top of the list unless they are part of the search results // This clears up space on mobile views, where if you create a group with 4+ people you can't see the selected participants and the search results at the same time + const selectedOptionsMapper = (participant: Participant) => { + const isReportPolicyExpenseChat = participant.isPolicyExpenseChat ?? false; + const isIOUInvoiceRoom = participant.accountID === CONST.DEFAULT_NUMBER_ID && !!participant.reportID && 'iouType' in participant && participant.iouType === 'invoice'; + if (participant.isSelfDM) { + return getReportOption(participant, undefined, reportAttributesDerived); + } + return isReportPolicyExpenseChat || isIOUInvoiceRoom + ? getPolicyExpenseReportOption(participant, reportAttributesDerived, isIOUInvoiceRoom) + : getParticipantsOption(participant, personalDetails); + }; + if (searchTerm === '') { return { section: { title: undefined, - data: shouldGetOptionDetails - ? selectedOptions.map((participant) => { - const isReportPolicyExpenseChat = participant.isPolicyExpenseChat ?? false; - const isIOUInvoiceRoom = - participant.accountID === CONST.DEFAULT_NUMBER_ID && !!participant.reportID && 'iouType' in participant && participant.iouType === 'invoice'; - return isReportPolicyExpenseChat || isIOUInvoiceRoom - ? getPolicyExpenseReportOption(participant, reportAttributesDerived, isIOUInvoiceRoom) - : getParticipantsOption(participant, personalDetails, shouldAddCurrentUserPostfix); - }) - : selectedOptions, + data: shouldGetOptionDetails ? selectedOptions.map(selectedOptionsMapper) : selectedOptions, shouldShow: selectedOptions.length > 0, }, }; @@ -2631,7 +2627,14 @@ function formatSectionsFromSearchTerm( // This will add them to the list of options, deduping them if they already exist in the other lists const selectedParticipantsWithoutDetails = selectedOptions.filter((participant) => { const accountID = participant.accountID ?? null; - const isPartOfSearchTerm = getPersonalDetailSearchTerms({...participant, login: participant.login ?? personalDetails[participant.accountID ?? CONST.DEFAULT_NUMBER_ID]?.login}) + let currentParticipant = participant; + if (currentParticipant.isSelfDM) { + currentParticipant = {...currentParticipant, accountID: currentUserAccountID}; + } + const isPartOfSearchTerm = getPersonalDetailSearchTerms({ + ...currentParticipant, + login: currentParticipant.login ?? personalDetails[currentParticipant.accountID ?? CONST.DEFAULT_NUMBER_ID]?.login, + }) .join(' ') .toLowerCase() .includes(cleanSearchTerm); @@ -2644,15 +2647,7 @@ function formatSectionsFromSearchTerm( return { section: { title: undefined, - data: shouldGetOptionDetails - ? selectedParticipantsWithoutDetails.map((participant) => { - const isReportPolicyExpenseChat = participant.isPolicyExpenseChat ?? false; - const isIOUInvoiceRoom = participant.accountID === CONST.DEFAULT_NUMBER_ID && !!participant.reportID && 'iouType' in participant && participant.iouType === 'invoice'; - return isReportPolicyExpenseChat || isIOUInvoiceRoom - ? getPolicyExpenseReportOption(participant, reportAttributesDerived, isIOUInvoiceRoom) - : getParticipantsOption(participant, personalDetails, shouldAddCurrentUserPostfix); - }) - : selectedParticipantsWithoutDetails, + data: shouldGetOptionDetails ? selectedParticipantsWithoutDetails.map(selectedOptionsMapper) : selectedParticipantsWithoutDetails, shouldShow: selectedParticipantsWithoutDetails.length > 0, }, }; diff --git a/src/libs/actions/IOU/index.ts b/src/libs/actions/IOU/index.ts index cf3987bf2f2b..75502470d4fc 100644 --- a/src/libs/actions/IOU/index.ts +++ b/src/libs/actions/IOU/index.ts @@ -11783,14 +11783,7 @@ function getMoneyRequestParticipantsFromReport(report: OnyxEntry Date: Thu, 15 Jan 2026 17:32:07 +0700 Subject: [PATCH 09/14] Fix - No checkmark displayed for selected recipient in choose recipient page --- src/libs/OptionsListUtils/index.ts | 22 +++++++--------------- src/libs/ReportUtils.ts | 1 - 2 files changed, 7 insertions(+), 16 deletions(-) diff --git a/src/libs/OptionsListUtils/index.ts b/src/libs/OptionsListUtils/index.ts index 49d47f4ff2c5..e1b2bfd997e1 100644 --- a/src/libs/OptionsListUtils/index.ts +++ b/src/libs/OptionsListUtils/index.ts @@ -1079,12 +1079,8 @@ function getReportDisplayOption(report: OnyxEntry, unknownUserDetails: O /** * Get the option for a policy expense report. */ -function getPolicyExpenseReportOption( - participant: Participant | SearchOptionData, - reportAttributesDerived?: ReportAttributesDerivedValue['reports'], - isIOUInvoiceRoom?: boolean, -): SearchOptionData { - const expenseReport = reportUtilsIsPolicyExpenseChat(participant) || isIOUInvoiceRoom ? getReportOrDraftReport(participant.reportID) : null; +function getPolicyExpenseReportOption(participant: Participant | SearchOptionData, reportAttributesDerived?: ReportAttributesDerivedValue['reports']): SearchOptionData { + const expenseReport = reportUtilsIsPolicyExpenseChat(participant) ? getReportOrDraftReport(participant.reportID) : null; const visibleParticipantAccountIDs = Object.entries(expenseReport?.participants ?? {}) .filter(([, reportParticipant]) => reportParticipant && !isHiddenForCurrentUser(reportParticipant.notificationPreference)) @@ -1101,12 +1097,10 @@ function getPolicyExpenseReportOption( reportAttributesDerived, ); - if (!isIOUInvoiceRoom) { - // Update text & alternateText because createOption returns workspace name only if report is owned by the user - option.text = getPolicyName({report: expenseReport}); - } + // Update text & alternateText because createOption returns workspace name only if report is owned by the user + option.text = getPolicyName({report: expenseReport}); // eslint-disable-next-line @typescript-eslint/no-deprecated - option.alternateText = isIOUInvoiceRoom ? translateLocal('workspace.common.invoices') : translateLocal('workspace.common.workspace'); + option.alternateText = translateLocal('workspace.common.workspace'); option.isSelected = participant.selected; option.selected = participant.selected; // Keep for backwards compatibility return option; @@ -2604,12 +2598,10 @@ function formatSectionsFromSearchTerm( const selectedOptionsMapper = (participant: Participant) => { const isReportPolicyExpenseChat = participant.isPolicyExpenseChat ?? false; const isIOUInvoiceRoom = participant.accountID === CONST.DEFAULT_NUMBER_ID && !!participant.reportID && 'iouType' in participant && participant.iouType === 'invoice'; - if (participant.isSelfDM) { + if (participant.isSelfDM || isIOUInvoiceRoom) { return getReportOption(participant, undefined, reportAttributesDerived); } - return isReportPolicyExpenseChat || isIOUInvoiceRoom - ? getPolicyExpenseReportOption(participant, reportAttributesDerived, isIOUInvoiceRoom) - : getParticipantsOption(participant, personalDetails); + return isReportPolicyExpenseChat ? getPolicyExpenseReportOption(participant, reportAttributesDerived) : getParticipantsOption(participant, personalDetails); }; if (searchTerm === '') { diff --git a/src/libs/ReportUtils.ts b/src/libs/ReportUtils.ts index 25a631d54466..2c00bc38705e 100644 --- a/src/libs/ReportUtils.ts +++ b/src/libs/ReportUtils.ts @@ -11224,7 +11224,6 @@ function createDraftTransactionAndNavigateToParticipantSelector( modifiedMerchant: '', modifiedAttendees: undefined, mccGroup, - participants: undefined, } as Transaction); const filteredPolicies = Object.values(allPolicies ?? {}).filter((policy) => shouldShowPolicy(policy, false, currentUserEmail)); From 669e39b4f02c977817e3d757444933fc2002b558 Mon Sep 17 00:00:00 2001 From: dmkt9 Date: Thu, 22 Jan 2026 15:34:00 +0700 Subject: [PATCH 10/14] Fix - No checkmark displayed for the selected recipient --- src/libs/OptionsListUtils/index.ts | 5 ++--- src/pages/iou/request/MoneyRequestParticipantsSelector.tsx | 6 +----- src/pages/iou/request/step/IOURequestStepAmount.tsx | 4 +++- 3 files changed, 6 insertions(+), 9 deletions(-) diff --git a/src/libs/OptionsListUtils/index.ts b/src/libs/OptionsListUtils/index.ts index 2564e9fa56b0..c43dabd5d6c2 100644 --- a/src/libs/OptionsListUtils/index.ts +++ b/src/libs/OptionsListUtils/index.ts @@ -2626,8 +2626,6 @@ function shouldOptionShowTooltip(option: SearchOptionData): boolean { /** * Handles the logic for displaying selected participants from the search term - * - * @param shouldAddCurrentUserPostfix - Whether to add the current user postfix (e.g., "(You)") when the participant is the current user */ function formatSectionsFromSearchTerm( searchTerm: string, @@ -2646,7 +2644,8 @@ function formatSectionsFromSearchTerm( const isReportPolicyExpenseChat = participant.isPolicyExpenseChat ?? false; const isIOUInvoiceRoom = participant.accountID === CONST.DEFAULT_NUMBER_ID && !!participant.reportID && 'iouType' in participant && participant.iouType === 'invoice'; if (participant.isSelfDM || isIOUInvoiceRoom) { - return getReportOption(participant, undefined, reportAttributesDerived); + const privateIsArchived = allReportNameValuePairsOnyxConnect?.[`${ONYXKEYS.COLLECTION.REPORT_NAME_VALUE_PAIRS}${participant.reportID}`]?.private_isArchived; + return getReportOption(participant, privateIsArchived, undefined, reportAttributesDerived); } return isReportPolicyExpenseChat ? getPolicyExpenseReportOption(participant, reportAttributesDerived) : getParticipantsOption(participant, personalDetails); }; diff --git a/src/pages/iou/request/MoneyRequestParticipantsSelector.tsx b/src/pages/iou/request/MoneyRequestParticipantsSelector.tsx index 2f1ab1104373..7c27951d325f 100644 --- a/src/pages/iou/request/MoneyRequestParticipantsSelector.tsx +++ b/src/pages/iou/request/MoneyRequestParticipantsSelector.tsx @@ -172,10 +172,7 @@ function MoneyRequestParticipantsSelector({ const getValidOptionsConfig = useMemo( () => ({ - selectedOptions: participants.map((participant) => ({ - ...participant, - login: participant.login ?? personalDetails?.[participant.accountID ?? CONST.DEFAULT_NUMBER_ID]?.login, - })) as OptionData[], + selectedOptions: participants as Participant[], excludeLogins: CONST.EXPENSIFY_EMAILS_OBJECT, includeOwnedWorkspaceChats: iouType === CONST.IOU.TYPE.SUBMIT || iouType === CONST.IOU.TYPE.CREATE || iouType === CONST.IOU.TYPE.SPLIT || iouType === CONST.IOU.TYPE.TRACK, excludeNonAdminWorkspaces: action === CONST.IOU.ACTION.SHARE, @@ -204,7 +201,6 @@ function MoneyRequestParticipantsSelector({ isPaidGroupPolicy, isRestrictedToPreferredPolicy, preferredPolicyID, - personalDetails, ], ); diff --git a/src/pages/iou/request/step/IOURequestStepAmount.tsx b/src/pages/iou/request/step/IOURequestStepAmount.tsx index 1ddacf2d410e..5d3d73309c47 100644 --- a/src/pages/iou/request/step/IOURequestStepAmount.tsx +++ b/src/pages/iou/request/step/IOURequestStepAmount.tsx @@ -334,7 +334,9 @@ function IOURequestStepAmount({ } else { resetToDefaultWorkspace(); } - } else if (iouType === CONST.IOU.TYPE.CREATE && isP2PChat && isNegativeAmount && isReturningFromConfirmationPage) { + } + // P2P chats don't support negative amounts, so in cases where there is no default workspace when the amount is negative, we will remove the selected transaction participants. + else if (iouType === CONST.IOU.TYPE.CREATE && isP2PChat && isNegativeAmount && isReturningFromConfirmationPage) { setTransactionReport(transactionID, {reportID: undefined}, true); setMoneyRequestParticipants(transactionID, [], true).then(() => { navigateToParticipantPage(iouType, transactionID, reportID); From 44da0d9ac8db33ccccf96885744da76bab75ab5b Mon Sep 17 00:00:00 2001 From: dmkt9 Date: Thu, 22 Jan 2026 15:42:01 +0700 Subject: [PATCH 11/14] fix ts --- tests/unit/OptionsListUtilsTest.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/unit/OptionsListUtilsTest.tsx b/tests/unit/OptionsListUtilsTest.tsx index dba227c3d06c..6bdf36173d67 100644 --- a/tests/unit/OptionsListUtilsTest.tsx +++ b/tests/unit/OptionsListUtilsTest.tsx @@ -1275,7 +1275,7 @@ describe('OptionsListUtils', () => { const selectedPerson = PERSONAL_DETAILS['3']; const selectedReport = REPORTS['3'] as unknown as OptionData; - const results = getValidOptions({reports: OPTIONS.reports, personalDetails: OPTIONS.personalDetails}, {}, nvpDismissedProductTraining, loginList, { + const results = getValidOptions({reports: OPTIONS.reports, personalDetails: OPTIONS.personalDetails}, allPolicies, {}, nvpDismissedProductTraining, loginList, { excludeLogins: CONST.EXPENSIFY_EMAILS_OBJECT, selectedOptions: [selectedPerson, selectedReport], }); From b062e935b5659f68913d66090c038e916d9dd6c1 Mon Sep 17 00:00:00 2001 From: dmkt9 Date: Wed, 28 Jan 2026 20:45:51 +0700 Subject: [PATCH 12/14] Fix - No checkmark displayed for selected recipient in choose recipient page --- src/libs/OptionsListUtils/index.ts | 2 +- .../MoneyRequestParticipantsSelector.tsx | 1 - tests/unit/OptionsListUtilsTest.tsx | 17 +++++++++++++---- 3 files changed, 14 insertions(+), 6 deletions(-) diff --git a/src/libs/OptionsListUtils/index.ts b/src/libs/OptionsListUtils/index.ts index 0c6f3945ffc6..238857a1e780 100644 --- a/src/libs/OptionsListUtils/index.ts +++ b/src/libs/OptionsListUtils/index.ts @@ -2682,7 +2682,7 @@ function formatSectionsFromSearchTerm( const isIOUInvoiceRoom = participant.accountID === CONST.DEFAULT_NUMBER_ID && !!participant.reportID && 'iouType' in participant && participant.iouType === 'invoice'; if (participant.isSelfDM || isIOUInvoiceRoom) { const privateIsArchived = allReportNameValuePairsOnyxConnect?.[`${ONYXKEYS.COLLECTION.REPORT_NAME_VALUE_PAIRS}${participant.reportID}`]?.private_isArchived; - return getReportOption(participant, privateIsArchived, undefined, reportAttributesDerived); + return getReportOption(participant, privateIsArchived, undefined, currentUserAccountID, personalDetails, reportAttributesDerived); } return isReportPolicyExpenseChat ? getPolicyExpenseReportOption(participant, currentUserAccountID, personalDetails, reportAttributesDerived) diff --git a/src/pages/iou/request/MoneyRequestParticipantsSelector.tsx b/src/pages/iou/request/MoneyRequestParticipantsSelector.tsx index 69ed5557a232..de1db0602fb6 100644 --- a/src/pages/iou/request/MoneyRequestParticipantsSelector.tsx +++ b/src/pages/iou/request/MoneyRequestParticipantsSelector.tsx @@ -510,7 +510,6 @@ function MoneyRequestParticipantsSelector({ return; } - // eslint-disable-next-line rulesdir/no-default-id-values setSelectedOptions([{...option, isSelected: true, reportID: option.reportID ?? ''}]); addSingleParticipant(option); }, diff --git a/tests/unit/OptionsListUtilsTest.tsx b/tests/unit/OptionsListUtilsTest.tsx index bd0a59fb8c20..4323a7fa0fd0 100644 --- a/tests/unit/OptionsListUtilsTest.tsx +++ b/tests/unit/OptionsListUtilsTest.tsx @@ -1407,10 +1407,19 @@ describe('OptionsListUtils', () => { const selectedPerson = PERSONAL_DETAILS['3']; const selectedReport = REPORTS['3'] as unknown as OptionData; - const results = getValidOptions({reports: OPTIONS.reports, personalDetails: OPTIONS.personalDetails}, allPolicies, {}, nvpDismissedProductTraining, loginList, { - excludeLogins: CONST.EXPENSIFY_EMAILS_OBJECT, - selectedOptions: [selectedPerson, selectedReport], - }); + const results = getValidOptions( + {reports: OPTIONS.reports, personalDetails: OPTIONS.personalDetails}, + allPolicies, + {}, + nvpDismissedProductTraining, + loginList, + CURRENT_USER_ACCOUNT_ID, + CURRENT_USER_EMAIL, + { + excludeLogins: CONST.EXPENSIFY_EMAILS_OBJECT, + selectedOptions: [selectedPerson, selectedReport], + }, + ); // The person must be excluded expect(results.recentReports.every((option) => option.login !== selectedPerson.login)).toBe(true); From ec0029c2adaef93659f43de028e6ad9fe119bdd1 Mon Sep 17 00:00:00 2001 From: dmkt9 Date: Wed, 28 Jan 2026 21:05:03 +0700 Subject: [PATCH 13/14] fix lint --- src/pages/iou/request/MoneyRequestParticipantsSelector.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pages/iou/request/MoneyRequestParticipantsSelector.tsx b/src/pages/iou/request/MoneyRequestParticipantsSelector.tsx index de1db0602fb6..3aeb312c83ef 100644 --- a/src/pages/iou/request/MoneyRequestParticipantsSelector.tsx +++ b/src/pages/iou/request/MoneyRequestParticipantsSelector.tsx @@ -510,7 +510,7 @@ function MoneyRequestParticipantsSelector({ return; } - setSelectedOptions([{...option, isSelected: true, reportID: option.reportID ?? ''}]); + setSelectedOptions([{...option, isSelected: true, reportID: option.reportID ?? CONST.REPORT.UNREPORTED_REPORT_ID}]); addSingleParticipant(option); }, [isIOUSplit, addParticipantToSelection, addSingleParticipant, setSelectedOptions], From dee4d854fa26568dfe6af676c959f86c2dec4a42 Mon Sep 17 00:00:00 2001 From: dmkt9 Date: Mon, 9 Feb 2026 17:27:08 +0700 Subject: [PATCH 14/14] Fix - No checkmark displayed for selected recipient in choose recipient page --- src/libs/OptionsListUtils/index.ts | 1 + .../iou/request/MoneyRequestParticipantsSelector.tsx | 11 +++++++++-- .../iou/request/step/IOURequestStepParticipants.tsx | 4 +++- 3 files changed, 13 insertions(+), 3 deletions(-) diff --git a/src/libs/OptionsListUtils/index.ts b/src/libs/OptionsListUtils/index.ts index 1fef48ac7e09..3da06fbe7ffb 100644 --- a/src/libs/OptionsListUtils/index.ts +++ b/src/libs/OptionsListUtils/index.ts @@ -2258,6 +2258,7 @@ function getValidOptions( if (option.reportID) { loginsToExclude[option.reportID] = true; + loginsToExcludeFromSuggestions[option.reportID] = true; } } } diff --git a/src/pages/iou/request/MoneyRequestParticipantsSelector.tsx b/src/pages/iou/request/MoneyRequestParticipantsSelector.tsx index 3aeb312c83ef..81c98d332afe 100644 --- a/src/pages/iou/request/MoneyRequestParticipantsSelector.tsx +++ b/src/pages/iou/request/MoneyRequestParticipantsSelector.tsx @@ -414,9 +414,15 @@ function MoneyRequestParticipantsSelector({ return; } + // If the selected option is self DM, we need to recall onParticipantsAdded to handle navigation correctly + if (!option && selectedOptions.length === 1 && selectedOptions.at(0)?.isSelfDM) { + onParticipantsAdded(selectedOptions.map((selectedOption) => sanitizedSelectedParticipant(selectedOption, iouType))); + return; + } + onFinish(CONST.IOU.TYPE.SPLIT); }, - [shouldShowSplitBillErrorMessage, onFinish, addSingleParticipant, selectedOptions.length], + [shouldShowSplitBillErrorMessage, onFinish, addSingleParticipant, onParticipantsAdded, selectedOptions, iouType], ); const showLoadingPlaceholder = useMemo(() => !areOptionsInitialized || !didScreenTransitionEnd, [areOptionsInitialized, didScreenTransitionEnd]); @@ -510,7 +516,8 @@ function MoneyRequestParticipantsSelector({ return; } - setSelectedOptions([{...option, isSelected: true, reportID: option.reportID ?? CONST.REPORT.UNREPORTED_REPORT_ID}]); + const reportID = option.reportID ?? CONST.REPORT.UNREPORTED_REPORT_ID; + setSelectedOptions([{...option, isSelected: true, reportID, keyForList: reportID}]); addSingleParticipant(option); }, [isIOUSplit, addParticipantToSelection, addSingleParticipant, setSelectedOptions], diff --git a/src/pages/iou/request/step/IOURequestStepParticipants.tsx b/src/pages/iou/request/step/IOURequestStepParticipants.tsx index 30b262f77fd6..6b576152d6e0 100644 --- a/src/pages/iou/request/step/IOURequestStepParticipants.tsx +++ b/src/pages/iou/request/step/IOURequestStepParticipants.tsx @@ -90,7 +90,9 @@ function IOURequestStepParticipants({ const transactionIDs = useMemo(() => transactions?.map((transaction) => transaction.transactionID), [transactions.length]); // We need to set selectedReportID if user has navigated back from confirmation page and navigates to confirmation page with already selected participant - const selectedReportID = useRef(participants?.length === 1 ? (participants.at(0)?.reportID ?? reportID) : reportID); + // We need to disable the eslint rule here because the reportID from the first participant can be an empty string + // eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing + const selectedReportID = useRef(participants?.length === 1 ? participants.at(0)?.reportID || reportID : reportID); const numberOfParticipants = useRef(participants?.length ?? 0); const iouRequestType = getRequestType(initialTransaction); const isMovingTransactionFromTrackExpense = isMovingTransactionFromTrackExpenseIOUUtils(action);