From 33271968658c4e5ece26df5420446f20b689e681 Mon Sep 17 00:00:00 2001 From: VH Date: Wed, 19 Nov 2025 15:51:09 +0700 Subject: [PATCH 01/36] Add utils to check harvest report and get originalID --- src/libs/ReportUtils.ts | 22 +++++++++++++++++++++- src/types/onyx/ReportNameValuePairs.ts | 6 ++++++ 2 files changed, 27 insertions(+), 1 deletion(-) diff --git a/src/libs/ReportUtils.ts b/src/libs/ReportUtils.ts index 37b9a27dc267..49cd9bea8111 100644 --- a/src/libs/ReportUtils.ts +++ b/src/libs/ReportUtils.ts @@ -2293,6 +2293,23 @@ function isArchivedReport(reportNameValuePairs?: OnyxInputOrEntry): boolean { + return !!reportNameValuePairs?.originalID && reportNameValuePairs?.origin === 'harvest'; +} + +/** + * Returns the original reportID for a harvest-created report + */ +function getHarvestOriginalReportID(reportNameValuePairs?: OnyxInputOrEntry): string | undefined { + if (!isHarvestCreatedExpenseReport(reportNameValuePairs)) { + return undefined; + } + return reportNameValuePairs?.originalID; +} + /** * Whether the report with the provided reportID is an archived non-expense report */ @@ -10827,7 +10844,8 @@ function getReportActionActorAccountID( case CONST.REPORT.ACTIONS.TYPE.SUBMITTED: case CONST.REPORT.ACTIONS.TYPE.SUBMITTED_AND_CLOSED: return reportAction?.adminAccountID ?? reportAction?.actorAccountID; - + case CONST.REPORT.ACTIONS.TYPE.CREATED: + return CONST.ACCOUNT_ID.CONCIERGE; default: return reportAction?.actorAccountID; } @@ -12747,6 +12765,7 @@ export { goBackFromPrivateNotes, getInvoicePayerName, getInvoicesChatName, + getHarvestOriginalReportID, getPayeeName, getReportSummariesForEmptyCheck, reportSummariesOnyxSelector, @@ -12808,6 +12827,7 @@ export { isExpensifyOnlyParticipantInReport, isGroupChat, isGroupChatAdmin, + isHarvestCreatedExpenseReport, isGroupPolicy, isReportInGroupPolicy, isHoldCreator, diff --git a/src/types/onyx/ReportNameValuePairs.ts b/src/types/onyx/ReportNameValuePairs.ts index b43d7cf0ea90..82dc02b12103 100644 --- a/src/types/onyx/ReportNameValuePairs.ts +++ b/src/types/onyx/ReportNameValuePairs.ts @@ -58,6 +58,12 @@ type ReportNameValuePairs = OnyxCommon.OnyxValueWithOfflineFeedback<{ /** Whether the report is an archived room */ private_isArchived?: string; + /** Identifies where the report originated from */ + origin?: string; + + /** Original reportID that spawned the current report */ + originalID?: string; + /** Scheduled calls for the user on #admin rooms */ calendlyCalls?: CalendlyCall[]; From ce2692035ae4dbc29252d7f8b950a220bd99d374 Mon Sep 17 00:00:00 2001 From: VH Date: Wed, 19 Nov 2025 15:57:09 +0700 Subject: [PATCH 02/36] Display created action for harvest expense reports --- .../MoneyRequestReportActionsList.tsx | 9 ++++++--- src/languages/en.ts | 2 ++ src/languages/params.ts | 5 +++++ src/libs/MoneyRequestReportUtils.ts | 7 +++++-- src/pages/home/report/PureReportActionItem.tsx | 15 +++++++++++++-- .../home/report/ReportActionsListItemRenderer.tsx | 7 ++++++- 6 files changed, 37 insertions(+), 8 deletions(-) diff --git a/src/components/MoneyRequestReportView/MoneyRequestReportActionsList.tsx b/src/components/MoneyRequestReportView/MoneyRequestReportActionsList.tsx index ac77aa36ffec..f84236806aff 100644 --- a/src/components/MoneyRequestReportView/MoneyRequestReportActionsList.tsx +++ b/src/components/MoneyRequestReportView/MoneyRequestReportActionsList.tsx @@ -51,7 +51,7 @@ import { shouldReportActionBeVisible, wasMessageReceivedWhileOffline, } from '@libs/ReportActionsUtils'; -import {canUserPerformWriteAction, chatIncludesChronosWithID, getOriginalReportID, getReportLastVisibleActionCreated, isUnread} from '@libs/ReportUtils'; +import {canUserPerformWriteAction, chatIncludesChronosWithID, getOriginalReportID, getReportLastVisibleActionCreated, isHarvestCreatedExpenseReport, isUnread} from '@libs/ReportUtils'; import markOpenReportEnd from '@libs/telemetry/markOpenReportEnd'; import {isTransactionPendingDelete} from '@libs/TransactionUtils'; import Visibility from '@libs/Visibility'; @@ -168,6 +168,8 @@ function MoneyRequestReportActionsList({ const {shouldUseNarrowLayout} = useResponsiveLayout(); const [session] = useOnyx(ONYXKEYS.SESSION, {canBeMissing: false}); + const [reportNameValuePairs] = useOnyx(`${ONYXKEYS.COLLECTION.REPORT_NAME_VALUE_PAIRS}${getNonEmptyStringOnyxID(reportID)}`, {canBeMissing: true}); + const shouldShowHarvestCreatedAction = isHarvestCreatedExpenseReport(reportNameValuePairs); const [offlineModalVisible, setOfflineModalVisible] = useState(false); const [isDownloadErrorModalVisible, setIsDownloadErrorModalVisible] = useState(false); const [enableScrollToEnd, setEnableScrollToEnd] = useState(false); @@ -215,7 +217,7 @@ function MoneyRequestReportActionsList({ // We are reversing actions because in this View we are starting at the top and don't use Inverted list const visibleReportActions = useMemo(() => { const filteredActions = reportActions.filter((reportAction) => { - const isActionVisibleOnMoneyReport = isActionVisibleOnMoneyRequestReport(reportAction); + const isActionVisibleOnMoneyReport = isActionVisibleOnMoneyRequestReport(reportAction, shouldShowHarvestCreatedAction); return ( isActionVisibleOnMoneyReport && @@ -226,7 +228,7 @@ function MoneyRequestReportActionsList({ }); return filteredActions.toReversed(); - }, [reportActions, isOffline, canPerformWriteAction, reportTransactionIDs]); + }, [reportActions, isOffline, canPerformWriteAction, reportTransactionIDs, shouldShowHarvestCreatedAction]); const reportActionSize = useRef(visibleReportActions.length); const lastAction = visibleReportActions.at(-1); @@ -571,6 +573,7 @@ function MoneyRequestReportActionsList({ isReportArchived={isReportArchived} draftMessage={matchingDraftMessageString} isTryNewDotNVPDismissed={isTryNewDotNVPDismissed} + reportNameValuePairs={reportNameValuePairs} /> ); }, diff --git a/src/languages/en.ts b/src/languages/en.ts index 86ffa35a4329..0deae778f9b8 100755 --- a/src/languages/en.ts +++ b/src/languages/en.ts @@ -108,6 +108,7 @@ import type { FocusModeUpdateParams, FormattedMaxLengthParams, GoBackMessageParams, + HarvestCreatedExpenseReportParams, ImportedTagsMessageParams, ImportedTypesParams, ImportFieldParams, @@ -964,6 +965,7 @@ const translations = { adminOnlyCanPost: 'Only admins can send messages in this room.', reportAction: { asCopilot: 'as copilot for', + harvestCreatedExpenseReport: ({reportID}: HarvestCreatedExpenseReportParams) => `created this report to hold all expenses from #${reportID} that couldn't be submitted on your chosen frequency`, }, mentionSuggestions: { hereAlternateText: 'Notify everyone in this conversation', diff --git a/src/languages/params.ts b/src/languages/params.ts index 77ad01f58b1e..d37874ae1229 100644 --- a/src/languages/params.ts +++ b/src/languages/params.ts @@ -136,6 +136,10 @@ type ReportArchiveReasonsInvoiceReceiverPolicyDeletedParams = { policyName: string; }; +type HarvestCreatedExpenseReportParams = { + reportID: string; +}; + type DuplicateTransactionParams = { isSubmitted: boolean; }; @@ -1099,6 +1103,7 @@ export type { ReportArchiveReasonsMergedParams, ReportPolicyNameParams, ReportArchiveReasonsInvoiceReceiverPolicyDeletedParams, + HarvestCreatedExpenseReportParams, ReportArchiveReasonsRemovedFromPolicyParams, RequestAmountParams, RequestCountParams, diff --git a/src/libs/MoneyRequestReportUtils.ts b/src/libs/MoneyRequestReportUtils.ts index 248c2ea890b2..5cf71ce74b38 100644 --- a/src/libs/MoneyRequestReportUtils.ts +++ b/src/libs/MoneyRequestReportUtils.ts @@ -30,13 +30,16 @@ const IOU_ACTIONS_TO_FILTER_OUT = new Set([CONST.IOU * at the top the report, instead of in-between the rest of messages like in normal chat. * Because of that several action types are not relevant to this ReportView and should not be shown. */ -function isActionVisibleOnMoneyRequestReport(action: ReportAction) { +function isActionVisibleOnMoneyRequestReport(action: ReportAction, shouldShowCreatedActions = false) { if (isMoneyRequestAction(action)) { const originalMessage = getOriginalMessage(action); return originalMessage ? !IOU_ACTIONS_TO_FILTER_OUT.has(originalMessage.type) : false; } + if (action.actionName === CONST.REPORT.ACTIONS.TYPE.CREATED) { + return shouldShowCreatedActions; + } - return action.actionName !== CONST.REPORT.ACTIONS.TYPE.CREATED; + return true; } /** diff --git a/src/pages/home/report/PureReportActionItem.tsx b/src/pages/home/report/PureReportActionItem.tsx index 277af9630920..6f1e71d74c6f 100644 --- a/src/pages/home/report/PureReportActionItem.tsx +++ b/src/pages/home/report/PureReportActionItem.tsx @@ -146,6 +146,7 @@ import { getDeletedTransactionMessage, getDisplayNamesWithTooltips, getDowngradeWorkspaceMessage, + getHarvestOriginalReportID, getMovedActionMessage, getMovedTransactionMessage, getPolicyChangeMessage, @@ -158,6 +159,7 @@ import { isChatThread, isCompletedTaskReport, isExpenseReport, + isHarvestCreatedExpenseReport as isHarvestCreatedExpenseReportUtils, isTaskReport, shouldDisplayThreadReplies as shouldDisplayThreadRepliesUtils, } from '@libs/ReportUtils'; @@ -392,6 +394,9 @@ type PureReportActionItemProps = { /** The bank account list */ bankAccountList?: OnyxTypes.BankAccountList | undefined; + + /** Report name value pairs */ + reportNameValuePairs?: OnyxEntry; }; // This is equivalent to returning a negative boolean in normal functions, but we can keep the element return type @@ -460,6 +465,7 @@ function PureReportActionItem({ isTryNewDotNVPDismissed = false, currentUserAccountID, bankAccountList, + reportNameValuePairs, }: PureReportActionItemProps) { const actionSheetAwareScrollViewContext = useContext(ActionSheetAwareScrollView.ActionSheetAwareScrollViewContext); const {translate, formatPhoneNumber, localeCompare, formatTravelDate, getLocalDateFromDatetime} = useLocalize(); @@ -489,6 +495,7 @@ function PureReportActionItem({ isActionableMentionWhisper(action) || isActionableMentionInviteToSubmitExpenseConfirmWhisper(action) || isActionableTrackExpense(action) || isActionableReportMentionWhisper(action); const isReportArchived = useReportIsArchived(reportID); const isOriginalReportArchived = useReportIsArchived(originalReportID); + const isHarvestCreatedExpenseReport = isHarvestCreatedExpenseReportUtils(reportNameValuePairs); const highlightedBackgroundColorIfNeeded = useMemo( // eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing @@ -1405,6 +1412,9 @@ function PureReportActionItem({ children = ; } else if (isActionOfType(action, CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.UPDATE_MANUAL_APPROVAL_THRESHOLD)) { children = ; + } else if (isActionOfType(action, CONST.REPORT.ACTIONS.TYPE.CREATED) && isHarvestCreatedExpenseReport) { + const harvestOriginalReportID = getHarvestOriginalReportID(reportNameValuePairs); + children = ; } else if (isActionableMentionWhisper(action)) { children = ( @@ -1590,7 +1600,7 @@ function PureReportActionItem({ return {content}; }; - if (action.actionName === CONST.REPORT.ACTIONS.TYPE.CREATED) { + if (action.actionName === CONST.REPORT.ACTIONS.TYPE.CREATED && !isHarvestCreatedExpenseReport) { const transactionID = isMoneyRequestAction(parentReportActionForTransactionThread) ? getOriginalMessage(parentReportActionForTransactionThread)?.IOUTransactionID : undefined; return ( @@ -1850,6 +1860,7 @@ export default memo(PureReportActionItem, (prevProps, nextProps) => { prevProps.userBillingFundID === nextProps.userBillingFundID && deepEqual(prevProps.taskReport, nextProps.taskReport) && prevProps.shouldHighlight === nextProps.shouldHighlight && - deepEqual(prevProps.bankAccountList, nextProps.bankAccountList) + deepEqual(prevProps.bankAccountList, nextProps.bankAccountList) && + deepEqual(prevProps.reportNameValuePairs, nextProps.reportNameValuePairs) ); }); diff --git a/src/pages/home/report/ReportActionsListItemRenderer.tsx b/src/pages/home/report/ReportActionsListItemRenderer.tsx index ddaf25718a7c..fcdda3d5d184 100644 --- a/src/pages/home/report/ReportActionsListItemRenderer.tsx +++ b/src/pages/home/report/ReportActionsListItemRenderer.tsx @@ -3,7 +3,7 @@ import type {OnyxCollection, OnyxEntry} from 'react-native-onyx'; import {getOriginalMessage, isSentMoneyReportAction, isTransactionThread} from '@libs/ReportActionsUtils'; import {isChatThread} from '@libs/ReportUtils'; import CONST from '@src/CONST'; -import type {PersonalDetailsList, Policy, Report, ReportAction, ReportActionReactions, ReportActionsDrafts, Transaction} from '@src/types/onyx'; +import type {PersonalDetailsList, Policy, Report, ReportAction, ReportActionReactions, ReportActionsDrafts, ReportNameValuePairs, Transaction} from '@src/types/onyx'; import type {Errors} from '@src/types/onyx/OnyxCommon'; import ReportActionItem from './ReportActionItem'; import ReportActionItemParentAction from './ReportActionItemParentAction'; @@ -97,6 +97,9 @@ type ReportActionsListItemRendererProps = { isTryNewDotNVPDismissed: boolean | undefined; /** Whether the report is archived */ isReportArchived: boolean; + + /** Report name value pairs */ + reportNameValuePairs?: OnyxEntry; }; function ReportActionsListItemRenderer({ @@ -130,6 +133,7 @@ function ReportActionsListItemRenderer({ allEmojiReactions, isTryNewDotNVPDismissed = false, isReportArchived = false, + reportNameValuePairs, }: ReportActionsListItemRendererProps) { const originalMessage = useMemo(() => getOriginalMessage(reportAction), [reportAction]); @@ -260,6 +264,7 @@ function ReportActionsListItemRenderer({ linkedTransactionRouteError={linkedTransactionRouteError} userBillingFundID={userBillingFundID} isTryNewDotNVPDismissed={isTryNewDotNVPDismissed} + reportNameValuePairs={reportNameValuePairs} /> ); } From dbf6eeb0d1ed28c102849442234b288898939d6f Mon Sep 17 00:00:00 2001 From: VH Date: Wed, 19 Nov 2025 15:59:40 +0700 Subject: [PATCH 03/36] Fix translation key --- src/pages/home/report/PureReportActionItem.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pages/home/report/PureReportActionItem.tsx b/src/pages/home/report/PureReportActionItem.tsx index 6f1e71d74c6f..2eaa1dc540a7 100644 --- a/src/pages/home/report/PureReportActionItem.tsx +++ b/src/pages/home/report/PureReportActionItem.tsx @@ -1414,7 +1414,7 @@ function PureReportActionItem({ children = ; } else if (isActionOfType(action, CONST.REPORT.ACTIONS.TYPE.CREATED) && isHarvestCreatedExpenseReport) { const harvestOriginalReportID = getHarvestOriginalReportID(reportNameValuePairs); - children = ; + children = ; } else if (isActionableMentionWhisper(action)) { children = ( From a2f2bde39481b2268578631e60f56958722ef87f Mon Sep 17 00:00:00 2001 From: VH Date: Thu, 20 Nov 2025 15:08:49 +0700 Subject: [PATCH 04/36] only return CONCIERGE ID for harvest created expense report --- src/libs/ReportUtils.ts | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/libs/ReportUtils.ts b/src/libs/ReportUtils.ts index 49cd9bea8111..be59e018a054 100644 --- a/src/libs/ReportUtils.ts +++ b/src/libs/ReportUtils.ts @@ -10844,8 +10844,13 @@ function getReportActionActorAccountID( case CONST.REPORT.ACTIONS.TYPE.SUBMITTED: case CONST.REPORT.ACTIONS.TYPE.SUBMITTED_AND_CLOSED: return reportAction?.adminAccountID ?? reportAction?.actorAccountID; - case CONST.REPORT.ACTIONS.TYPE.CREATED: - return CONST.ACCOUNT_ID.CONCIERGE; + case CONST.REPORT.ACTIONS.TYPE.CREATED: { + const reportNameValuePairs = allReportNameValuePair?.[`${ONYXKEYS.COLLECTION.REPORT_NAME_VALUE_PAIRS}${report?.reportID}`]; + if (isHarvestCreatedExpenseReport(reportNameValuePairs)) { + return CONST.ACCOUNT_ID.CONCIERGE; + } + return reportAction?.actorAccountID; + } default: return reportAction?.actorAccountID; } From a5c5f9d06ebbf9cb83cca9e1126895c08172d69e Mon Sep 17 00:00:00 2001 From: VH Date: Thu, 20 Nov 2025 15:11:19 +0700 Subject: [PATCH 05/36] Fix bug, incorrect report id --- src/libs/ReportUtils.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libs/ReportUtils.ts b/src/libs/ReportUtils.ts index be59e018a054..472d07262ee9 100644 --- a/src/libs/ReportUtils.ts +++ b/src/libs/ReportUtils.ts @@ -10845,7 +10845,7 @@ function getReportActionActorAccountID( case CONST.REPORT.ACTIONS.TYPE.SUBMITTED_AND_CLOSED: return reportAction?.adminAccountID ?? reportAction?.actorAccountID; case CONST.REPORT.ACTIONS.TYPE.CREATED: { - const reportNameValuePairs = allReportNameValuePair?.[`${ONYXKEYS.COLLECTION.REPORT_NAME_VALUE_PAIRS}${report?.reportID}`]; + const reportNameValuePairs = allReportNameValuePair?.[`${ONYXKEYS.COLLECTION.REPORT_NAME_VALUE_PAIRS}${iouReport?.reportID}`]; if (isHarvestCreatedExpenseReport(reportNameValuePairs)) { return CONST.ACCOUNT_ID.CONCIERGE; } From 8967b602f8addcee7aea505b313d9cd6e35a3332 Mon Sep 17 00:00:00 2001 From: VH Date: Thu, 20 Nov 2025 15:23:47 +0700 Subject: [PATCH 06/36] Add tests for harvest-created reports and CREATED action visibility --- tests/unit/ReportUtilsTest.ts | 64 ++++++++++++++++++++++ tests/unit/libs/MoneyRequestReportUtils.ts | 21 ++++++- 2 files changed, 84 insertions(+), 1 deletion(-) diff --git a/tests/unit/ReportUtilsTest.ts b/tests/unit/ReportUtilsTest.ts index 1acf4cc5fbc4..48799d7bb2e7 100644 --- a/tests/unit/ReportUtilsTest.ts +++ b/tests/unit/ReportUtilsTest.ts @@ -54,6 +54,7 @@ import { getDefaultWorkspaceAvatar, getDisplayNamesWithTooltips, getGroupChatName, + getHarvestOriginalReportID, getIconsForParticipants, getIOUReportActionDisplayMessage, getMoneyReportPreviewName, @@ -81,6 +82,7 @@ import { isChatUsedForOnboarding, isClosedExpenseReportWithNoExpenses, isDeprecatedGroupDM, + isHarvestCreatedExpenseReport, isMoneyRequestReportEligibleForMerge, isPayer, isReportOutstanding, @@ -789,6 +791,25 @@ describe('ReportUtils', () => { }); }); + describe('Harvest-created reports', () => { + test('detects harvest-created report from name value pairs', () => { + const reportNameValuePairs = { + origin: 'harvest', + originalID: '12345', + }; + + expect(isHarvestCreatedExpenseReport(reportNameValuePairs)).toBe(true); + expect(getHarvestOriginalReportID(reportNameValuePairs)).toBe('12345'); + }); + + test('returns false when origin or originalID missing', () => { + expect(isHarvestCreatedExpenseReport(undefined)).toBe(false); + expect(isHarvestCreatedExpenseReport({origin: 'harvest'})).toBe(false); + expect(isHarvestCreatedExpenseReport({originalID: '123'})).toBe(false); + expect(getHarvestOriginalReportID({origin: 'harvest'})).toBeUndefined(); + }); + }); + describe('PolicyExpenseChat', () => { describe('Active', () => { test('as member', () => { @@ -8516,6 +8537,49 @@ describe('ReportUtils', () => { const actorAccountID = getReportActionActorAccountID(reportAction, iouReport, report); expect(actorAccountID).toEqual(123); }); + + it('returns CONCIERGE for CREATED action when report is harvest-created', async () => { + const reportAction: ReportAction = { + ...createRandomReportAction(0), + actionName: CONST.REPORT.ACTIONS.TYPE.CREATED, + actorAccountID: 9999, + }; + + const iouReport: Report = {...createRandomReport(0, undefined)}; + const report: Report = { + ...createRandomReport(1, undefined), + reportID: 'harvest-report-1', + }; + + await Onyx.merge(`${ONYXKEYS.COLLECTION.REPORT_NAME_VALUE_PAIRS}${iouReport.reportID}`, { + origin: 'harvest', + originalID: 'orig-123', + }); + await waitForBatchedUpdates(); + + const actorAccountID = getReportActionActorAccountID(reportAction, iouReport, report); + expect(actorAccountID).toBe(CONST.ACCOUNT_ID.CONCIERGE); + }); + + it('returns reportAction.actorAccountID for CREATED action when not harvest-created', async () => { + const reportAction: ReportAction = { + ...createRandomReportAction(0), + actionName: CONST.REPORT.ACTIONS.TYPE.CREATED, + actorAccountID: 9999, + }; + + const iouReport: Report = {...createRandomReport(0, undefined)}; + const report: Report = { + ...createRandomReport(2, undefined), + reportID: 'normal-report-2', + }; + + await Onyx.set(`${ONYXKEYS.COLLECTION.REPORT_NAME_VALUE_PAIRS}${iouReport.reportID}`, {}); + await waitForBatchedUpdates(); + + const actorAccountID = getReportActionActorAccountID(reportAction, iouReport, report); + expect(actorAccountID).toBe(9999); + }); }); describe('shouldBlockSubmitDueToStrictPolicyRules', () => { diff --git a/tests/unit/libs/MoneyRequestReportUtils.ts b/tests/unit/libs/MoneyRequestReportUtils.ts index c8eafb6c8f93..7a24d55913fd 100644 --- a/tests/unit/libs/MoneyRequestReportUtils.ts +++ b/tests/unit/libs/MoneyRequestReportUtils.ts @@ -1,4 +1,5 @@ -import {getThreadReportIDsForTransactions} from '@libs/MoneyRequestReportUtils'; +import {getThreadReportIDsForTransactions, isActionVisibleOnMoneyRequestReport} from '@libs/MoneyRequestReportUtils'; +import CONST from '@src/CONST'; import type {ReportAction, Transaction} from '@src/types/onyx'; import {actionR14932, actionR98765} from '../../../__mocks__/reportData/actions'; import {transactionR14932, transactionR98765} from '../../../__mocks__/reportData/transactions'; @@ -31,3 +32,21 @@ describe('getThreadReportIDsForTransactions', () => { expect(result).toEqual([]); }); }); + +describe('isActionVisibleOnMoneyRequestReport', () => { + test('hides created action by default', () => { + const createdAction = { + actionName: CONST.REPORT.ACTIONS.TYPE.CREATED, + } as ReportAction; + + expect(isActionVisibleOnMoneyRequestReport(createdAction)).toBe(false); + }); + + test('shows created action when explicitly allowed', () => { + const createdAction = { + actionName: CONST.REPORT.ACTIONS.TYPE.CREATED, + } as ReportAction; + + expect(isActionVisibleOnMoneyRequestReport(createdAction, true)).toBe(true); + }); +}); From 9ba217216dbcf74f6b633cf7bab1d618fb31e6b6 Mon Sep 17 00:00:00 2001 From: VH Date: Thu, 20 Nov 2025 15:49:34 +0700 Subject: [PATCH 07/36] Context menu: copy harvest-created CREATED action as localized summary; pass reportNameValuePairs to payload --- .../BaseReportActionContextMenu.tsx | 2 ++ .../report/ContextMenu/ContextMenuActions.tsx | 22 ++++++++++++++++++- .../home/report/PureReportActionItem.tsx | 2 +- 3 files changed, 24 insertions(+), 2 deletions(-) diff --git a/src/pages/home/report/ContextMenu/BaseReportActionContextMenu.tsx b/src/pages/home/report/ContextMenu/BaseReportActionContextMenu.tsx index 0ba3843d94fa..29eb6b67082d 100755 --- a/src/pages/home/report/ContextMenu/BaseReportActionContextMenu.tsx +++ b/src/pages/home/report/ContextMenu/BaseReportActionContextMenu.tsx @@ -156,6 +156,7 @@ function BaseReportActionContextMenu({ const [transaction] = useOnyx(`${ONYXKEYS.COLLECTION.TRANSACTION}${getNonEmptyStringOnyxID(transactionID)}`, {canBeMissing: true}); const [isDebugModeEnabled] = useOnyx(ONYXKEYS.IS_DEBUG_MODE_ENABLED, {canBeMissing: true}); const [report] = useOnyx(`${ONYXKEYS.COLLECTION.REPORT}${reportID}`, {canBeMissing: true}); + const [reportNameValuePairs] = useOnyx(`${ONYXKEYS.COLLECTION.REPORT_NAME_VALUE_PAIRS}${reportID}`, {canBeMissing: true}); const [originalReport] = useOnyx(`${ONYXKEYS.COLLECTION.REPORT}${originalReportID}`, {canBeMissing: true}); const isOriginalReportArchived = useReportIsArchived(originalReportID); const policyID = report?.policyID; @@ -364,6 +365,7 @@ function BaseReportActionContextMenu({ interceptAnonymousUser, openOverflowMenu, setIsEmojiPickerActive, + reportNameValuePairs, moneyRequestAction, card, originalReport, diff --git a/src/pages/home/report/ContextMenu/ContextMenuActions.tsx b/src/pages/home/report/ContextMenu/ContextMenuActions.tsx index 6b45dc75caa6..da3af1cf663a 100644 --- a/src/pages/home/report/ContextMenu/ContextMenuActions.tsx +++ b/src/pages/home/report/ContextMenu/ContextMenuActions.tsx @@ -104,6 +104,7 @@ import { getChildReportNotificationPreference as getChildReportNotificationPreferenceReportUtils, getDeletedTransactionMessage, getDowngradeWorkspaceMessage, + getHarvestOriginalReportID, getIOUReportActionDisplayMessage, getMovedActionMessage, getOriginalReportID, @@ -117,6 +118,7 @@ import { getUpgradeWorkspaceMessage, getWorkspaceNameUpdatedMessage, isExpenseReport, + isHarvestCreatedExpenseReport, shouldDisableThread, shouldDisplayThreadReplies as shouldDisplayThreadRepliesReportUtils, } from '@libs/ReportUtils'; @@ -136,7 +138,19 @@ import { import CONST from '@src/CONST'; import type {TranslationPaths} from '@src/languages/types'; import ROUTES from '@src/ROUTES'; -import type {Beta, Card, Download as DownloadOnyx, OnyxInputOrEntry, Policy, PolicyTagLists, ReportAction, ReportActionReactions, Report as ReportType, Transaction} from '@src/types/onyx'; +import type { + Beta, + Card, + Download as DownloadOnyx, + OnyxInputOrEntry, + Policy, + PolicyTagLists, + ReportAction, + ReportActionReactions, + ReportNameValuePairs, + Report as ReportType, + Transaction, +} from '@src/types/onyx'; import type IconAsset from '@src/types/utils/IconAsset'; import KeyboardUtils from '@src/utils/keyboard'; import type {ContextMenuAnchor} from './ReportActionContextMenu'; @@ -207,6 +221,7 @@ type ContextMenuActionPayload = { moneyRequestAction: ReportAction | undefined; card?: Card; originalReport: OnyxEntry; + reportNameValuePairs?: OnyxEntry; isTryNewDotNVPDismissed?: boolean; childReport?: OnyxEntry; movedFromReport?: OnyxEntry; @@ -531,6 +546,7 @@ const ContextMenuActions: ContextMenuAction[] = [ reportID, card, originalReport, + reportNameValuePairs, isTryNewDotNVPDismissed, movedFromReport, movedToReport, @@ -748,6 +764,10 @@ const ContextMenuActions: ContextMenuAction[] = [ } else if (isActionableJoinRequest(reportAction)) { const displayMessage = getJoinRequestMessage(reportAction); Clipboard.setString(displayMessage); + } else if (isActionOfType(reportAction, CONST.REPORT.ACTIONS.TYPE.CREATED) && isHarvestCreatedExpenseReport(reportNameValuePairs)) { + const harvestOriginalReportID = getHarvestOriginalReportID(reportNameValuePairs) ?? ''; + const displayMessage = translate('reportAction.harvestCreatedExpenseReport', {reportID: harvestOriginalReportID}); + setClipboardMessage(displayMessage); } else if (content) { setClipboardMessage( content.replaceAll(/()(.*?)(<\/mention-user>)/gi, (match, openTag: string, innerContent: string, closeTag: string): string => { diff --git a/src/pages/home/report/PureReportActionItem.tsx b/src/pages/home/report/PureReportActionItem.tsx index 2eaa1dc540a7..7194e1dc0511 100644 --- a/src/pages/home/report/PureReportActionItem.tsx +++ b/src/pages/home/report/PureReportActionItem.tsx @@ -1413,7 +1413,7 @@ function PureReportActionItem({ } else if (isActionOfType(action, CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.UPDATE_MANUAL_APPROVAL_THRESHOLD)) { children = ; } else if (isActionOfType(action, CONST.REPORT.ACTIONS.TYPE.CREATED) && isHarvestCreatedExpenseReport) { - const harvestOriginalReportID = getHarvestOriginalReportID(reportNameValuePairs); + const harvestOriginalReportID = getHarvestOriginalReportID(reportNameValuePairs) ?? ''; children = ; } else if (isActionableMentionWhisper(action)) { children = ( From 793e382aab88d7718e6f0f0eadae335cffaf7cb4 Mon Sep 17 00:00:00 2001 From: VH Date: Thu, 20 Nov 2025 17:41:30 +0700 Subject: [PATCH 08/36] feat(i18n): add HarvestCreatedExpenseReportParams import and translations for harvestCreatedExpenseReport in all major languages --- src/languages/de.ts | 3 +++ src/languages/en.ts | 3 ++- src/languages/es.ts | 4 +++- src/languages/fr.ts | 3 +++ src/languages/it.ts | 3 +++ src/languages/ja.ts | 3 +++ src/languages/nl.ts | 3 +++ src/languages/pl.ts | 3 +++ src/languages/pt-BR.ts | 3 +++ src/languages/zh-hans.ts | 2 ++ 10 files changed, 28 insertions(+), 2 deletions(-) diff --git a/src/languages/de.ts b/src/languages/de.ts index 6ee628ce4b41..7a42d968847d 100644 --- a/src/languages/de.ts +++ b/src/languages/de.ts @@ -119,6 +119,7 @@ import type { FocusModeUpdateParams, FormattedMaxLengthParams, GoBackMessageParams, + HarvestCreatedExpenseReportParams, ImportedTagsMessageParams, ImportedTypesParams, ImportFieldParams, @@ -975,6 +976,8 @@ const translations: TranslationDeepObject = { adminOnlyCanPost: 'Nur Administratoren können Nachrichten in diesem Raum senden.', reportAction: { asCopilot: 'als Co-Pilot für', + harvestCreatedExpenseReport: ({reportID}: HarvestCreatedExpenseReportParams) => + `hat diesen Bericht erstellt, um alle Ausgaben aus #${reportID} aufzunehmen, die mit der von dir gewählten Frequenz nicht eingereicht werden konnten`, }, mentionSuggestions: { hereAlternateText: 'Benachrichtige alle in diesem Gespräch', diff --git a/src/languages/en.ts b/src/languages/en.ts index 0deae778f9b8..47a925484499 100755 --- a/src/languages/en.ts +++ b/src/languages/en.ts @@ -965,7 +965,8 @@ const translations = { adminOnlyCanPost: 'Only admins can send messages in this room.', reportAction: { asCopilot: 'as copilot for', - harvestCreatedExpenseReport: ({reportID}: HarvestCreatedExpenseReportParams) => `created this report to hold all expenses from #${reportID} that couldn't be submitted on your chosen frequency`, + harvestCreatedExpenseReport: ({reportID}: HarvestCreatedExpenseReportParams) => + `created this report to hold all expenses from #${reportID} that couldn't be submitted on your chosen frequency`, }, mentionSuggestions: { hereAlternateText: 'Notify everyone in this conversation', diff --git a/src/languages/es.ts b/src/languages/es.ts index b96ee87a3fce..a40b403b50fb 100644 --- a/src/languages/es.ts +++ b/src/languages/es.ts @@ -2,7 +2,7 @@ import {CONST as COMMON_CONST} from 'expensify-common'; import dedent from '@libs/StringUtils/dedent'; import CONST from '@src/CONST'; import type en from './en'; -import type {ViolationsRterParams} from './params'; +import type {HarvestCreatedExpenseReportParams, ViolationsRterParams} from './params'; import type {TranslationDeepObject} from './types'; /* eslint-disable max-len */ @@ -630,6 +630,8 @@ const translations: TranslationDeepObject = { adminOnlyCanPost: 'Solo los administradores pueden enviar mensajes en esta sala.', reportAction: { asCopilot: 'como copiloto de', + harvestCreatedExpenseReport: ({reportID}: HarvestCreatedExpenseReportParams) => + `creó este informe para contener todos los gastos de #${reportID} que no se pudieron enviar con la frecuencia que elegiste`, }, mentionSuggestions: { hereAlternateText: 'Notificar a todos en esta conversación', diff --git a/src/languages/fr.ts b/src/languages/fr.ts index 4f5ee5d17dee..f87332eb5ef3 100644 --- a/src/languages/fr.ts +++ b/src/languages/fr.ts @@ -119,6 +119,7 @@ import type { FocusModeUpdateParams, FormattedMaxLengthParams, GoBackMessageParams, + HarvestCreatedExpenseReportParams, ImportedTagsMessageParams, ImportedTypesParams, ImportFieldParams, @@ -977,6 +978,8 @@ const translations: TranslationDeepObject = { adminOnlyCanPost: 'Seuls les administrateurs peuvent envoyer des messages dans cette salle.', reportAction: { asCopilot: 'en tant que copilote pour', + harvestCreatedExpenseReport: ({reportID}: HarvestCreatedExpenseReportParams) => + `a créé ce rapport pour regrouper toutes les dépenses de #${reportID} qui n'ont pas pu être soumises selon la fréquence que vous avez choisie`, }, mentionSuggestions: { hereAlternateText: 'Notifier tout le monde dans cette conversation', diff --git a/src/languages/it.ts b/src/languages/it.ts index 0e54f3daae13..2ef5a651bf27 100644 --- a/src/languages/it.ts +++ b/src/languages/it.ts @@ -119,6 +119,7 @@ import type { FocusModeUpdateParams, FormattedMaxLengthParams, GoBackMessageParams, + HarvestCreatedExpenseReportParams, ImportedTagsMessageParams, ImportedTypesParams, ImportFieldParams, @@ -974,6 +975,8 @@ const translations: TranslationDeepObject = { adminOnlyCanPost: 'Solo gli amministratori possono inviare messaggi in questa stanza.', reportAction: { asCopilot: 'come copilota per', + harvestCreatedExpenseReport: ({reportID}: HarvestCreatedExpenseReportParams) => + `ha creato questo rapporto per raccogliere tutte le spese di #${reportID} che non sono state inviate con la frequenza scelta`, }, mentionSuggestions: { hereAlternateText: 'Notifica tutti in questa conversazione', diff --git a/src/languages/ja.ts b/src/languages/ja.ts index 9efb79b3a78d..416e2a3166ec 100644 --- a/src/languages/ja.ts +++ b/src/languages/ja.ts @@ -119,6 +119,7 @@ import type { FocusModeUpdateParams, FormattedMaxLengthParams, GoBackMessageParams, + HarvestCreatedExpenseReportParams, ImportedTagsMessageParams, ImportedTypesParams, ImportFieldParams, @@ -975,6 +976,8 @@ const translations: TranslationDeepObject = { adminOnlyCanPost: 'このルームでは管理者のみがメッセージを送信できます。', reportAction: { asCopilot: 'のコパイロットとして', + harvestCreatedExpenseReport: ({reportID}: HarvestCreatedExpenseReportParams) => + `選択した頻度では提出できなかった #${reportID} のすべての経費をまとめるためにこのレポートを作成しました`, }, mentionSuggestions: { hereAlternateText: 'この会話の全員に通知する', diff --git a/src/languages/nl.ts b/src/languages/nl.ts index edf0a885378d..5cdee01d5f21 100644 --- a/src/languages/nl.ts +++ b/src/languages/nl.ts @@ -119,6 +119,7 @@ import type { FocusModeUpdateParams, FormattedMaxLengthParams, GoBackMessageParams, + HarvestCreatedExpenseReportParams, ImportedTagsMessageParams, ImportedTypesParams, ImportFieldParams, @@ -973,6 +974,8 @@ const translations: TranslationDeepObject = { adminOnlyCanPost: 'Alleen beheerders kunnen berichten sturen in deze ruimte.', reportAction: { asCopilot: 'als copiloot voor', + harvestCreatedExpenseReport: ({reportID}: HarvestCreatedExpenseReportParams) => + `heeft dit rapport aangemaakt om alle uitgaven van #${reportID} op te nemen die niet konden worden ingediend met de door jou gekozen frequentie`, }, mentionSuggestions: { hereAlternateText: 'Breng iedereen in dit gesprek op de hoogte', diff --git a/src/languages/pl.ts b/src/languages/pl.ts index d88381f33548..57dbe3aef7a7 100644 --- a/src/languages/pl.ts +++ b/src/languages/pl.ts @@ -119,6 +119,7 @@ import type { FocusModeUpdateParams, FormattedMaxLengthParams, GoBackMessageParams, + HarvestCreatedExpenseReportParams, ImportedTagsMessageParams, ImportedTypesParams, ImportFieldParams, @@ -974,6 +975,8 @@ const translations: TranslationDeepObject = { adminOnlyCanPost: 'Tylko administratorzy mogą wysyłać wiadomości w tym pokoju.', reportAction: { asCopilot: 'jako współpilot dla', + harvestCreatedExpenseReport: ({reportID}: HarvestCreatedExpenseReportParams) => + `utworzył ten raport, aby zawrzeć wszystkie wydatki z #${reportID}, które nie mogły zostać przesłane zgodnie z wybraną przez ciebie częstotliwością`, }, mentionSuggestions: { hereAlternateText: 'Powiadom wszystkich w tej rozmowie', diff --git a/src/languages/pt-BR.ts b/src/languages/pt-BR.ts index 39cf4d45f7af..ffae982a282d 100644 --- a/src/languages/pt-BR.ts +++ b/src/languages/pt-BR.ts @@ -119,6 +119,7 @@ import type { FocusModeUpdateParams, FormattedMaxLengthParams, GoBackMessageParams, + HarvestCreatedExpenseReportParams, ImportedTagsMessageParams, ImportedTypesParams, ImportFieldParams, @@ -972,6 +973,8 @@ const translations: TranslationDeepObject = { adminOnlyCanPost: 'Apenas administradores podem enviar mensagens nesta sala.', reportAction: { asCopilot: 'como copiloto para', + harvestCreatedExpenseReport: ({reportID}: HarvestCreatedExpenseReportParams) => + `criou este relatório para agrupar todas as despesas de #${reportID} que não puderam ser enviadas na frequência que você escolheu`, }, mentionSuggestions: { hereAlternateText: 'Notificar todos nesta conversa', diff --git a/src/languages/zh-hans.ts b/src/languages/zh-hans.ts index 7762508a518e..0cc87dae6686 100644 --- a/src/languages/zh-hans.ts +++ b/src/languages/zh-hans.ts @@ -119,6 +119,7 @@ import type { FocusModeUpdateParams, FormattedMaxLengthParams, GoBackMessageParams, + HarvestCreatedExpenseReportParams, ImportedTagsMessageParams, ImportedTypesParams, ImportFieldParams, @@ -966,6 +967,7 @@ const translations: TranslationDeepObject = { adminOnlyCanPost: '只有管理员可以在此房间发送消息。', reportAction: { asCopilot: '作为副驾驶', + harvestCreatedExpenseReport: ({reportID}: HarvestCreatedExpenseReportParams) => `创建了此报表以汇总 #${reportID} 中无法按您选择的频率提交的所有费用`, }, mentionSuggestions: { hereAlternateText: '通知此对话中的所有人', From bbfb1cbb2862fece4a8f94080315a9f2da7f5809 Mon Sep 17 00:00:00 2001 From: VH Date: Thu, 20 Nov 2025 17:41:41 +0700 Subject: [PATCH 09/36] Fix linter --- src/libs/DebugUtils.ts | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/libs/DebugUtils.ts b/src/libs/DebugUtils.ts index 41a8ef863247..4c78e952efa1 100644 --- a/src/libs/DebugUtils.ts +++ b/src/libs/DebugUtils.ts @@ -440,6 +440,8 @@ function validateReportDraftProperty(key: keyof Report | keyof ReportNameValuePa case 'preexistingReportID': case 'private_isArchived': case 'welcomeMessage': + case 'origin': + case 'originalID': return validateString(value); case 'hasOutstandingChildRequest': case 'hasOutstandingChildTask': From d55abefa5f71d628c60bf89a56b14c7adf7fa0dc Mon Sep 17 00:00:00 2001 From: VH Date: Thu, 20 Nov 2025 18:16:08 +0700 Subject: [PATCH 10/36] chore(i18n): include reportUrl in HarvestCreatedExpenseReportParams and update translations --- src/languages/de.ts | 4 ++-- src/languages/en.ts | 4 ++-- src/languages/es.ts | 4 ++-- src/languages/fr.ts | 4 ++-- src/languages/it.ts | 4 ++-- src/languages/ja.ts | 4 ++-- src/languages/nl.ts | 4 ++-- src/languages/params.ts | 1 + src/languages/pl.ts | 4 ++-- src/languages/pt-BR.ts | 4 ++-- src/languages/zh-hans.ts | 3 ++- src/libs/ReportActionsUtils.ts | 8 +++++++- src/pages/home/report/ContextMenu/ContextMenuActions.tsx | 4 ++-- src/pages/home/report/PureReportActionItem.tsx | 8 ++++++-- 14 files changed, 36 insertions(+), 24 deletions(-) diff --git a/src/languages/de.ts b/src/languages/de.ts index 7a42d968847d..a3e97b32a311 100644 --- a/src/languages/de.ts +++ b/src/languages/de.ts @@ -976,8 +976,8 @@ const translations: TranslationDeepObject = { adminOnlyCanPost: 'Nur Administratoren können Nachrichten in diesem Raum senden.', reportAction: { asCopilot: 'als Co-Pilot für', - harvestCreatedExpenseReport: ({reportID}: HarvestCreatedExpenseReportParams) => - `hat diesen Bericht erstellt, um alle Ausgaben aus #${reportID} aufzunehmen, die mit der von dir gewählten Frequenz nicht eingereicht werden konnten`, + harvestCreatedExpenseReport: ({reportUrl, reportID}: HarvestCreatedExpenseReportParams) => + `hat diesen Bericht erstellt, um alle Ausgaben aus #${reportID} aufzunehmen, die mit der von dir gewählten Frequenz nicht eingereicht werden konnten`, }, mentionSuggestions: { hereAlternateText: 'Benachrichtige alle in diesem Gespräch', diff --git a/src/languages/en.ts b/src/languages/en.ts index 47a925484499..9b59ac384893 100755 --- a/src/languages/en.ts +++ b/src/languages/en.ts @@ -965,8 +965,8 @@ const translations = { adminOnlyCanPost: 'Only admins can send messages in this room.', reportAction: { asCopilot: 'as copilot for', - harvestCreatedExpenseReport: ({reportID}: HarvestCreatedExpenseReportParams) => - `created this report to hold all expenses from #${reportID} that couldn't be submitted on your chosen frequency`, + harvestCreatedExpenseReport: ({reportUrl, reportID}: HarvestCreatedExpenseReportParams) => + `created this report to hold all expenses from #${reportID} that couldn't be submitted on your chosen frequency`, }, mentionSuggestions: { hereAlternateText: 'Notify everyone in this conversation', diff --git a/src/languages/es.ts b/src/languages/es.ts index a40b403b50fb..cf1323d067e9 100644 --- a/src/languages/es.ts +++ b/src/languages/es.ts @@ -630,8 +630,8 @@ const translations: TranslationDeepObject = { adminOnlyCanPost: 'Solo los administradores pueden enviar mensajes en esta sala.', reportAction: { asCopilot: 'como copiloto de', - harvestCreatedExpenseReport: ({reportID}: HarvestCreatedExpenseReportParams) => - `creó este informe para contener todos los gastos de #${reportID} que no se pudieron enviar con la frecuencia que elegiste`, + harvestCreatedExpenseReport: ({reportUrl, reportID}: HarvestCreatedExpenseReportParams) => + `creó este informe para contener todos los gastos de #${reportID} que no se pudieron enviar con la frecuencia que elegiste`, }, mentionSuggestions: { hereAlternateText: 'Notificar a todos en esta conversación', diff --git a/src/languages/fr.ts b/src/languages/fr.ts index f87332eb5ef3..cc7e84b99c09 100644 --- a/src/languages/fr.ts +++ b/src/languages/fr.ts @@ -978,8 +978,8 @@ const translations: TranslationDeepObject = { adminOnlyCanPost: 'Seuls les administrateurs peuvent envoyer des messages dans cette salle.', reportAction: { asCopilot: 'en tant que copilote pour', - harvestCreatedExpenseReport: ({reportID}: HarvestCreatedExpenseReportParams) => - `a créé ce rapport pour regrouper toutes les dépenses de #${reportID} qui n'ont pas pu être soumises selon la fréquence que vous avez choisie`, + harvestCreatedExpenseReport: ({reportUrl, reportID}: HarvestCreatedExpenseReportParams) => + `a créé ce rapport pour regrouper toutes les dépenses de #${reportID} qui n'ont pas pu être soumises selon la fréquence que vous avez choisie`, }, mentionSuggestions: { hereAlternateText: 'Notifier tout le monde dans cette conversation', diff --git a/src/languages/it.ts b/src/languages/it.ts index 2ef5a651bf27..0fbb3c229846 100644 --- a/src/languages/it.ts +++ b/src/languages/it.ts @@ -975,8 +975,8 @@ const translations: TranslationDeepObject = { adminOnlyCanPost: 'Solo gli amministratori possono inviare messaggi in questa stanza.', reportAction: { asCopilot: 'come copilota per', - harvestCreatedExpenseReport: ({reportID}: HarvestCreatedExpenseReportParams) => - `ha creato questo rapporto per raccogliere tutte le spese di #${reportID} che non sono state inviate con la frequenza scelta`, + harvestCreatedExpenseReport: ({reportUrl, reportID}: HarvestCreatedExpenseReportParams) => + `ha creato questo rapporto per raccogliere tutte le spese di #${reportID} che non sono state inviate con la frequenza scelta`, }, mentionSuggestions: { hereAlternateText: 'Notifica tutti in questa conversazione', diff --git a/src/languages/ja.ts b/src/languages/ja.ts index 416e2a3166ec..dd77690fa793 100644 --- a/src/languages/ja.ts +++ b/src/languages/ja.ts @@ -976,8 +976,8 @@ const translations: TranslationDeepObject = { adminOnlyCanPost: 'このルームでは管理者のみがメッセージを送信できます。', reportAction: { asCopilot: 'のコパイロットとして', - harvestCreatedExpenseReport: ({reportID}: HarvestCreatedExpenseReportParams) => - `選択した頻度では提出できなかった #${reportID} のすべての経費をまとめるためにこのレポートを作成しました`, + harvestCreatedExpenseReport: ({reportUrl, reportID}: HarvestCreatedExpenseReportParams) => + `選択した頻度では提出できなかった #${reportID} のすべての経費をまとめるためにこのレポートを作成しました`, }, mentionSuggestions: { hereAlternateText: 'この会話の全員に通知する', diff --git a/src/languages/nl.ts b/src/languages/nl.ts index 5cdee01d5f21..0c3406531a81 100644 --- a/src/languages/nl.ts +++ b/src/languages/nl.ts @@ -974,8 +974,8 @@ const translations: TranslationDeepObject = { adminOnlyCanPost: 'Alleen beheerders kunnen berichten sturen in deze ruimte.', reportAction: { asCopilot: 'als copiloot voor', - harvestCreatedExpenseReport: ({reportID}: HarvestCreatedExpenseReportParams) => - `heeft dit rapport aangemaakt om alle uitgaven van #${reportID} op te nemen die niet konden worden ingediend met de door jou gekozen frequentie`, + harvestCreatedExpenseReport: ({reportUrl, reportID}: HarvestCreatedExpenseReportParams) => + `heeft dit rapport aangemaakt om alle uitgaven van #${reportID} op te nemen die niet konden worden ingediend met de door jou gekozen frequentie`, }, mentionSuggestions: { hereAlternateText: 'Breng iedereen in dit gesprek op de hoogte', diff --git a/src/languages/params.ts b/src/languages/params.ts index d37874ae1229..bc6a8e5a1826 100644 --- a/src/languages/params.ts +++ b/src/languages/params.ts @@ -137,6 +137,7 @@ type ReportArchiveReasonsInvoiceReceiverPolicyDeletedParams = { }; type HarvestCreatedExpenseReportParams = { + reportUrl: string; reportID: string; }; diff --git a/src/languages/pl.ts b/src/languages/pl.ts index 57dbe3aef7a7..663cd6f2959e 100644 --- a/src/languages/pl.ts +++ b/src/languages/pl.ts @@ -975,8 +975,8 @@ const translations: TranslationDeepObject = { adminOnlyCanPost: 'Tylko administratorzy mogą wysyłać wiadomości w tym pokoju.', reportAction: { asCopilot: 'jako współpilot dla', - harvestCreatedExpenseReport: ({reportID}: HarvestCreatedExpenseReportParams) => - `utworzył ten raport, aby zawrzeć wszystkie wydatki z #${reportID}, które nie mogły zostać przesłane zgodnie z wybraną przez ciebie częstotliwością`, + harvestCreatedExpenseReport: ({reportUrl, reportID}: HarvestCreatedExpenseReportParams) => + `utworzył ten raport, aby zawrzeć wszystkie wydatki z #${reportID}, które nie mogły zostać przesłane zgodnie z wybraną przez ciebie częstotliwością`, }, mentionSuggestions: { hereAlternateText: 'Powiadom wszystkich w tej rozmowie', diff --git a/src/languages/pt-BR.ts b/src/languages/pt-BR.ts index ffae982a282d..174e7ee17abf 100644 --- a/src/languages/pt-BR.ts +++ b/src/languages/pt-BR.ts @@ -973,8 +973,8 @@ const translations: TranslationDeepObject = { adminOnlyCanPost: 'Apenas administradores podem enviar mensagens nesta sala.', reportAction: { asCopilot: 'como copiloto para', - harvestCreatedExpenseReport: ({reportID}: HarvestCreatedExpenseReportParams) => - `criou este relatório para agrupar todas as despesas de #${reportID} que não puderam ser enviadas na frequência que você escolheu`, + harvestCreatedExpenseReport: ({reportUrl, reportID}: HarvestCreatedExpenseReportParams) => + `criou este relatório para agrupar todas as despesas de #${reportID} que não puderam ser enviadas na frequência que você escolheu`, }, mentionSuggestions: { hereAlternateText: 'Notificar todos nesta conversa', diff --git a/src/languages/zh-hans.ts b/src/languages/zh-hans.ts index 0cc87dae6686..a04a9baf3020 100644 --- a/src/languages/zh-hans.ts +++ b/src/languages/zh-hans.ts @@ -967,7 +967,8 @@ const translations: TranslationDeepObject = { adminOnlyCanPost: '只有管理员可以在此房间发送消息。', reportAction: { asCopilot: '作为副驾驶', - harvestCreatedExpenseReport: ({reportID}: HarvestCreatedExpenseReportParams) => `创建了此报表以汇总 #${reportID} 中无法按您选择的频率提交的所有费用`, + harvestCreatedExpenseReport: ({reportUrl, reportID}: HarvestCreatedExpenseReportParams) => + `创建了此报表以汇总 #${reportID} 中无法按您选择的频率提交的所有费用`, }, mentionSuggestions: { hereAlternateText: '通知此对话中的所有人', diff --git a/src/libs/ReportActionsUtils.ts b/src/libs/ReportActionsUtils.ts index 1c410c9f71bf..c94dcd7b08ad 100644 --- a/src/libs/ReportActionsUtils.ts +++ b/src/libs/ReportActionsUtils.ts @@ -5,7 +5,7 @@ import isEmpty from 'lodash/isEmpty'; import type {NullishDeep, OnyxCollection, OnyxEntry, OnyxUpdate} from 'react-native-onyx'; import Onyx from 'react-native-onyx'; import type {ValueOf} from 'type-fest'; -import type {LocaleContextProps} from '@components/LocaleContextProvider'; +import type {LocaleContextProps, LocalizedTranslate} from '@components/LocaleContextProvider'; import usePrevious from '@hooks/usePrevious'; import CONST from '@src/CONST'; import IntlStore from '@src/languages/IntlStore'; @@ -3127,6 +3127,11 @@ function getChangedApproverActionMessage, ): reportAction is ReportAction< @@ -3499,6 +3504,7 @@ export { isPendingHide, filterOutDeprecatedReportActions, getActionableCardFraudAlertMessage, + getHarvestCreatedExpenseReportMessage, }; export type {LastVisibleMessage}; diff --git a/src/pages/home/report/ContextMenu/ContextMenuActions.tsx b/src/pages/home/report/ContextMenu/ContextMenuActions.tsx index da3af1cf663a..12406dce3b03 100644 --- a/src/pages/home/report/ContextMenu/ContextMenuActions.tsx +++ b/src/pages/home/report/ContextMenu/ContextMenuActions.tsx @@ -30,6 +30,7 @@ import { getChangedApproverActionMessage, getDeletedApprovalRuleMessage, getExportIntegrationMessageHTML, + getHarvestCreatedExpenseReportMessage, getIntegrationSyncFailedMessage, getIOUReportIDFromReportActionPreview, getJoinRequestMessage, @@ -765,8 +766,7 @@ const ContextMenuActions: ContextMenuAction[] = [ const displayMessage = getJoinRequestMessage(reportAction); Clipboard.setString(displayMessage); } else if (isActionOfType(reportAction, CONST.REPORT.ACTIONS.TYPE.CREATED) && isHarvestCreatedExpenseReport(reportNameValuePairs)) { - const harvestOriginalReportID = getHarvestOriginalReportID(reportNameValuePairs) ?? ''; - const displayMessage = translate('reportAction.harvestCreatedExpenseReport', {reportID: harvestOriginalReportID}); + const displayMessage = getHarvestCreatedExpenseReportMessage(getHarvestOriginalReportID(reportNameValuePairs), translate); setClipboardMessage(displayMessage); } else if (content) { setClipboardMessage( diff --git a/src/pages/home/report/PureReportActionItem.tsx b/src/pages/home/report/PureReportActionItem.tsx index 7194e1dc0511..e74a371a0aa4 100644 --- a/src/pages/home/report/PureReportActionItem.tsx +++ b/src/pages/home/report/PureReportActionItem.tsx @@ -69,6 +69,7 @@ import { getDeletedApprovalRuleMessage, getDemotedFromWorkspaceMessage, getDismissedViolationMessageText, + getHarvestCreatedExpenseReportMessage, getIntegrationSyncFailedMessage, getIOUReportIDFromReportActionPreview, getJoinRequestMessage, @@ -1413,8 +1414,11 @@ function PureReportActionItem({ } else if (isActionOfType(action, CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.UPDATE_MANUAL_APPROVAL_THRESHOLD)) { children = ; } else if (isActionOfType(action, CONST.REPORT.ACTIONS.TYPE.CREATED) && isHarvestCreatedExpenseReport) { - const harvestOriginalReportID = getHarvestOriginalReportID(reportNameValuePairs) ?? ''; - children = ; + children = ( + + ${getHarvestCreatedExpenseReportMessage(getHarvestOriginalReportID(reportNameValuePairs), translate)}`} /> + + ); } else if (isActionableMentionWhisper(action)) { children = ( From 65e2025dbd9cd55cbe43c55d83290ffabd1d6c12 Mon Sep 17 00:00:00 2001 From: VH Date: Thu, 20 Nov 2025 20:03:21 +0700 Subject: [PATCH 11/36] Fix type error --- src/libs/DebugUtils.ts | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/libs/DebugUtils.ts b/src/libs/DebugUtils.ts index 4c78e952efa1..7af352ae022b 100644 --- a/src/libs/DebugUtils.ts +++ b/src/libs/DebugUtils.ts @@ -643,6 +643,8 @@ function validateReportDraftProperty(key: keyof Report | keyof ReportNameValuePa expensify_text_title: CONST.RED_BRICK_ROAD_PENDING_ACTION, created: CONST.RED_BRICK_ROAD_PENDING_ACTION, transactionCount: CONST.RED_BRICK_ROAD_PENDING_ACTION, + origin: CONST.RED_BRICK_ROAD_PENDING_ACTION, + originalID: CONST.RED_BRICK_ROAD_PENDING_ACTION, }); case 'expensify_text_title': return validateObject>(value, { From 3d8b12c6a1e8f06abb53b60e8e14a7bd96e0d47e Mon Sep 17 00:00:00 2001 From: VH Date: Thu, 20 Nov 2025 20:17:11 +0700 Subject: [PATCH 12/36] Fix type error --- src/libs/ReportActionsUtils.ts | 4 ++-- src/libs/ReportUtils.ts | 9 +++++---- tests/unit/ReportUtilsTest.ts | 2 +- 3 files changed, 8 insertions(+), 7 deletions(-) diff --git a/src/libs/ReportActionsUtils.ts b/src/libs/ReportActionsUtils.ts index c94dcd7b08ad..13c3f733fbb7 100644 --- a/src/libs/ReportActionsUtils.ts +++ b/src/libs/ReportActionsUtils.ts @@ -3127,9 +3127,9 @@ function getChangedApproverActionMessage): string | undefined { - if (!isHarvestCreatedExpenseReport(reportNameValuePairs)) { - return undefined; +function getHarvestOriginalReportID(reportNameValuePairs?: OnyxInputOrEntry): string { + if (!reportNameValuePairs?.originalID || !isHarvestCreatedExpenseReport(reportNameValuePairs)) { + return ''; } - return reportNameValuePairs?.originalID; + + return reportNameValuePairs.originalID; } /** diff --git a/tests/unit/ReportUtilsTest.ts b/tests/unit/ReportUtilsTest.ts index 48799d7bb2e7..ded5e577b5f3 100644 --- a/tests/unit/ReportUtilsTest.ts +++ b/tests/unit/ReportUtilsTest.ts @@ -806,7 +806,7 @@ describe('ReportUtils', () => { expect(isHarvestCreatedExpenseReport(undefined)).toBe(false); expect(isHarvestCreatedExpenseReport({origin: 'harvest'})).toBe(false); expect(isHarvestCreatedExpenseReport({originalID: '123'})).toBe(false); - expect(getHarvestOriginalReportID({origin: 'harvest'})).toBeUndefined(); + expect(getHarvestOriginalReportID({origin: 'harvest'})).toBe(''); }); }); From d11506f17762f16e27599686afe533b52c202f33 Mon Sep 17 00:00:00 2001 From: VH Date: Thu, 20 Nov 2025 22:35:37 +0700 Subject: [PATCH 13/36] Add unit test for getHarvestCreatedExpenseReportMessage - Add test to verify correct message generation with valid report ID - Include required imports (getEnvironmentURL and ROUTES) - Test validates proper URL and reportID interpolation in translation --- tests/unit/ReportActionsUtilsTest.ts | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/tests/unit/ReportActionsUtilsTest.ts b/tests/unit/ReportActionsUtilsTest.ts index 3b97883ef3fd..18d38bc5ff1e 100644 --- a/tests/unit/ReportActionsUtilsTest.ts +++ b/tests/unit/ReportActionsUtilsTest.ts @@ -1,8 +1,10 @@ import type {KeyValueMapping} from 'react-native-onyx'; import Onyx from 'react-native-onyx'; +import {getEnvironmentURL} from '@libs/Environment/Environment'; import {formatPhoneNumber} from '@libs/LocalePhoneNumber'; import {isExpenseReport} from '@libs/ReportUtils'; import IntlStore from '@src/languages/IntlStore'; +import ROUTES from '@src/ROUTES'; import {actionR14932 as mockIOUAction, originalMessageR14932 as mockOriginalMessage} from '../../__mocks__/reportData/actions'; import {chatReportR14932 as mockChatReport, iouReportR14932 as mockIOUReport} from '../../__mocks__/reportData/reports'; import CONST from '../../src/CONST'; @@ -1501,4 +1503,23 @@ describe('ReportActionsUtils', () => { expect(ReportActionsUtils.isDeletedAction(action)).toBe(false); }); }); + + describe('getHarvestCreatedExpenseReportMessage', () => { + let environmentURL: string; + beforeAll(async () => { + environmentURL = await getEnvironmentURL(); + }); + + it('should return the correct message with a valid report ID', () => { + const reportID = '12345'; + const expectedMessage = translateLocal('reportAction.harvestCreatedExpenseReport', { + reportUrl: `${environmentURL}/${ROUTES.REPORT_WITH_ID.getRoute(reportID)}`, + reportID, + }); + + const result = ReportActionsUtils.getHarvestCreatedExpenseReportMessage(reportID, translateLocal); + + expect(result).toBe(expectedMessage); + }); + }); }); From 90e1db5b0ecdbc80080e1eb0f7ee9a6489d9df16 Mon Sep 17 00:00:00 2001 From: VH Date: Fri, 21 Nov 2025 13:34:32 +0700 Subject: [PATCH 14/36] perf: optimize React.memo comparison and fix stale closure - Replace deepEqual with shallow comparison for reportNameValuePairs - Add reportNameValuePairs to renderItem dependency array - Compare only relevant properties (origin and originalID) to avoid deep equality overhead --- .../MoneyRequestReportView/MoneyRequestReportActionsList.tsx | 1 + src/pages/home/report/PureReportActionItem.tsx | 3 ++- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/src/components/MoneyRequestReportView/MoneyRequestReportActionsList.tsx b/src/components/MoneyRequestReportView/MoneyRequestReportActionsList.tsx index f84236806aff..f0d91dbcf7dd 100644 --- a/src/components/MoneyRequestReportView/MoneyRequestReportActionsList.tsx +++ b/src/components/MoneyRequestReportView/MoneyRequestReportActionsList.tsx @@ -597,6 +597,7 @@ function MoneyRequestReportActionsList({ draftMessage, isTryNewDotNVPDismissed, isReportArchived, + reportNameValuePairs, ], ); diff --git a/src/pages/home/report/PureReportActionItem.tsx b/src/pages/home/report/PureReportActionItem.tsx index e74a371a0aa4..2d73ae2ca2c2 100644 --- a/src/pages/home/report/PureReportActionItem.tsx +++ b/src/pages/home/report/PureReportActionItem.tsx @@ -1865,6 +1865,7 @@ export default memo(PureReportActionItem, (prevProps, nextProps) => { deepEqual(prevProps.taskReport, nextProps.taskReport) && prevProps.shouldHighlight === nextProps.shouldHighlight && deepEqual(prevProps.bankAccountList, nextProps.bankAccountList) && - deepEqual(prevProps.reportNameValuePairs, nextProps.reportNameValuePairs) + prevProps.reportNameValuePairs?.origin === nextProps.reportNameValuePairs?.origin && + prevProps.reportNameValuePairs?.originalID === nextProps.reportNameValuePairs?.originalID ); }); From 358e6efae61ee25d2b784e5773b654982e482bb8 Mon Sep 17 00:00:00 2001 From: VH Date: Tue, 2 Dec 2025 07:36:42 +0700 Subject: [PATCH 15/36] Run prettier --- src/pages/home/report/ContextMenu/ContextMenuActions.tsx | 2 +- src/pages/home/report/PureReportActionItem.tsx | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/pages/home/report/ContextMenu/ContextMenuActions.tsx b/src/pages/home/report/ContextMenu/ContextMenuActions.tsx index fa6d7babfed6..377dfc72fde5 100644 --- a/src/pages/home/report/ContextMenu/ContextMenuActions.tsx +++ b/src/pages/home/report/ContextMenu/ContextMenuActions.tsx @@ -111,8 +111,8 @@ import { getChildReportNotificationPreference as getChildReportNotificationPreferenceReportUtils, getDeletedTransactionMessage, getDowngradeWorkspaceMessage, - getHarvestOriginalReportID, getForcedCorporateUpgradeMessage, + getHarvestOriginalReportID, getIOUReportActionDisplayMessage, getMovedActionMessage, getOriginalReportID, diff --git a/src/pages/home/report/PureReportActionItem.tsx b/src/pages/home/report/PureReportActionItem.tsx index 1f8029f1a756..1da83d3c63fc 100644 --- a/src/pages/home/report/PureReportActionItem.tsx +++ b/src/pages/home/report/PureReportActionItem.tsx @@ -151,8 +151,8 @@ import { getDeletedTransactionMessage, getDisplayNamesWithTooltips, getDowngradeWorkspaceMessage, - getHarvestOriginalReportID, getForcedCorporateUpgradeMessage, + getHarvestOriginalReportID, getMovedActionMessage, getMovedTransactionMessage, getPolicyChangeMessage, From b8906087f8d631d4b8a4cd22c9cc2846ba605565 Mon Sep 17 00:00:00 2001 From: VH Date: Wed, 3 Dec 2025 18:14:32 +0700 Subject: [PATCH 16/36] refactor: update harvestCreatedExpenseReport to use reportName instead of reportID - Updated getHarvestCreatedExpenseReportMessage to accept reportName parameter - Modified translation keys across all languages to use reportName instead of reportID - Added getReportName from ReportNameUtils to get report names - Updated PureReportActionItem to fetch and pass harvest report name - Updated BaseReportActionContextMenu to use useOnyx hook for harvest report - Added harvestReport to ContextMenuActionPayload type - Updated test spec to include reportName parameter --- src/languages/de.ts | 4 ++-- src/languages/en.ts | 4 ++-- src/languages/es.ts | 4 ++-- src/languages/fr.ts | 4 ++-- src/languages/it.ts | 4 ++-- src/languages/ja.ts | 4 ++-- src/languages/nl.ts | 4 ++-- src/languages/params.ts | 2 +- src/languages/pl.ts | 4 ++-- src/languages/pt-BR.ts | 4 ++-- src/languages/zh-hans.ts | 4 ++-- src/libs/ReportActionsUtils.ts | 4 ++-- src/libs/ReportUtils.ts | 4 ++-- .../ContextMenu/BaseReportActionContextMenu.tsx | 3 +++ .../home/report/ContextMenu/ContextMenuActions.tsx | 11 +++++++---- src/pages/home/report/PureReportActionItem.tsx | 5 ++++- tests/unit/ReportActionsUtilsTest.ts | 7 ++++--- 17 files changed, 43 insertions(+), 33 deletions(-) diff --git a/src/languages/de.ts b/src/languages/de.ts index 621b0592582c..f34138dee8e8 100644 --- a/src/languages/de.ts +++ b/src/languages/de.ts @@ -981,8 +981,8 @@ const translations: TranslationDeepObject = { adminOnlyCanPost: 'Nur Administratoren können Nachrichten in diesem Raum senden.', reportAction: { asCopilot: 'als Co-Pilot für', - harvestCreatedExpenseReport: ({reportUrl, reportID}: HarvestCreatedExpenseReportParams) => - `hat diesen Bericht erstellt, um alle Ausgaben aus #${reportID} aufzunehmen, die mit der von dir gewählten Frequenz nicht eingereicht werden konnten`, + harvestCreatedExpenseReport: ({reportUrl, reportName}: HarvestCreatedExpenseReportParams) => + `hat diesen Bericht erstellt, um alle Ausgaben aus ${reportName} aufzunehmen, die mit der von dir gewählten Frequenz nicht eingereicht werden konnten`, }, mentionSuggestions: { hereAlternateText: 'Benachrichtige alle in diesem Gespräch', diff --git a/src/languages/en.ts b/src/languages/en.ts index 625cdd220ecb..3d30efc3bed0 100755 --- a/src/languages/en.ts +++ b/src/languages/en.ts @@ -970,8 +970,8 @@ const translations = { adminOnlyCanPost: 'Only admins can send messages in this room.', reportAction: { asCopilot: 'as copilot for', - harvestCreatedExpenseReport: ({reportUrl, reportID}: HarvestCreatedExpenseReportParams) => - `created this report to hold all expenses from #${reportID} that couldn't be submitted on your chosen frequency`, + harvestCreatedExpenseReport: ({reportUrl, reportName}: HarvestCreatedExpenseReportParams) => + `created this report to hold all expenses from ${reportName} that couldn't be submitted on your chosen frequency`, }, mentionSuggestions: { hereAlternateText: 'Notify everyone in this conversation', diff --git a/src/languages/es.ts b/src/languages/es.ts index 87aaa77cdb3d..cda17a1af191 100644 --- a/src/languages/es.ts +++ b/src/languages/es.ts @@ -633,8 +633,8 @@ const translations: TranslationDeepObject = { adminOnlyCanPost: 'Solo los administradores pueden enviar mensajes en esta sala.', reportAction: { asCopilot: 'como copiloto de', - harvestCreatedExpenseReport: ({reportUrl, reportID}: HarvestCreatedExpenseReportParams) => - `creó este informe para contener todos los gastos de #${reportID} que no se pudieron enviar con la frecuencia que elegiste`, + harvestCreatedExpenseReport: ({reportUrl, reportName}: HarvestCreatedExpenseReportParams) => + `creó este informe para contener todos los gastos de ${reportName} que no se pudieron enviar con la frecuencia que elegiste`, }, mentionSuggestions: { hereAlternateText: 'Notificar a todos en esta conversación', diff --git a/src/languages/fr.ts b/src/languages/fr.ts index c1714b7918e0..a936069b6e64 100644 --- a/src/languages/fr.ts +++ b/src/languages/fr.ts @@ -983,8 +983,8 @@ const translations: TranslationDeepObject = { adminOnlyCanPost: 'Seuls les administrateurs peuvent envoyer des messages dans cette salle.', reportAction: { asCopilot: 'en tant que copilote pour', - harvestCreatedExpenseReport: ({reportUrl, reportID}: HarvestCreatedExpenseReportParams) => - `a créé ce rapport pour regrouper toutes les dépenses de #${reportID} qui n'ont pas pu être soumises selon la fréquence que vous avez choisie`, + harvestCreatedExpenseReport: ({reportUrl, reportName}: HarvestCreatedExpenseReportParams) => + `a créé ce rapport pour regrouper toutes les dépenses de ${reportName} qui n'ont pas pu être soumises selon la fréquence que vous avez choisie`, }, mentionSuggestions: { hereAlternateText: 'Notifier tout le monde dans cette conversation', diff --git a/src/languages/it.ts b/src/languages/it.ts index bb4db0a400e1..adcc9af34f16 100644 --- a/src/languages/it.ts +++ b/src/languages/it.ts @@ -980,8 +980,8 @@ const translations: TranslationDeepObject = { adminOnlyCanPost: 'Solo gli amministratori possono inviare messaggi in questa stanza.', reportAction: { asCopilot: 'come copilota per', - harvestCreatedExpenseReport: ({reportUrl, reportID}: HarvestCreatedExpenseReportParams) => - `ha creato questo rapporto per raccogliere tutte le spese di #${reportID} che non sono state inviate con la frequenza scelta`, + harvestCreatedExpenseReport: ({reportUrl, reportName}: HarvestCreatedExpenseReportParams) => + `ha creato questo rapporto per raccogliere tutte le spese di ${reportName} che non sono state inviate con la frequenza scelta`, }, mentionSuggestions: { hereAlternateText: 'Notifica tutti in questa conversazione', diff --git a/src/languages/ja.ts b/src/languages/ja.ts index bb8f0de2ea37..66e42cc25c1b 100644 --- a/src/languages/ja.ts +++ b/src/languages/ja.ts @@ -981,8 +981,8 @@ const translations: TranslationDeepObject = { adminOnlyCanPost: 'このルームでは管理者のみがメッセージを送信できます。', reportAction: { asCopilot: 'のコパイロットとして', - harvestCreatedExpenseReport: ({reportUrl, reportID}: HarvestCreatedExpenseReportParams) => - `選択した頻度では提出できなかった #${reportID} のすべての経費をまとめるためにこのレポートを作成しました`, + harvestCreatedExpenseReport: ({reportUrl, reportName}: HarvestCreatedExpenseReportParams) => + `選択した頻度では提出できなかった ${reportName} のすべての経費をまとめるためにこのレポートを作成しました`, }, mentionSuggestions: { hereAlternateText: 'この会話の全員に通知する', diff --git a/src/languages/nl.ts b/src/languages/nl.ts index 561da8b01e6a..b3ca411ef6a9 100644 --- a/src/languages/nl.ts +++ b/src/languages/nl.ts @@ -979,8 +979,8 @@ const translations: TranslationDeepObject = { adminOnlyCanPost: 'Alleen beheerders kunnen berichten sturen in deze ruimte.', reportAction: { asCopilot: 'als copiloot voor', - harvestCreatedExpenseReport: ({reportUrl, reportID}: HarvestCreatedExpenseReportParams) => - `heeft dit rapport aangemaakt om alle uitgaven van #${reportID} op te nemen die niet konden worden ingediend met de door jou gekozen frequentie`, + harvestCreatedExpenseReport: ({reportUrl, reportName}: HarvestCreatedExpenseReportParams) => + `heeft dit rapport aangemaakt om alle uitgaven van ${reportName} op te nemen die niet konden worden ingediend met de door jou gekozen frequentie`, }, mentionSuggestions: { hereAlternateText: 'Breng iedereen in dit gesprek op de hoogte', diff --git a/src/languages/params.ts b/src/languages/params.ts index 69907ed1a749..4620aa6d922a 100644 --- a/src/languages/params.ts +++ b/src/languages/params.ts @@ -142,7 +142,7 @@ type ReportArchiveReasonsInvoiceReceiverPolicyDeletedParams = { type HarvestCreatedExpenseReportParams = { reportUrl: string; - reportID: string; + reportName: string; }; type DuplicateTransactionParams = { diff --git a/src/languages/pl.ts b/src/languages/pl.ts index 99b34b3561b0..f1dbf146052d 100644 --- a/src/languages/pl.ts +++ b/src/languages/pl.ts @@ -980,8 +980,8 @@ const translations: TranslationDeepObject = { adminOnlyCanPost: 'Tylko administratorzy mogą wysyłać wiadomości w tym pokoju.', reportAction: { asCopilot: 'jako współpilot dla', - harvestCreatedExpenseReport: ({reportUrl, reportID}: HarvestCreatedExpenseReportParams) => - `utworzył ten raport, aby zawrzeć wszystkie wydatki z #${reportID}, które nie mogły zostać przesłane zgodnie z wybraną przez ciebie częstotliwością`, + harvestCreatedExpenseReport: ({reportUrl, reportName}: HarvestCreatedExpenseReportParams) => + `utworzył ten raport, aby zawrzeć wszystkie wydatki z ${reportName}, które nie mogły zostać przesłane zgodnie z wybraną przez ciebie częstotliwością`, }, mentionSuggestions: { hereAlternateText: 'Powiadom wszystkich w tej rozmowie', diff --git a/src/languages/pt-BR.ts b/src/languages/pt-BR.ts index 1b82e4029d80..e65dc38d7e4e 100644 --- a/src/languages/pt-BR.ts +++ b/src/languages/pt-BR.ts @@ -978,8 +978,8 @@ const translations: TranslationDeepObject = { adminOnlyCanPost: 'Apenas administradores podem enviar mensagens nesta sala.', reportAction: { asCopilot: 'como copiloto para', - harvestCreatedExpenseReport: ({reportUrl, reportID}: HarvestCreatedExpenseReportParams) => - `criou este relatório para agrupar todas as despesas de #${reportID} que não puderam ser enviadas na frequência que você escolheu`, + harvestCreatedExpenseReport: ({reportUrl, reportName}: HarvestCreatedExpenseReportParams) => + `criou este relatório para agrupar todas as despesas de ${reportName} que não puderam ser enviadas na frequência que você escolheu`, }, mentionSuggestions: { hereAlternateText: 'Notificar todos nesta conversa', diff --git a/src/languages/zh-hans.ts b/src/languages/zh-hans.ts index c918f5eaa6c8..285a48a8bc61 100644 --- a/src/languages/zh-hans.ts +++ b/src/languages/zh-hans.ts @@ -972,8 +972,8 @@ const translations: TranslationDeepObject = { adminOnlyCanPost: '只有管理员可以在此房间发送消息。', reportAction: { asCopilot: '作为副驾驶', - harvestCreatedExpenseReport: ({reportUrl, reportID}: HarvestCreatedExpenseReportParams) => - `创建了此报表以汇总 #${reportID} 中无法按您选择的频率提交的所有费用`, + harvestCreatedExpenseReport: ({reportUrl, reportName}: HarvestCreatedExpenseReportParams) => + `创建了此报表以汇总 ${reportName} 中无法按您选择的频率提交的所有费用`, }, mentionSuggestions: { hereAlternateText: '通知此对话中的所有人', diff --git a/src/libs/ReportActionsUtils.ts b/src/libs/ReportActionsUtils.ts index 8b6778b109c6..c464bc10658e 100644 --- a/src/libs/ReportActionsUtils.ts +++ b/src/libs/ReportActionsUtils.ts @@ -3162,9 +3162,9 @@ function getChangedApproverActionMessage): string { +function getHarvestOriginalReportID(reportNameValuePairs?: OnyxInputOrEntry): string | undefined { if (!reportNameValuePairs?.originalID || !isHarvestCreatedExpenseReport(reportNameValuePairs)) { - return ''; + return undefined; } return reportNameValuePairs.originalID; diff --git a/src/pages/home/report/ContextMenu/BaseReportActionContextMenu.tsx b/src/pages/home/report/ContextMenu/BaseReportActionContextMenu.tsx index 279c243a77db..c9f05af07993 100755 --- a/src/pages/home/report/ContextMenu/BaseReportActionContextMenu.tsx +++ b/src/pages/home/report/ContextMenu/BaseReportActionContextMenu.tsx @@ -28,6 +28,7 @@ import {getMovedReportID} from '@libs/ModifiedExpenseMessage'; import {getLinkedTransactionID, getOneTransactionThreadReportID, getOriginalMessage, getReportAction, isDeletedAction} from '@libs/ReportActionsUtils'; import { chatIncludesChronosWithID, + getHarvestOriginalReportID, getSourceIDFromReportAction, isArchivedNonExpenseReport, isInvoiceReport as ReportUtilsIsInvoiceReport, @@ -159,6 +160,7 @@ function BaseReportActionContextMenu({ const [isDebugModeEnabled] = useOnyx(ONYXKEYS.IS_DEBUG_MODE_ENABLED, {canBeMissing: true}); const [report] = useOnyx(`${ONYXKEYS.COLLECTION.REPORT}${reportID}`, {canBeMissing: true}); const [reportNameValuePairs] = useOnyx(`${ONYXKEYS.COLLECTION.REPORT_NAME_VALUE_PAIRS}${reportID}`, {canBeMissing: true}); + const [harvestReport] = useOnyx(`${ONYXKEYS.COLLECTION.REPORT}${getHarvestOriginalReportID(reportNameValuePairs)}`, {canBeMissing: true}); const [originalReport] = useOnyx(`${ONYXKEYS.COLLECTION.REPORT}${originalReportID}`, {canBeMissing: true}); const isOriginalReportArchived = useReportIsArchived(originalReportID); const policyID = report?.policyID; @@ -380,6 +382,7 @@ function BaseReportActionContextMenu({ policy, policyTags, translate, + harvestReport, }; if ('renderContent' in contextAction) { diff --git a/src/pages/home/report/ContextMenu/ContextMenuActions.tsx b/src/pages/home/report/ContextMenu/ContextMenuActions.tsx index bd4f5ea15653..44a3a0f4bc72 100644 --- a/src/pages/home/report/ContextMenu/ContextMenuActions.tsx +++ b/src/pages/home/report/ContextMenu/ContextMenuActions.tsx @@ -103,6 +103,7 @@ import { isUnapprovedAction, isWhisperAction as isWhisperActionReportActionsUtils, } from '@libs/ReportActionsUtils'; +import {getReportName} from '@libs/ReportNameUtils'; import { canDeleteReportAction, canEditReportAction, @@ -113,7 +114,6 @@ import { getDeletedTransactionMessage, getDowngradeWorkspaceMessage, getForcedCorporateUpgradeMessage, - getHarvestOriginalReportID, getIOUReportActionDisplayMessage, getMovedActionMessage, getMovedTransactionMessage, @@ -122,7 +122,7 @@ import { getReimbursementDeQueuedOrCanceledActionMessage, getReimbursementQueuedActionMessage, getRejectedReportMessage, - getReportName, + getReportName as getReportNameDeprecated, getReportPreviewMessage, getUnreportedTransactionMessage, getUpgradeWorkspaceMessage, @@ -240,6 +240,7 @@ type ContextMenuActionPayload = { policy?: OnyxEntry; policyTags: OnyxEntry; translate: LocalizedTranslate; + harvestReport?: OnyxEntry; }; type OnPress = (closePopover: boolean, payload: ContextMenuActionPayload, selection?: string, reportID?: string, draftMessage?: string) => void; @@ -603,6 +604,7 @@ const ContextMenuActions: ContextMenuAction[] = [ policy, policyTags, translate, + harvestReport, }, ) => { const isReportPreviewAction = isReportPreviewActionReportActionsUtils(reportAction); @@ -644,7 +646,7 @@ const ContextMenuActions: ContextMenuAction[] = [ const taskPreviewMessage = getTaskCreatedMessage(reportAction, childReport, true); Clipboard.setString(taskPreviewMessage); } else if (isMemberChangeAction(reportAction)) { - const logMessage = getMemberChangeMessageFragment(reportAction, getReportName).html ?? ''; + const logMessage = getMemberChangeMessageFragment(reportAction, getReportNameDeprecated).html ?? ''; setClipboardMessage(logMessage); } else if (reportAction?.actionName === CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.UPDATE_NAME) { Clipboard.setString(Str.htmlDecode(getWorkspaceNameUpdatedMessage(reportAction))); @@ -827,7 +829,8 @@ const ContextMenuActions: ContextMenuAction[] = [ const displayMessage = getJoinRequestMessage(reportAction); Clipboard.setString(displayMessage); } else if (isActionOfType(reportAction, CONST.REPORT.ACTIONS.TYPE.CREATED) && isHarvestCreatedExpenseReport(reportNameValuePairs)) { - const displayMessage = getHarvestCreatedExpenseReportMessage(getHarvestOriginalReportID(reportNameValuePairs), translate); + const harvestReportName = getReportName(harvestReport); + const displayMessage = getHarvestCreatedExpenseReportMessage(harvestReport?.reportID, harvestReportName, translate); setClipboardMessage(displayMessage); } else if (content) { setClipboardMessage( diff --git a/src/pages/home/report/PureReportActionItem.tsx b/src/pages/home/report/PureReportActionItem.tsx index adceba520fcc..ddd4c7903e17 100644 --- a/src/pages/home/report/PureReportActionItem.tsx +++ b/src/pages/home/report/PureReportActionItem.tsx @@ -144,6 +144,7 @@ import { isWhisperActionTargetedToOthers, useTableReportViewActionRenderConditionals, } from '@libs/ReportActionsUtils'; +import {getReportName} from '@libs/ReportNameUtils'; import type {MissingPaymentMethod} from '@libs/ReportUtils'; import { canWriteInReport, @@ -1469,9 +1470,11 @@ function PureReportActionItem({ } else if (isActionOfType(action, CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.UPDATE_MANUAL_APPROVAL_THRESHOLD)) { children = ; } else if (isActionOfType(action, CONST.REPORT.ACTIONS.TYPE.CREATED) && isHarvestCreatedExpenseReport) { + const harvestReport = allReports?.[`${ONYXKEYS.COLLECTION.REPORT}${getHarvestOriginalReportID(reportNameValuePairs)}`]; + const harvestReportName = getReportName(harvestReport); children = ( - ${getHarvestCreatedExpenseReportMessage(getHarvestOriginalReportID(reportNameValuePairs), translate)}`} /> + ${getHarvestCreatedExpenseReportMessage(harvestReport?.reportID, harvestReportName, translate)}`} /> ); } else if (isActionableMentionWhisper(action)) { diff --git a/tests/unit/ReportActionsUtilsTest.ts b/tests/unit/ReportActionsUtilsTest.ts index 8839972deae3..f54bfb31bff5 100644 --- a/tests/unit/ReportActionsUtilsTest.ts +++ b/tests/unit/ReportActionsUtilsTest.ts @@ -1485,14 +1485,15 @@ describe('ReportActionsUtils', () => { environmentURL = await getEnvironmentURL(); }); - it('should return the correct message with a valid report ID', () => { + it('should return the correct message with a valid report ID and report name', () => { const reportID = '12345'; + const reportName = 'Test Expense Report'; const expectedMessage = translateLocal('reportAction.harvestCreatedExpenseReport', { reportUrl: `${environmentURL}/${ROUTES.REPORT_WITH_ID.getRoute(reportID)}`, - reportID, + reportName, }); - const result = ReportActionsUtils.getHarvestCreatedExpenseReportMessage(reportID, translateLocal); + const result = ReportActionsUtils.getHarvestCreatedExpenseReportMessage(reportID, reportName, translateLocal); expect(result).toBe(expectedMessage); }); From d14c02b44a6bc3f79251f8f91c2cfe5369d6389f Mon Sep 17 00:00:00 2001 From: VH Date: Wed, 3 Dec 2025 18:38:10 +0700 Subject: [PATCH 17/36] refactor: pass reportNameValuePairs as separate props for better performance MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Extract reportNameValuePairsOrigin and reportNameValuePairsOriginalID from reportNameValuePairs object - Pass them as separate primitive props through component hierarchy (MoneyRequestReportActionsList → ReportActionsListItemRenderer → PureReportActionItem) - Update isHarvestCreatedExpenseReport and getHarvestOriginalReportID utility functions to accept separate origin and originalID parameters instead of entire object - Reuse isHarvestCreatedExpenseReport utility function in PureReportActionItem instead of inline check - Update all usages across components and context menus - Update test cases to use new function signatures - Update memo comparison to use separate props This change improves component performance by preventing unnecessary re-renders when unrelated properties in the reportNameValuePairs object change. --- .../MoneyRequestReportActionsList.tsx | 8 +++++--- src/libs/ReportUtils.ts | 12 ++++++------ .../BaseReportActionContextMenu.tsx | 2 +- .../report/ContextMenu/ContextMenuActions.tsx | 2 +- .../home/report/PureReportActionItem.tsx | 19 +++++++++++-------- .../report/ReportActionsListItemRenderer.tsx | 13 +++++++++---- tests/unit/ReportUtilsTest.ts | 17 ++++++----------- 7 files changed, 39 insertions(+), 34 deletions(-) diff --git a/src/components/MoneyRequestReportView/MoneyRequestReportActionsList.tsx b/src/components/MoneyRequestReportView/MoneyRequestReportActionsList.tsx index d8d5ab5beb7c..1c3278cd28c4 100644 --- a/src/components/MoneyRequestReportView/MoneyRequestReportActionsList.tsx +++ b/src/components/MoneyRequestReportView/MoneyRequestReportActionsList.tsx @@ -170,7 +170,7 @@ function MoneyRequestReportActionsList({ const [session] = useOnyx(ONYXKEYS.SESSION, {canBeMissing: false}); const [reportNameValuePairs] = useOnyx(`${ONYXKEYS.COLLECTION.REPORT_NAME_VALUE_PAIRS}${getNonEmptyStringOnyxID(reportID)}`, {canBeMissing: true}); - const shouldShowHarvestCreatedAction = isHarvestCreatedExpenseReport(reportNameValuePairs); + const shouldShowHarvestCreatedAction = isHarvestCreatedExpenseReport(reportNameValuePairs?.origin, reportNameValuePairs?.originalID); const [offlineModalVisible, setOfflineModalVisible] = useState(false); const [isDownloadErrorModalVisible, setIsDownloadErrorModalVisible] = useState(false); const [enableScrollToEnd, setEnableScrollToEnd] = useState(false); @@ -574,7 +574,8 @@ function MoneyRequestReportActionsList({ isReportArchived={isReportArchived} draftMessage={matchingDraftMessageString} isTryNewDotNVPDismissed={isTryNewDotNVPDismissed} - reportNameValuePairs={reportNameValuePairs} + reportNameValuePairsOrigin={reportNameValuePairs?.origin} + reportNameValuePairsOriginalID={reportNameValuePairs?.originalID} /> ); }, @@ -598,7 +599,8 @@ function MoneyRequestReportActionsList({ draftMessage, isTryNewDotNVPDismissed, isReportArchived, - reportNameValuePairs, + reportNameValuePairs?.origin, + reportNameValuePairs?.originalID, ], ); diff --git a/src/libs/ReportUtils.ts b/src/libs/ReportUtils.ts index 396b9c4541d3..1184b7106c7d 100644 --- a/src/libs/ReportUtils.ts +++ b/src/libs/ReportUtils.ts @@ -2306,19 +2306,19 @@ function isArchivedReport(reportNameValuePairs?: OnyxInputOrEntry): boolean { - return !!reportNameValuePairs?.originalID && reportNameValuePairs?.origin === 'harvest'; +function isHarvestCreatedExpenseReport(origin?: string, originalID?: string): boolean { + return !!originalID && origin === 'harvest'; } /** * Returns the original reportID for a harvest-created report */ -function getHarvestOriginalReportID(reportNameValuePairs?: OnyxInputOrEntry): string | undefined { - if (!reportNameValuePairs?.originalID || !isHarvestCreatedExpenseReport(reportNameValuePairs)) { +function getHarvestOriginalReportID(origin?: string, originalID?: string): string | undefined { + if (!originalID || !isHarvestCreatedExpenseReport(origin, originalID)) { return undefined; } - return reportNameValuePairs.originalID; + return originalID; } /** @@ -11151,7 +11151,7 @@ function getReportActionActorAccountID( return reportAction?.adminAccountID ?? reportAction?.actorAccountID; case CONST.REPORT.ACTIONS.TYPE.CREATED: { const reportNameValuePairs = allReportNameValuePair?.[`${ONYXKEYS.COLLECTION.REPORT_NAME_VALUE_PAIRS}${iouReport?.reportID}`]; - if (isHarvestCreatedExpenseReport(reportNameValuePairs)) { + if (isHarvestCreatedExpenseReport(reportNameValuePairs?.origin, reportNameValuePairs?.originalID)) { return CONST.ACCOUNT_ID.CONCIERGE; } return reportAction?.actorAccountID; diff --git a/src/pages/home/report/ContextMenu/BaseReportActionContextMenu.tsx b/src/pages/home/report/ContextMenu/BaseReportActionContextMenu.tsx index c9f05af07993..5dd6ac912b1f 100755 --- a/src/pages/home/report/ContextMenu/BaseReportActionContextMenu.tsx +++ b/src/pages/home/report/ContextMenu/BaseReportActionContextMenu.tsx @@ -160,7 +160,7 @@ function BaseReportActionContextMenu({ const [isDebugModeEnabled] = useOnyx(ONYXKEYS.IS_DEBUG_MODE_ENABLED, {canBeMissing: true}); const [report] = useOnyx(`${ONYXKEYS.COLLECTION.REPORT}${reportID}`, {canBeMissing: true}); const [reportNameValuePairs] = useOnyx(`${ONYXKEYS.COLLECTION.REPORT_NAME_VALUE_PAIRS}${reportID}`, {canBeMissing: true}); - const [harvestReport] = useOnyx(`${ONYXKEYS.COLLECTION.REPORT}${getHarvestOriginalReportID(reportNameValuePairs)}`, {canBeMissing: true}); + const [harvestReport] = useOnyx(`${ONYXKEYS.COLLECTION.REPORT}${getHarvestOriginalReportID(reportNameValuePairs?.origin, reportNameValuePairs?.originalID)}`, {canBeMissing: true}); const [originalReport] = useOnyx(`${ONYXKEYS.COLLECTION.REPORT}${originalReportID}`, {canBeMissing: true}); const isOriginalReportArchived = useReportIsArchived(originalReportID); const policyID = report?.policyID; diff --git a/src/pages/home/report/ContextMenu/ContextMenuActions.tsx b/src/pages/home/report/ContextMenu/ContextMenuActions.tsx index 44a3a0f4bc72..47b57ec040b0 100644 --- a/src/pages/home/report/ContextMenu/ContextMenuActions.tsx +++ b/src/pages/home/report/ContextMenu/ContextMenuActions.tsx @@ -828,7 +828,7 @@ const ContextMenuActions: ContextMenuAction[] = [ } else if (isActionableJoinRequest(reportAction)) { const displayMessage = getJoinRequestMessage(reportAction); Clipboard.setString(displayMessage); - } else if (isActionOfType(reportAction, CONST.REPORT.ACTIONS.TYPE.CREATED) && isHarvestCreatedExpenseReport(reportNameValuePairs)) { + } else if (isActionOfType(reportAction, CONST.REPORT.ACTIONS.TYPE.CREATED) && isHarvestCreatedExpenseReport(reportNameValuePairs?.origin, reportNameValuePairs?.originalID)) { const harvestReportName = getReportName(harvestReport); const displayMessage = getHarvestCreatedExpenseReportMessage(harvestReport?.reportID, harvestReportName, translate); setClipboardMessage(displayMessage); diff --git a/src/pages/home/report/PureReportActionItem.tsx b/src/pages/home/report/PureReportActionItem.tsx index ddd4c7903e17..b54729dd9a19 100644 --- a/src/pages/home/report/PureReportActionItem.tsx +++ b/src/pages/home/report/PureReportActionItem.tsx @@ -154,7 +154,6 @@ import { getDisplayNamesWithTooltips, getDowngradeWorkspaceMessage, getForcedCorporateUpgradeMessage, - getHarvestOriginalReportID, getMovedActionMessage, getMovedTransactionMessage, getPolicyChangeMessage, @@ -409,8 +408,11 @@ type PureReportActionItemProps = { /** The bank account list */ bankAccountList?: OnyxTypes.BankAccountList | undefined; - /** Report name value pairs */ - reportNameValuePairs?: OnyxEntry; + /** Report name value pairs origin */ + reportNameValuePairsOrigin?: string; + + /** Report name value pairs originalID */ + reportNameValuePairsOriginalID?: string; }; // This is equivalent to returning a negative boolean in normal functions, but we can keep the element return type @@ -479,7 +481,8 @@ function PureReportActionItem({ isTryNewDotNVPDismissed = false, currentUserAccountID, bankAccountList, - reportNameValuePairs, + reportNameValuePairsOrigin, + reportNameValuePairsOriginalID, }: PureReportActionItemProps) { const actionSheetAwareScrollViewContext = useContext(ActionSheetAwareScrollView.ActionSheetAwareScrollViewContext); const {translate, formatPhoneNumber, localeCompare, formatTravelDate, getLocalDateFromDatetime} = useLocalize(); @@ -509,7 +512,7 @@ function PureReportActionItem({ isActionableMentionWhisper(action) || isActionableMentionInviteToSubmitExpenseConfirmWhisper(action) || isActionableTrackExpense(action) || isActionableReportMentionWhisper(action); const isReportArchived = useReportIsArchived(reportID); const isOriginalReportArchived = useReportIsArchived(originalReportID); - const isHarvestCreatedExpenseReport = isHarvestCreatedExpenseReportUtils(reportNameValuePairs); + const isHarvestCreatedExpenseReport = isHarvestCreatedExpenseReportUtils(reportNameValuePairsOrigin, reportNameValuePairsOriginalID); const highlightedBackgroundColorIfNeeded = useMemo( // eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing @@ -1470,7 +1473,7 @@ function PureReportActionItem({ } else if (isActionOfType(action, CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.UPDATE_MANUAL_APPROVAL_THRESHOLD)) { children = ; } else if (isActionOfType(action, CONST.REPORT.ACTIONS.TYPE.CREATED) && isHarvestCreatedExpenseReport) { - const harvestReport = allReports?.[`${ONYXKEYS.COLLECTION.REPORT}${getHarvestOriginalReportID(reportNameValuePairs)}`]; + const harvestReport = allReports?.[`${ONYXKEYS.COLLECTION.REPORT}${reportNameValuePairsOriginalID}`]; const harvestReportName = getReportName(harvestReport); children = ( @@ -1930,7 +1933,7 @@ export default memo(PureReportActionItem, (prevProps, nextProps) => { deepEqual(prevProps.taskReport, nextProps.taskReport) && prevProps.shouldHighlight === nextProps.shouldHighlight && deepEqual(prevProps.bankAccountList, nextProps.bankAccountList) && - prevProps.reportNameValuePairs?.origin === nextProps.reportNameValuePairs?.origin && - prevProps.reportNameValuePairs?.originalID === nextProps.reportNameValuePairs?.originalID + prevProps.reportNameValuePairsOrigin === nextProps.reportNameValuePairsOrigin && + prevProps.reportNameValuePairsOriginalID === nextProps.reportNameValuePairsOriginalID ); }); diff --git a/src/pages/home/report/ReportActionsListItemRenderer.tsx b/src/pages/home/report/ReportActionsListItemRenderer.tsx index fcdda3d5d184..96ecf2f42607 100644 --- a/src/pages/home/report/ReportActionsListItemRenderer.tsx +++ b/src/pages/home/report/ReportActionsListItemRenderer.tsx @@ -98,8 +98,11 @@ type ReportActionsListItemRendererProps = { /** Whether the report is archived */ isReportArchived: boolean; - /** Report name value pairs */ - reportNameValuePairs?: OnyxEntry; + /** Report name value pairs origin */ + reportNameValuePairsOrigin?: string; + + /** Report name value pairs originalID */ + reportNameValuePairsOriginalID?: string; }; function ReportActionsListItemRenderer({ @@ -133,7 +136,8 @@ function ReportActionsListItemRenderer({ allEmojiReactions, isTryNewDotNVPDismissed = false, isReportArchived = false, - reportNameValuePairs, + reportNameValuePairsOrigin, + reportNameValuePairsOriginalID, }: ReportActionsListItemRendererProps) { const originalMessage = useMemo(() => getOriginalMessage(reportAction), [reportAction]); @@ -264,7 +268,8 @@ function ReportActionsListItemRenderer({ linkedTransactionRouteError={linkedTransactionRouteError} userBillingFundID={userBillingFundID} isTryNewDotNVPDismissed={isTryNewDotNVPDismissed} - reportNameValuePairs={reportNameValuePairs} + reportNameValuePairsOrigin={reportNameValuePairsOrigin} + reportNameValuePairsOriginalID={reportNameValuePairsOriginalID} /> ); } diff --git a/tests/unit/ReportUtilsTest.ts b/tests/unit/ReportUtilsTest.ts index a8ed6c1e7ef1..552eb9402435 100644 --- a/tests/unit/ReportUtilsTest.ts +++ b/tests/unit/ReportUtilsTest.ts @@ -818,20 +818,15 @@ describe('ReportUtils', () => { describe('Harvest-created reports', () => { test('detects harvest-created report from name value pairs', () => { - const reportNameValuePairs = { - origin: 'harvest', - originalID: '12345', - }; - - expect(isHarvestCreatedExpenseReport(reportNameValuePairs)).toBe(true); - expect(getHarvestOriginalReportID(reportNameValuePairs)).toBe('12345'); + expect(isHarvestCreatedExpenseReport('harvest', '12345')).toBe(true); + expect(getHarvestOriginalReportID('harvest', '12345')).toBe('12345'); }); test('returns false when origin or originalID missing', () => { - expect(isHarvestCreatedExpenseReport(undefined)).toBe(false); - expect(isHarvestCreatedExpenseReport({origin: 'harvest'})).toBe(false); - expect(isHarvestCreatedExpenseReport({originalID: '123'})).toBe(false); - expect(getHarvestOriginalReportID({origin: 'harvest'})).toBe(''); + expect(isHarvestCreatedExpenseReport(undefined, undefined)).toBe(false); + expect(isHarvestCreatedExpenseReport('harvest', undefined)).toBe(false); + expect(isHarvestCreatedExpenseReport(undefined, '123')).toBe(false); + expect(getHarvestOriginalReportID('harvest', undefined)).toBe(undefined); }); }); From dd5751b6d00162e0a78521f39c02455e25723e94 Mon Sep 17 00:00:00 2001 From: VH Date: Wed, 3 Dec 2025 18:48:11 +0700 Subject: [PATCH 18/36] Fix eslint --- src/pages/home/report/ReportActionsListItemRenderer.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pages/home/report/ReportActionsListItemRenderer.tsx b/src/pages/home/report/ReportActionsListItemRenderer.tsx index 96ecf2f42607..47664acf4f61 100644 --- a/src/pages/home/report/ReportActionsListItemRenderer.tsx +++ b/src/pages/home/report/ReportActionsListItemRenderer.tsx @@ -3,7 +3,7 @@ import type {OnyxCollection, OnyxEntry} from 'react-native-onyx'; import {getOriginalMessage, isSentMoneyReportAction, isTransactionThread} from '@libs/ReportActionsUtils'; import {isChatThread} from '@libs/ReportUtils'; import CONST from '@src/CONST'; -import type {PersonalDetailsList, Policy, Report, ReportAction, ReportActionReactions, ReportActionsDrafts, ReportNameValuePairs, Transaction} from '@src/types/onyx'; +import type {PersonalDetailsList, Policy, Report, ReportAction, ReportActionReactions, ReportActionsDrafts, Transaction} from '@src/types/onyx'; import type {Errors} from '@src/types/onyx/OnyxCommon'; import ReportActionItem from './ReportActionItem'; import ReportActionItemParentAction from './ReportActionItemParentAction'; From a97821906ab550ef49c6cf25496faac1dc727066 Mon Sep 17 00:00:00 2001 From: VH Date: Fri, 5 Dec 2025 04:44:28 +0700 Subject: [PATCH 19/36] refactor: extract getReportURLForCurrentContext to navigation helper - Move getReportURLForCurrentContext from ReportUtils to separate helper file - Update ReportActionsUtils to use the helper instead of manually building URLs - Prevents circular dependency issues - Maintains context-aware URL generation for search/report navigation --- .../helpers/getReportURLForCurrentContext.ts | 62 +++++++++++++++++++ src/libs/ReportActionsUtils.ts | 3 +- src/libs/ReportUtils.ts | 50 +-------------- tests/unit/ReportUtilsTest.ts | 2 +- 4 files changed, 67 insertions(+), 50 deletions(-) create mode 100644 src/libs/Navigation/helpers/getReportURLForCurrentContext.ts diff --git a/src/libs/Navigation/helpers/getReportURLForCurrentContext.ts b/src/libs/Navigation/helpers/getReportURLForCurrentContext.ts new file mode 100644 index 000000000000..d6566f917849 --- /dev/null +++ b/src/libs/Navigation/helpers/getReportURLForCurrentContext.ts @@ -0,0 +1,62 @@ +import {getEnvironmentURL} from '@libs/Environment/Environment'; +import Navigation from '@libs/Navigation/Navigation'; +import ROUTES from '@src/ROUTES'; +import isSearchTopmostFullScreenRoute from './isSearchTopmostFullScreenRoute'; + +let environmentURL: string; +getEnvironmentURL().then((url: string) => (environmentURL = url)); + +/** + * Generates a URL for a report that respects the current navigation context. + * When in a search context, includes backTo parameter to preserve search state. + * Otherwise, returns a simple report URL. + */ +function getReportURLForCurrentContext(reportID: string | undefined): string { + if (!reportID) { + return `${environmentURL}/r/`; + } + const isInSearchContext = isSearchTopmostFullScreenRoute(); + if (!isInSearchContext) { + return `${environmentURL}/${ROUTES.REPORT_WITH_ID.getRoute(reportID)}`; + } + + // Navigation can return routes with a leading slash or missing when still mounting. + // Normalize everything to match the path shape used by ROUTES helpers. + const normalizeRoute = (route?: string) => { + if (!route) { + return undefined; + } + return route.startsWith('/') ? route.substring(1) : route; + }; + + const activeRoute = normalizeRoute(Navigation.getActiveRoute()); + + let backToRoute: string | undefined; + + if (activeRoute) { + const [, queryString = ''] = activeRoute.split('?'); + if (queryString) { + const params = new URLSearchParams(queryString); + const encodedBackTo = params.get('backTo'); + if (encodedBackTo) { + // Prefer the backTo param when present; it points to the exact search state we left. + backToRoute = normalizeRoute(decodeURIComponent(encodedBackTo)); + } + } + + if (!backToRoute && activeRoute.startsWith(ROUTES.SEARCH_ROOT.route)) { + // Otherwise keep the current search route (preserves tab + filters) as the return target. + backToRoute = activeRoute; + } + } + + if (!backToRoute?.startsWith(ROUTES.SEARCH_ROOT.route)) { + // Fall back to the generic search home when we can't recover a valid route. + backToRoute = ROUTES.SEARCH_ROOT.route; + } + + const relativePath = ROUTES.SEARCH_MONEY_REQUEST_REPORT.getRoute({reportID, backTo: backToRoute}); + return `${environmentURL}/${relativePath}`; +} + +export default getReportURLForCurrentContext; diff --git a/src/libs/ReportActionsUtils.ts b/src/libs/ReportActionsUtils.ts index 914d88f2cf5f..6f3972116aa1 100644 --- a/src/libs/ReportActionsUtils.ts +++ b/src/libs/ReportActionsUtils.ts @@ -32,6 +32,7 @@ import {formatPhoneNumber} from './LocalePhoneNumber'; import {formatMessageElementList, translateLocal} from './Localize'; import Log from './Log'; import type {MessageElementBase, MessageTextElement} from './MessageElement'; +import getReportURLForCurrentContext from './Navigation/helpers/getReportURLForCurrentContext'; import Parser from './Parser'; import {arePersonalDetailsMissing, getEffectiveDisplayName, getPersonalDetailByEmail, getPersonalDetailsByIDs} from './PersonalDetailsUtils'; import {getPolicy, isPolicyAdmin as isPolicyAdminPolicyUtils} from './PolicyUtils'; @@ -3173,7 +3174,7 @@ function getChangedApproverActionMessage, isPoli return (report.visibility === CONST.REPORT.VISIBILITY.RESTRICTED || hasAccessPolicyExpenseChat) && isPolicyEmployee; } -function getReportURLForCurrentContext(reportID: string | undefined): string { - if (!reportID) { - return `${environmentURL}/r/`; - } - const isInSearchContext = isSearchTopmostFullScreenRoute(); - if (!isInSearchContext) { - return `${environmentURL}/${ROUTES.REPORT_WITH_ID.getRoute(reportID)}`; - } - - // Navigation can return routes with a leading slash or missing when still mounting. - // Normalize everything to match the path shape used by ROUTES helpers. - const normalizeRoute = (route?: string) => { - if (!route) { - return undefined; - } - return route.startsWith('/') ? route.substring(1) : route; - }; - - const activeRoute = normalizeRoute(Navigation.getActiveRoute()); - let backToRoute: string | undefined; - - if (activeRoute) { - const [, queryString = ''] = activeRoute.split('?'); - if (queryString) { - const params = new URLSearchParams(queryString); - const encodedBackTo = params.get('backTo'); - if (encodedBackTo) { - // Prefer the backTo param when present; it points to the exact search state we left. - backToRoute = normalizeRoute(decodeURIComponent(encodedBackTo)); - } - } - - if (!backToRoute && activeRoute.startsWith(ROUTES.SEARCH_ROOT.route)) { - // Otherwise keep the current search route (preserves tab + filters) as the return target. - backToRoute = activeRoute; - } - } - - if (!backToRoute?.startsWith(ROUTES.SEARCH_ROOT.route)) { - // Fall back to the generic search home when we can't recover a valid route. - backToRoute = ROUTES.SEARCH_ROOT.route; - } - - const relativePath = ROUTES.SEARCH_MONEY_REQUEST_REPORT.getRoute({reportID, backTo: backToRoute}); - return `${environmentURL}/${relativePath}`; -} /** * Checks if all selected items have the necessary Onyx data hydrated for bulk rejection. @@ -13374,7 +13328,6 @@ export { isWorkspaceThread, isMoneyRequestReportEligibleForMerge, getReportStatusTranslation, - getReportURLForCurrentContext, getReportStatusColorStyle, getMovedActionMessage, excludeParticipantsForDisplay, @@ -13389,6 +13342,7 @@ export { isWorkspaceChat, isOneTransactionReport, }; + export type { Ancestor, DisplayNameWithTooltips, diff --git a/tests/unit/ReportUtilsTest.ts b/tests/unit/ReportUtilsTest.ts index 552eb9402435..202f1291f671 100644 --- a/tests/unit/ReportUtilsTest.ts +++ b/tests/unit/ReportUtilsTest.ts @@ -16,6 +16,7 @@ import DateUtils from '@libs/DateUtils'; import {getEnvironmentURL} from '@libs/Environment/Environment'; import getBase62ReportID from '@libs/getBase62ReportID'; import {translate} from '@libs/Localize'; +import getReportURLForCurrentContext from '@libs/Navigation/helpers/getReportURLForCurrentContext'; import isSearchTopmostFullScreenRoute from '@libs/Navigation/helpers/isSearchTopmostFullScreenRoute'; import Navigation from '@libs/Navigation/Navigation'; import {getOriginalMessage, getReportAction, isWhisperAction} from '@libs/ReportActionsUtils'; @@ -71,7 +72,6 @@ import { getReportName as getReportNameDeprecated, getReportOrDraftReport, getReportStatusTranslation, - getReportURLForCurrentContext, getWorkspaceIcon, getWorkspaceNameUpdatedMessage, hasEmptyReportsForPolicy, From 068e15e253a45a28f52938bf0353465a2c357d91 Mon Sep 17 00:00:00 2001 From: VH Date: Fri, 5 Dec 2025 17:17:20 +0700 Subject: [PATCH 20/36] fix: show harvest created expense report action in LHN --- src/libs/OptionsListUtils/index.ts | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/libs/OptionsListUtils/index.ts b/src/libs/OptionsListUtils/index.ts index 41e781e7e407..f00ae2f412bc 100644 --- a/src/libs/OptionsListUtils/index.ts +++ b/src/libs/OptionsListUtils/index.ts @@ -37,6 +37,7 @@ import { getChangedApproverActionMessage, getCombinedReportActions, getExportIntegrationLastMessageText, + getHarvestCreatedExpenseReportMessage, getIOUReportIDFromReportActionPreview, getJoinRequestMessage, getLastVisibleMessage, @@ -117,6 +118,7 @@ import { isDM, isDraftReport, isExpenseReport, + isHarvestCreatedExpenseReport, isHiddenForCurrentUser, isInvoiceRoom, isMoneyRequest, @@ -643,6 +645,12 @@ function getLastMessageTextForReport({ lastMessageTextFromReport = translateLocal(`reportArchiveReasons.default`); } } + } else if (report?.lastActionType === CONST.REPORT.ACTIONS.TYPE.CREATED) { + const reportNameValuePairs = allReportNameValuePairs?.[`${ONYXKEYS.COLLECTION.REPORT_NAME_VALUE_PAIRS}${reportID}`]; + if (isHarvestCreatedExpenseReport(reportNameValuePairs?.origin, reportNameValuePairs?.originalID)) { + const harvestReport = getReportOrDraftReport(reportNameValuePairs?.originalID); + lastMessageTextFromReport = formatReportLastMessageText(Parser.htmlToText(getHarvestCreatedExpenseReportMessage(harvestReport?.reportID, getReportName(harvestReport), translateLocal))); + } } else if (isMoneyRequestAction(lastReportAction)) { const properSchemaForMoneyRequestMessage = getReportPreviewMessage(report, lastReportAction, true, false, null, true); lastMessageTextFromReport = formatReportLastMessageText(Parser.htmlToText(properSchemaForMoneyRequestMessage)); From 0cedc66877c0a2e555cb729857ac4ab4d6ac96bc Mon Sep 17 00:00:00 2001 From: VH Date: Fri, 5 Dec 2025 22:27:34 +0700 Subject: [PATCH 21/36] fix: show harvest created expense report action in one-transaction view --- .../home/report/PureReportActionItem.tsx | 251 ++++++++++-------- src/pages/home/report/ReportActionsList.tsx | 5 + 2 files changed, 138 insertions(+), 118 deletions(-) diff --git a/src/pages/home/report/PureReportActionItem.tsx b/src/pages/home/report/PureReportActionItem.tsx index 4658f82e348b..e7c61216ece3 100644 --- a/src/pages/home/report/PureReportActionItem.tsx +++ b/src/pages/home/report/PureReportActionItem.tsx @@ -1671,10 +1671,12 @@ function PureReportActionItem({ return {content}; }; - if (action.actionName === CONST.REPORT.ACTIONS.TYPE.CREATED && !isHarvestCreatedExpenseReport) { + + let createdActionContent: React.JSX.Element | null = null; + if (action.actionName === CONST.REPORT.ACTIONS.TYPE.CREATED) { const transactionID = isMoneyRequestAction(parentReportActionForTransactionThread) ? getOriginalMessage(parentReportActionForTransactionThread)?.IOUTransactionID : undefined; - return ( + createdActionContent = ( ); + + if (!isHarvestCreatedExpenseReport) { + return createdActionContent; + } + + // Hide createdActionContent if harvest report is shown in MoneyRequestReportActionsList (multiple-transaction view) + // The harvest message will be rendered through renderItemContent instead + if (isHarvestCreatedExpenseReport && !parentReportActionForTransactionThread) { + createdActionContent = null; + } } if (isTripPreview(action) && isThreadReportParentAction) { @@ -1754,129 +1766,132 @@ function PureReportActionItem({ }; return ( - { - if (draftMessage === undefined) { - onPress?.(); - } - if (!Keyboard.isVisible()) { - return; - } - Keyboard.dismiss(); - }} - style={[action.pendingAction === CONST.RED_BRICK_ROAD_PENDING_ACTION.DELETE && !isDeletedParentAction ? styles.pointerEventsNone : styles.pointerEventsAuto]} - onPressIn={() => shouldUseNarrowLayout && canUseTouchScreen() && ControlSelection.block()} - onPressOut={() => ControlSelection.unblock()} - onSecondaryInteraction={showPopover} - preventDefaultContextMenu={draftMessage === undefined && !hasErrors} - withoutFocusOnSecondaryInteraction - accessibilityLabel={translate('accessibilityHints.chatMessage')} - accessible - > - { - setIsReportActionActive(false); - }} - onHoverOut={() => { - setIsReportActionActive(!!isReportActionLinked); + <> + { + if (draftMessage === undefined) { + onPress?.(); + } + if (!Keyboard.isVisible()) { + return; + } + Keyboard.dismiss(); }} + style={[action.pendingAction === CONST.RED_BRICK_ROAD_PENDING_ACTION.DELETE && !isDeletedParentAction ? styles.pointerEventsNone : styles.pointerEventsAuto]} + onPressIn={() => shouldUseNarrowLayout && canUseTouchScreen() && ControlSelection.block()} + onPressOut={() => ControlSelection.unblock()} + onSecondaryInteraction={showPopover} + preventDefaultContextMenu={draftMessage === undefined && !hasErrors} + withoutFocusOnSecondaryInteraction + accessibilityLabel={translate('accessibilityHints.chatMessage')} + accessible > - {(hovered) => ( - - {shouldDisplayNewMarker && (!shouldUseThreadDividerLine || !isFirstVisibleReportAction) && } - {shouldDisplayContextMenu && ( - - )} - { + setIsReportActionActive(false); + }} + onHoverOut={() => { + setIsReportActionActive(!!isReportActionLinked); + }} + > + {(hovered) => ( + + {shouldDisplayNewMarker && (!shouldUseThreadDividerLine || !isFirstVisibleReportAction) && } + {shouldDisplayContextMenu && ( + )} - > - - {renderSearchHeader( - <> - {isWhisper && ( - - - + {renderSearchHeader( + <> + {isWhisper && ( + + + + + + {translate('reportActionContextMenu.onlyVisible')} +   + + - - {translate('reportActionContextMenu.onlyVisible')} -   - - - - )} - {renderReportActionItem(!!hovered || !!isReportActionLinked, isWhisper, hasErrors)} - , - )} - + )} + {renderReportActionItem(!!hovered || !!isReportActionLinked, isWhisper, hasErrors)} + , + )} + + - - )} - - - - - { - dismissError(); - setShowConfirmDismissReceiptError(false); - }} - onCancel={() => { - setShowConfirmDismissReceiptError(false); - }} - title={translate('iou.dismissReceiptError')} - prompt={translate('iou.dismissReceiptErrorConfirmation')} - confirmText={translate('common.dismiss')} - cancelText={translate('common.cancel')} - shouldShowCancelButton - danger - /> - + )} + + + + + { + dismissError(); + setShowConfirmDismissReceiptError(false); + }} + onCancel={() => { + setShowConfirmDismissReceiptError(false); + }} + title={translate('iou.dismissReceiptError')} + prompt={translate('iou.dismissReceiptErrorConfirmation')} + confirmText={translate('common.dismiss')} + cancelText={translate('common.cancel')} + shouldShowCancelButton + danger + /> + + {createdActionContent} + ); } diff --git a/src/pages/home/report/ReportActionsList.tsx b/src/pages/home/report/ReportActionsList.tsx index 8bcad4613b84..4251996af965 100644 --- a/src/pages/home/report/ReportActionsList.tsx +++ b/src/pages/home/report/ReportActionsList.tsx @@ -194,6 +194,7 @@ function ReportActionsList({ const [isScrollToBottomEnabled, setIsScrollToBottomEnabled] = useState(false); const [actionIdToHighlight, setActionIdToHighlight] = useState(''); const [reportMetadata] = useOnyx(`${ONYXKEYS.COLLECTION.REPORT_METADATA}${report.reportID}`, {canBeMissing: true}); + const [reportNameValuePairs] = useOnyx(`${ONYXKEYS.COLLECTION.REPORT_NAME_VALUE_PAIRS}${report.reportID}`, {canBeMissing: true}); const backTo = route?.params?.backTo as string; // Display the new message indicator when comment linking and not close to the newest message. @@ -733,6 +734,8 @@ function ReportActionsList({ linkedTransactionRouteError={actionLinkedTransactionRouteError} userBillingFundID={userBillingFundID} isTryNewDotNVPDismissed={isTryNewDotNVPDismissed} + reportNameValuePairsOrigin={reportNameValuePairs?.origin} + reportNameValuePairsOriginalID={reportNameValuePairs?.originalID} /> ); }, @@ -760,6 +763,8 @@ function ReportActionsList({ userBillingFundID, isTryNewDotNVPDismissed, isReportArchived, + reportNameValuePairs?.origin, + reportNameValuePairs?.originalID, ], ); From fefd1258d35673a78073a972ad4ac049f9d3521e Mon Sep 17 00:00:00 2001 From: VH Date: Fri, 5 Dec 2025 22:32:44 +0700 Subject: [PATCH 22/36] Hide leave thread for harvest created action --- .../home/report/ContextMenu/BaseReportActionContextMenu.tsx | 3 +++ src/pages/home/report/ContextMenu/ContextMenuActions.tsx | 6 +++++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/src/pages/home/report/ContextMenu/BaseReportActionContextMenu.tsx b/src/pages/home/report/ContextMenu/BaseReportActionContextMenu.tsx index 5dd6ac912b1f..ebe917b9581d 100755 --- a/src/pages/home/report/ContextMenu/BaseReportActionContextMenu.tsx +++ b/src/pages/home/report/ContextMenu/BaseReportActionContextMenu.tsx @@ -31,6 +31,7 @@ import { getHarvestOriginalReportID, getSourceIDFromReportAction, isArchivedNonExpenseReport, + isHarvestCreatedExpenseReport, isInvoiceReport as ReportUtilsIsInvoiceReport, isMoneyRequest as ReportUtilsIsMoneyRequest, isMoneyRequestReport as ReportUtilsIsMoneyRequestReport, @@ -227,6 +228,7 @@ function BaseReportActionContextMenu({ !isArchivedNonExpenseReport(transactionThreadReportID ? childReport : parentReport, transactionThreadReportID ? isChildReportArchived : isParentReportArchived); const shouldEnableArrowNavigation = !isMini && (isVisible || shouldKeepOpen); + const isHarvestReport = useMemo(() => isHarvestCreatedExpenseReport(reportNameValuePairs?.origin, reportNameValuePairs?.originalID), [reportNameValuePairs?.origin]); let filteredContextMenuActions = ContextMenuActions.filter( (contextAction) => !disabledActions.includes(contextAction) && @@ -252,6 +254,7 @@ function BaseReportActionContextMenu({ isDebugModeEnabled, iouTransaction, transactions, + isHarvestReport, }), ); diff --git a/src/pages/home/report/ContextMenu/ContextMenuActions.tsx b/src/pages/home/report/ContextMenu/ContextMenuActions.tsx index 47b57ec040b0..3e36db787027 100644 --- a/src/pages/home/report/ContextMenu/ContextMenuActions.tsx +++ b/src/pages/home/report/ContextMenu/ContextMenuActions.tsx @@ -83,6 +83,7 @@ import { isActionableTrackExpense, isActionOfType, isCardIssuedAction, + isCreatedAction, isCreatedTaskReportAction, isDeletedAction as isDeletedActionReportActionsUtils, isMarkAsClosedAction, @@ -209,6 +210,7 @@ type ShouldShow = (args: { transactions?: OnyxCollection; moneyRequestReport?: OnyxEntry; moneyRequestPolicy?: OnyxEntry; + isHarvestReport?: boolean; }) => boolean; type ContextMenuActionPayload = { @@ -501,7 +503,7 @@ const ContextMenuActions: ContextMenuAction[] = [ isAnonymousAction: false, textTranslateKey: 'reportActionContextMenu.leaveThread', icon: Expensicons.Exit, - shouldShow: ({reportAction, isArchivedRoom, isThreadReportParentAction}) => { + shouldShow: ({reportAction, isArchivedRoom, isThreadReportParentAction, isHarvestReport}) => { const childReportNotificationPreference = getChildReportNotificationPreferenceReportUtils(reportAction); const isDeletedAction = isDeletedActionReportActionsUtils(reportAction); const shouldDisplayThreadReplies = shouldDisplayThreadRepliesReportUtils(reportAction, isThreadReportParentAction); @@ -509,12 +511,14 @@ const ContextMenuActions: ContextMenuAction[] = [ const isWhisperAction = isWhisperActionReportActionsUtils(reportAction) || isActionableTrackExpense(reportAction); const isExpenseReportAction = isMoneyRequestAction(reportAction) || isReportPreviewActionReportActionsUtils(reportAction); const isTaskAction = isCreatedTaskReportAction(reportAction); + const isHarvestCreatedExpenseReportAction = isHarvestReport && isCreatedAction(reportAction); return ( subscribed && !isWhisperAction && !isTaskAction && !isExpenseReportAction && !isThreadReportParentAction && + !isHarvestCreatedExpenseReportAction && (shouldDisplayThreadReplies || (!isDeletedAction && !isArchivedRoom)) ); }, From 8091288a1fa117fa1b8ea3c8a9ce6bde11cb1c64 Mon Sep 17 00:00:00 2001 From: VH Date: Fri, 5 Dec 2025 22:40:32 +0700 Subject: [PATCH 23/36] refactor: use isHarvestReport flag instead of reportNameValuePairs in context menu - Replace reportNameValuePairs with isHarvestReport in ContextMenuActionPayload type - Update BaseReportActionContextMenu to pass isHarvestReport to payload - Simplify copy message logic to check isHarvestReport directly - Remove dependency on reportNameValuePairs origin and originalID in payload --- .../report/ContextMenu/BaseReportActionContextMenu.tsx | 2 +- src/pages/home/report/ContextMenu/ContextMenuActions.tsx | 8 +++----- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/src/pages/home/report/ContextMenu/BaseReportActionContextMenu.tsx b/src/pages/home/report/ContextMenu/BaseReportActionContextMenu.tsx index ebe917b9581d..d37f9f229a28 100755 --- a/src/pages/home/report/ContextMenu/BaseReportActionContextMenu.tsx +++ b/src/pages/home/report/ContextMenu/BaseReportActionContextMenu.tsx @@ -373,7 +373,7 @@ function BaseReportActionContextMenu({ interceptAnonymousUser, openOverflowMenu, setIsEmojiPickerActive, - reportNameValuePairs, + isHarvestReport, moneyRequestAction, card, originalReport, diff --git a/src/pages/home/report/ContextMenu/ContextMenuActions.tsx b/src/pages/home/report/ContextMenu/ContextMenuActions.tsx index 3e36db787027..e3719dff6e8b 100644 --- a/src/pages/home/report/ContextMenu/ContextMenuActions.tsx +++ b/src/pages/home/report/ContextMenu/ContextMenuActions.tsx @@ -129,7 +129,6 @@ import { getUpgradeWorkspaceMessage, getWorkspaceNameUpdatedMessage, isExpenseReport, - isHarvestCreatedExpenseReport, shouldDisableThread, shouldDisplayThreadReplies as shouldDisplayThreadRepliesReportUtils, } from '@libs/ReportUtils'; @@ -158,7 +157,6 @@ import type { PolicyTagLists, ReportAction, ReportActionReactions, - ReportNameValuePairs, Report as ReportType, Transaction, } from '@src/types/onyx'; @@ -233,7 +231,7 @@ type ContextMenuActionPayload = { moneyRequestAction: ReportAction | undefined; card?: Card; originalReport: OnyxEntry; - reportNameValuePairs?: OnyxEntry; + isHarvestReport?: boolean; isTryNewDotNVPDismissed?: boolean; childReport?: OnyxEntry; movedFromReport?: OnyxEntry; @@ -599,7 +597,7 @@ const ContextMenuActions: ContextMenuAction[] = [ reportID, card, originalReport, - reportNameValuePairs, + isHarvestReport, isTryNewDotNVPDismissed, movedFromReport, movedToReport, @@ -832,7 +830,7 @@ const ContextMenuActions: ContextMenuAction[] = [ } else if (isActionableJoinRequest(reportAction)) { const displayMessage = getJoinRequestMessage(reportAction); Clipboard.setString(displayMessage); - } else if (isActionOfType(reportAction, CONST.REPORT.ACTIONS.TYPE.CREATED) && isHarvestCreatedExpenseReport(reportNameValuePairs?.origin, reportNameValuePairs?.originalID)) { + } else if (isActionOfType(reportAction, CONST.REPORT.ACTIONS.TYPE.CREATED) && isHarvestReport) { const harvestReportName = getReportName(harvestReport); const displayMessage = getHarvestCreatedExpenseReportMessage(harvestReport?.reportID, harvestReportName, translate); setClipboardMessage(displayMessage); From 2b6891ef8bc7d047dbe00ee487ada341254de665 Mon Sep 17 00:00:00 2001 From: VH Date: Fri, 5 Dec 2025 22:43:06 +0700 Subject: [PATCH 24/36] Run prettier --- src/libs/OptionsListUtils/index.ts | 5 ++++- src/libs/ReportUtils.ts | 4 +--- .../home/report/ContextMenu/ContextMenuActions.tsx | 13 +------------ src/pages/home/report/PureReportActionItem.tsx | 2 +- tests/unit/libs/MoneyRequestReportUtils.ts | 2 +- 5 files changed, 8 insertions(+), 18 deletions(-) diff --git a/src/libs/OptionsListUtils/index.ts b/src/libs/OptionsListUtils/index.ts index f00ae2f412bc..d0eca4ec3ac8 100644 --- a/src/libs/OptionsListUtils/index.ts +++ b/src/libs/OptionsListUtils/index.ts @@ -649,7 +649,10 @@ function getLastMessageTextForReport({ const reportNameValuePairs = allReportNameValuePairs?.[`${ONYXKEYS.COLLECTION.REPORT_NAME_VALUE_PAIRS}${reportID}`]; if (isHarvestCreatedExpenseReport(reportNameValuePairs?.origin, reportNameValuePairs?.originalID)) { const harvestReport = getReportOrDraftReport(reportNameValuePairs?.originalID); - lastMessageTextFromReport = formatReportLastMessageText(Parser.htmlToText(getHarvestCreatedExpenseReportMessage(harvestReport?.reportID, getReportName(harvestReport), translateLocal))); + lastMessageTextFromReport = formatReportLastMessageText( + // eslint-disable-next-line @typescript-eslint/no-deprecated + Parser.htmlToText(getHarvestCreatedExpenseReportMessage(harvestReport?.reportID, getReportName(harvestReport), translateLocal)), + ); } } else if (isMoneyRequestAction(lastReportAction)) { const properSchemaForMoneyRequestMessage = getReportPreviewMessage(report, lastReportAction, true, false, null, true); diff --git a/src/libs/ReportUtils.ts b/src/libs/ReportUtils.ts index 0544337ccf42..74f1a263e5e6 100644 --- a/src/libs/ReportUtils.ts +++ b/src/libs/ReportUtils.ts @@ -120,9 +120,9 @@ import Log from './Log'; import {isEmailPublicDomain} from './LoginUtils'; // eslint-disable-next-line import/no-cycle import {getForReportAction, getMovedReportID} from './ModifiedExpenseMessage'; +import getReportURLForCurrentContext from './Navigation/helpers/getReportURLForCurrentContext'; import getStateFromPath from './Navigation/helpers/getStateFromPath'; import {isFullScreenName} from './Navigation/helpers/isNavigatorName'; -import getReportURLForCurrentContext from './Navigation/helpers/getReportURLForCurrentContext'; import {linkingConfig} from './Navigation/linkingConfig'; import Navigation, {navigationRef} from './Navigation/Navigation'; import type {MoneyRequestNavigatorParamList, ReportsSplitNavigatorParamList} from './Navigation/types'; @@ -12862,8 +12862,6 @@ function isWorkspaceMemberLeavingWorkspaceRoom(report: OnyxEntry, isPoli return (report.visibility === CONST.REPORT.VISIBILITY.RESTRICTED || hasAccessPolicyExpenseChat) && isPolicyEmployee; } - - /** * Checks if all selected items have the necessary Onyx data hydrated for bulk rejection. */ diff --git a/src/pages/home/report/ContextMenu/ContextMenuActions.tsx b/src/pages/home/report/ContextMenu/ContextMenuActions.tsx index e3719dff6e8b..e414fbcfad98 100644 --- a/src/pages/home/report/ContextMenu/ContextMenuActions.tsx +++ b/src/pages/home/report/ContextMenu/ContextMenuActions.tsx @@ -148,18 +148,7 @@ import { import CONST from '@src/CONST'; import type {TranslationPaths} from '@src/languages/types'; import ROUTES from '@src/ROUTES'; -import type { - Beta, - Card, - Download as DownloadOnyx, - OnyxInputOrEntry, - Policy, - PolicyTagLists, - ReportAction, - ReportActionReactions, - Report as ReportType, - Transaction, -} from '@src/types/onyx'; +import type {Beta, Card, Download as DownloadOnyx, OnyxInputOrEntry, Policy, PolicyTagLists, ReportAction, ReportActionReactions, Report as ReportType, Transaction} from '@src/types/onyx'; import type IconAsset from '@src/types/utils/IconAsset'; import KeyboardUtils from '@src/utils/keyboard'; import type {ContextMenuAnchor} from './ReportActionContextMenu'; diff --git a/src/pages/home/report/PureReportActionItem.tsx b/src/pages/home/report/PureReportActionItem.tsx index e7c61216ece3..0ffa8d41b4fa 100644 --- a/src/pages/home/report/PureReportActionItem.tsx +++ b/src/pages/home/report/PureReportActionItem.tsx @@ -1671,7 +1671,7 @@ function PureReportActionItem({ return {content}; }; - + let createdActionContent: React.JSX.Element | null = null; if (action.actionName === CONST.REPORT.ACTIONS.TYPE.CREATED) { const transactionID = isMoneyRequestAction(parentReportActionForTransactionThread) ? getOriginalMessage(parentReportActionForTransactionThread)?.IOUTransactionID : undefined; diff --git a/tests/unit/libs/MoneyRequestReportUtils.ts b/tests/unit/libs/MoneyRequestReportUtils.ts index 25b054a06c90..f592007588bb 100644 --- a/tests/unit/libs/MoneyRequestReportUtils.ts +++ b/tests/unit/libs/MoneyRequestReportUtils.ts @@ -1,4 +1,4 @@ -import {getThreadReportIDsForTransactions, getAllNonDeletedTransactions, isActionVisibleOnMoneyRequestReport} from '@libs/MoneyRequestReportUtils'; +import {getAllNonDeletedTransactions, getThreadReportIDsForTransactions, isActionVisibleOnMoneyRequestReport} from '@libs/MoneyRequestReportUtils'; import CONST from '@src/CONST'; import type {ReportAction, Transaction} from '@src/types/onyx'; import {actionR14932, actionR98765} from '../../../__mocks__/reportData/actions'; From 803326c5d61d1ee5f87ac0198bc3f4ddb90940ed Mon Sep 17 00:00:00 2001 From: VH Date: Sun, 7 Dec 2025 22:38:26 +0700 Subject: [PATCH 25/36] fix: UI is blink for harvest created one transaction report --- src/pages/home/report/PureReportActionItem.tsx | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/pages/home/report/PureReportActionItem.tsx b/src/pages/home/report/PureReportActionItem.tsx index 0ffa8d41b4fa..09fd5997dafe 100644 --- a/src/pages/home/report/PureReportActionItem.tsx +++ b/src/pages/home/report/PureReportActionItem.tsx @@ -1766,7 +1766,8 @@ function PureReportActionItem({ }; return ( - <> + + {createdActionContent} { @@ -1890,8 +1891,7 @@ function PureReportActionItem({ danger /> - {createdActionContent} - + ); } From f60382eaacf15a706539e3be5b378bbcb14ba4ee Mon Sep 17 00:00:00 2001 From: VH Date: Sun, 7 Dec 2025 22:51:30 +0700 Subject: [PATCH 26/36] Fix merge main --- src/libs/ReportUtils.ts | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/libs/ReportUtils.ts b/src/libs/ReportUtils.ts index 7106180e18a6..0615ac5530e6 100644 --- a/src/libs/ReportUtils.ts +++ b/src/libs/ReportUtils.ts @@ -11151,9 +11151,6 @@ function getReportActionActorAccountID( return actorAccountID; } - case CONST.REPORT.ACTIONS.TYPE.SUBMITTED: - case CONST.REPORT.ACTIONS.TYPE.SUBMITTED_AND_CLOSED: - return reportAction?.adminAccountID ?? reportAction?.actorAccountID; case CONST.REPORT.ACTIONS.TYPE.CREATED: { const reportNameValuePairs = allReportNameValuePair?.[`${ONYXKEYS.COLLECTION.REPORT_NAME_VALUE_PAIRS}${iouReport?.reportID}`]; if (isHarvestCreatedExpenseReport(reportNameValuePairs?.origin, reportNameValuePairs?.originalID)) { @@ -11162,6 +11159,8 @@ function getReportActionActorAccountID( return reportAction?.actorAccountID; } + case CONST.REPORT.ACTIONS.TYPE.SUBMITTED: + case CONST.REPORT.ACTIONS.TYPE.SUBMITTED_AND_CLOSED: case CONST.REPORT.ACTIONS.TYPE.APPROVED: case CONST.REPORT.ACTIONS.TYPE.FORWARDED: case CONST.REPORT.ACTIONS.TYPE.IOU: { From a84980530a8a9772a8c249b1dea3ac7ca0c2d8a6 Mon Sep 17 00:00:00 2001 From: Vinh Hoang Date: Mon, 8 Dec 2025 22:14:43 +0700 Subject: [PATCH 27/36] Apply suggestions from code review Co-authored-by: parasharrajat --- .../home/report/ContextMenu/BaseReportActionContextMenu.tsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/pages/home/report/ContextMenu/BaseReportActionContextMenu.tsx b/src/pages/home/report/ContextMenu/BaseReportActionContextMenu.tsx index d37f9f229a28..acf938172928 100755 --- a/src/pages/home/report/ContextMenu/BaseReportActionContextMenu.tsx +++ b/src/pages/home/report/ContextMenu/BaseReportActionContextMenu.tsx @@ -161,7 +161,7 @@ function BaseReportActionContextMenu({ const [isDebugModeEnabled] = useOnyx(ONYXKEYS.IS_DEBUG_MODE_ENABLED, {canBeMissing: true}); const [report] = useOnyx(`${ONYXKEYS.COLLECTION.REPORT}${reportID}`, {canBeMissing: true}); const [reportNameValuePairs] = useOnyx(`${ONYXKEYS.COLLECTION.REPORT_NAME_VALUE_PAIRS}${reportID}`, {canBeMissing: true}); - const [harvestReport] = useOnyx(`${ONYXKEYS.COLLECTION.REPORT}${getHarvestOriginalReportID(reportNameValuePairs?.origin, reportNameValuePairs?.originalID)}`, {canBeMissing: true}); + const [harvestReport] = useOnyx(`${ONYXKEYS.COLLECTION.REPORT}${getNonEmptyStringOnyxID(getHarvestOriginalReportID(reportNameValuePairs?.origin, reportNameValuePairs?.originalID))}`, {canBeMissing: true}); const [originalReport] = useOnyx(`${ONYXKEYS.COLLECTION.REPORT}${originalReportID}`, {canBeMissing: true}); const isOriginalReportArchived = useReportIsArchived(originalReportID); const policyID = report?.policyID; @@ -228,7 +228,7 @@ function BaseReportActionContextMenu({ !isArchivedNonExpenseReport(transactionThreadReportID ? childReport : parentReport, transactionThreadReportID ? isChildReportArchived : isParentReportArchived); const shouldEnableArrowNavigation = !isMini && (isVisible || shouldKeepOpen); - const isHarvestReport = useMemo(() => isHarvestCreatedExpenseReport(reportNameValuePairs?.origin, reportNameValuePairs?.originalID), [reportNameValuePairs?.origin]); + const isHarvestReport = useMemo(() => isHarvestCreatedExpenseReport(reportNameValuePairs?.origin, reportNameValuePairs?.originalID), [reportNameValuePairs?.origin, reportNameValuePairs?.originalID]); let filteredContextMenuActions = ContextMenuActions.filter( (contextAction) => !disabledActions.includes(contextAction) && From 2ab32b4da2bb7219f0e60fb028ad567653b6ba52 Mon Sep 17 00:00:00 2001 From: VH Date: Mon, 8 Dec 2025 22:37:01 +0700 Subject: [PATCH 28/36] Refactor as suggested. --- .../home/report/PureReportActionItem.tsx | 23 ++++++++----------- 1 file changed, 10 insertions(+), 13 deletions(-) diff --git a/src/pages/home/report/PureReportActionItem.tsx b/src/pages/home/report/PureReportActionItem.tsx index 9e735aaafb71..34cb737e44f7 100644 --- a/src/pages/home/report/PureReportActionItem.tsx +++ b/src/pages/home/report/PureReportActionItem.tsx @@ -1671,11 +1671,10 @@ function PureReportActionItem({ return {content}; }; - let createdActionContent: React.JSX.Element | null = null; - if (action.actionName === CONST.REPORT.ACTIONS.TYPE.CREATED) { + const createdActionContent = useMemo(() => { const transactionID = isMoneyRequestAction(parentReportActionForTransactionThread) ? getOriginalMessage(parentReportActionForTransactionThread)?.IOUTransactionID : undefined; - createdActionContent = ( + return ( ); + }, [contextValue, allReports, parentReportAction, parentReport, draftMessage, shouldHideThreadDividerLine, parentReportActionForTransactionThread]); - if (!isHarvestCreatedExpenseReport) { - return createdActionContent; - } - - // Hide createdActionContent if harvest report is shown in MoneyRequestReportActionsList (multiple-transaction view) - // The harvest message will be rendered through renderItemContent instead - if (isHarvestCreatedExpenseReport && !parentReportActionForTransactionThread) { - createdActionContent = null; - } + if (action.actionName === CONST.REPORT.ACTIONS.TYPE.CREATED && !isHarvestCreatedExpenseReport) { + return createdActionContent; } + // Should show createdActionContent if: + // - Harvest report is shown in ReportActionsList (one-transaction view) + const shouldShowCreatedAction = !!isHarvestCreatedExpenseReport && !!parentReportActionForTransactionThread; + if (isTripPreview(action) && isThreadReportParentAction) { return ; } @@ -1765,7 +1762,7 @@ function PureReportActionItem({ return ( - {createdActionContent} + {shouldShowCreatedAction && createdActionContent} { From 65ca1c659293c8a2519b38aa68405ddcc5357405 Mon Sep 17 00:00:00 2001 From: VH Date: Mon, 8 Dec 2025 22:39:19 +0700 Subject: [PATCH 29/36] Run prettier --- .../report/ContextMenu/BaseReportActionContextMenu.tsx | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/pages/home/report/ContextMenu/BaseReportActionContextMenu.tsx b/src/pages/home/report/ContextMenu/BaseReportActionContextMenu.tsx index acf938172928..1f4273e40318 100755 --- a/src/pages/home/report/ContextMenu/BaseReportActionContextMenu.tsx +++ b/src/pages/home/report/ContextMenu/BaseReportActionContextMenu.tsx @@ -161,7 +161,9 @@ function BaseReportActionContextMenu({ const [isDebugModeEnabled] = useOnyx(ONYXKEYS.IS_DEBUG_MODE_ENABLED, {canBeMissing: true}); const [report] = useOnyx(`${ONYXKEYS.COLLECTION.REPORT}${reportID}`, {canBeMissing: true}); const [reportNameValuePairs] = useOnyx(`${ONYXKEYS.COLLECTION.REPORT_NAME_VALUE_PAIRS}${reportID}`, {canBeMissing: true}); - const [harvestReport] = useOnyx(`${ONYXKEYS.COLLECTION.REPORT}${getNonEmptyStringOnyxID(getHarvestOriginalReportID(reportNameValuePairs?.origin, reportNameValuePairs?.originalID))}`, {canBeMissing: true}); + const [harvestReport] = useOnyx(`${ONYXKEYS.COLLECTION.REPORT}${getNonEmptyStringOnyxID(getHarvestOriginalReportID(reportNameValuePairs?.origin, reportNameValuePairs?.originalID))}`, { + canBeMissing: true, + }); const [originalReport] = useOnyx(`${ONYXKEYS.COLLECTION.REPORT}${originalReportID}`, {canBeMissing: true}); const isOriginalReportArchived = useReportIsArchived(originalReportID); const policyID = report?.policyID; @@ -228,7 +230,10 @@ function BaseReportActionContextMenu({ !isArchivedNonExpenseReport(transactionThreadReportID ? childReport : parentReport, transactionThreadReportID ? isChildReportArchived : isParentReportArchived); const shouldEnableArrowNavigation = !isMini && (isVisible || shouldKeepOpen); - const isHarvestReport = useMemo(() => isHarvestCreatedExpenseReport(reportNameValuePairs?.origin, reportNameValuePairs?.originalID), [reportNameValuePairs?.origin, reportNameValuePairs?.originalID]); + const isHarvestReport = useMemo( + () => isHarvestCreatedExpenseReport(reportNameValuePairs?.origin, reportNameValuePairs?.originalID), + [reportNameValuePairs?.origin, reportNameValuePairs?.originalID], + ); let filteredContextMenuActions = ContextMenuActions.filter( (contextAction) => !disabledActions.includes(contextAction) && From aa2b2c2838ed0cd4da8940831900af365b02c4a5 Mon Sep 17 00:00:00 2001 From: VH Date: Tue, 9 Dec 2025 17:48:41 +0700 Subject: [PATCH 30/36] Fix eslint --- src/libs/ReportUtils.ts | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/libs/ReportUtils.ts b/src/libs/ReportUtils.ts index b5f98b1c9a5a..7bd8b85865c1 100644 --- a/src/libs/ReportUtils.ts +++ b/src/libs/ReportUtils.ts @@ -7037,6 +7037,7 @@ function getMovedTransactionMessage(action: ReportAction) { const fromReport = allReports?.[`${ONYXKEYS.COLLECTION.REPORT}${fromReportID}`]; const report = fromReport ?? toReport; + // eslint-disable-next-line @typescript-eslint/no-deprecated const reportName = getReportName(report) ?? report?.reportName ?? ''; let reportUrl = getReportURLForCurrentContext(report?.reportID); if (typeof fromReportID === 'undefined') { @@ -7066,6 +7067,7 @@ function getUnreportedTransactionMessage(action: ReportAction) { const fromReport = allReports?.[`${ONYXKEYS.COLLECTION.REPORT}${fromReportID}`]; + // eslint-disable-next-line @typescript-eslint/no-deprecated const reportName = getReportName(fromReport) ?? fromReport?.reportName ?? ''; let reportUrl = `${environmentURL}/r/${fromReport?.reportID}`; From 221acc174f0672380c9faece5d4d3c330492bba5 Mon Sep 17 00:00:00 2001 From: VH Date: Tue, 9 Dec 2025 17:50:01 +0700 Subject: [PATCH 31/36] Run prettier --- src/languages/es.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/languages/es.ts b/src/languages/es.ts index 0aa6606b90b6..ba3124248f77 100644 --- a/src/languages/es.ts +++ b/src/languages/es.ts @@ -2,7 +2,7 @@ import {CONST as COMMON_CONST} from 'expensify-common'; import dedent from '@libs/StringUtils/dedent'; import CONST from '@src/CONST'; import type en from './en'; -import type {HarvestCreatedExpenseReportParams, BeginningOfChatHistoryParams, TagSelectionParams, ViolationsRterParams} from './params'; +import type {BeginningOfChatHistoryParams, HarvestCreatedExpenseReportParams, TagSelectionParams, ViolationsRterParams} from './params'; import type {TranslationDeepObject} from './types'; /* eslint-disable max-len */ From 1dfb917998af85124a21171327f6d96366fc47bf Mon Sep 17 00:00:00 2001 From: VH Date: Thu, 11 Dec 2025 21:56:52 +0700 Subject: [PATCH 32/36] Use getNonEmptyStringOnyxID --- .../home/report/ContextMenu/BaseReportActionContextMenu.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pages/home/report/ContextMenu/BaseReportActionContextMenu.tsx b/src/pages/home/report/ContextMenu/BaseReportActionContextMenu.tsx index 33cfb79c2cde..3ea068da3ff1 100755 --- a/src/pages/home/report/ContextMenu/BaseReportActionContextMenu.tsx +++ b/src/pages/home/report/ContextMenu/BaseReportActionContextMenu.tsx @@ -160,7 +160,7 @@ function BaseReportActionContextMenu({ const [transaction] = useOnyx(`${ONYXKEYS.COLLECTION.TRANSACTION}${getNonEmptyStringOnyxID(transactionID)}`, {canBeMissing: true}); const [isDebugModeEnabled] = useOnyx(ONYXKEYS.IS_DEBUG_MODE_ENABLED, {canBeMissing: true}); const [report] = useOnyx(`${ONYXKEYS.COLLECTION.REPORT}${reportID}`, {canBeMissing: true}); - const [reportNameValuePairs] = useOnyx(`${ONYXKEYS.COLLECTION.REPORT_NAME_VALUE_PAIRS}${reportID}`, {canBeMissing: true}); + const [reportNameValuePairs] = useOnyx(`${ONYXKEYS.COLLECTION.REPORT_NAME_VALUE_PAIRS}${getNonEmptyStringOnyxID(reportID)}`, {canBeMissing: true}); const [harvestReport] = useOnyx(`${ONYXKEYS.COLLECTION.REPORT}${getNonEmptyStringOnyxID(getHarvestOriginalReportID(reportNameValuePairs?.origin, reportNameValuePairs?.originalID))}`, { canBeMissing: true, }); From 06b9ed491ba179cf9bd76caac2e1a09ba9c35865 Mon Sep 17 00:00:00 2001 From: VH Date: Thu, 11 Dec 2025 23:03:25 +0700 Subject: [PATCH 33/36] Fix render repeated MoneyRequestView --- src/pages/home/report/PureReportActionItem.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pages/home/report/PureReportActionItem.tsx b/src/pages/home/report/PureReportActionItem.tsx index 98aaf8fd46e7..0a76d12e8cc4 100644 --- a/src/pages/home/report/PureReportActionItem.tsx +++ b/src/pages/home/report/PureReportActionItem.tsx @@ -1706,7 +1706,7 @@ function PureReportActionItem({ // Should show createdActionContent if: // - Harvest report is shown in ReportActionsList (one-transaction view) - const shouldShowCreatedAction = !!isHarvestCreatedExpenseReport && !!parentReportActionForTransactionThread; + const shouldShowCreatedAction = action.actionName === CONST.REPORT.ACTIONS.TYPE.CREATED && !!isHarvestCreatedExpenseReport && !!parentReportActionForTransactionThread; if (isTripPreview(action) && isThreadReportParentAction) { return ; From c215ffd1c12d33f408fa1b6519c2ea9a8c3ab4ec Mon Sep 17 00:00:00 2001 From: VH Date: Fri, 12 Dec 2025 22:28:48 +0700 Subject: [PATCH 34/36] fix: hide join thread option for harvest created expense reports - Add isHarvestReport parameter to joinThread shouldShow function - Check if action is harvest created expense report - Prevent showing join thread for harvest reports to maintain consistency with leave thread behavior --- src/pages/home/report/ContextMenu/ContextMenuActions.tsx | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/pages/home/report/ContextMenu/ContextMenuActions.tsx b/src/pages/home/report/ContextMenu/ContextMenuActions.tsx index 9e648c638529..9649804f7699 100644 --- a/src/pages/home/report/ContextMenu/ContextMenuActions.tsx +++ b/src/pages/home/report/ContextMenu/ContextMenuActions.tsx @@ -454,7 +454,7 @@ const ContextMenuActions: ContextMenuAction[] = [ isAnonymousAction: false, textTranslateKey: 'reportActionContextMenu.joinThread', icon: Expensicons.Bell, - shouldShow: ({reportAction, isArchivedRoom, isThreadReportParentAction}) => { + shouldShow: ({reportAction, isArchivedRoom, isThreadReportParentAction, isHarvestReport}) => { const childReportNotificationPreference = getChildReportNotificationPreferenceReportUtils(reportAction); const isDeletedAction = isDeletedActionReportActionsUtils(reportAction); const shouldDisplayThreadReplies = shouldDisplayThreadRepliesReportUtils(reportAction, isThreadReportParentAction); @@ -462,12 +462,14 @@ const ContextMenuActions: ContextMenuAction[] = [ const isWhisperAction = isWhisperActionReportActionsUtils(reportAction) || isActionableTrackExpense(reportAction); const isExpenseReportAction = isMoneyRequestAction(reportAction) || isReportPreviewActionReportActionsUtils(reportAction); const isTaskAction = isCreatedTaskReportAction(reportAction); + const isHarvestCreatedExpenseReportAction = isHarvestReport && isCreatedAction(reportAction); return ( !subscribed && !isWhisperAction && !isTaskAction && !isExpenseReportAction && !isThreadReportParentAction && + !isHarvestCreatedExpenseReportAction && (shouldDisplayThreadReplies || (!isDeletedAction && !isArchivedRoom)) ); }, From 302a04f9414d13a9a0f934899f9ba6f06fae6075 Mon Sep 17 00:00:00 2001 From: VH Date: Fri, 12 Dec 2025 22:40:16 +0700 Subject: [PATCH 35/36] revert: harvest created expense report message in LHN --- src/libs/OptionsListUtils/index.ts | 11 ----------- 1 file changed, 11 deletions(-) diff --git a/src/libs/OptionsListUtils/index.ts b/src/libs/OptionsListUtils/index.ts index 263a77c4ab43..8fb4177cd352 100644 --- a/src/libs/OptionsListUtils/index.ts +++ b/src/libs/OptionsListUtils/index.ts @@ -37,7 +37,6 @@ import { getChangedApproverActionMessage, getCombinedReportActions, getExportIntegrationLastMessageText, - getHarvestCreatedExpenseReportMessage, getIOUReportIDFromReportActionPreview, getJoinRequestMessage, getLastVisibleMessage, @@ -118,7 +117,6 @@ import { isDM, isDraftReport, isExpenseReport, - isHarvestCreatedExpenseReport, isHiddenForCurrentUser, isInvoiceRoom, isMoneyRequest, @@ -649,15 +647,6 @@ function getLastMessageTextForReport({ lastMessageTextFromReport = translateLocal(`reportArchiveReasons.default`); } } - } else if (report?.lastActionType === CONST.REPORT.ACTIONS.TYPE.CREATED) { - const reportNameValuePairs = allReportNameValuePairs?.[`${ONYXKEYS.COLLECTION.REPORT_NAME_VALUE_PAIRS}${reportID}`]; - if (isHarvestCreatedExpenseReport(reportNameValuePairs?.origin, reportNameValuePairs?.originalID)) { - const harvestReport = getReportOrDraftReport(reportNameValuePairs?.originalID); - lastMessageTextFromReport = formatReportLastMessageText( - // eslint-disable-next-line @typescript-eslint/no-deprecated - Parser.htmlToText(getHarvestCreatedExpenseReportMessage(harvestReport?.reportID, getReportName(harvestReport), translateLocal)), - ); - } } else if (isMoneyRequestAction(lastReportAction)) { const properSchemaForMoneyRequestMessage = getReportPreviewMessage(report, lastReportAction, true, false, null, true); lastMessageTextFromReport = formatReportLastMessageText(Parser.htmlToText(properSchemaForMoneyRequestMessage)); From 124ab7b3a17ac29ac90b8f42f062d8c8574c07f2 Mon Sep 17 00:00:00 2001 From: VH Date: Mon, 15 Dec 2025 21:07:38 +0700 Subject: [PATCH 36/36] Fix react-compiler-compliance-check --- .../home/report/ContextMenu/BaseReportActionContextMenu.tsx | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/pages/home/report/ContextMenu/BaseReportActionContextMenu.tsx b/src/pages/home/report/ContextMenu/BaseReportActionContextMenu.tsx index f269baeb092f..d48263b3c2db 100755 --- a/src/pages/home/report/ContextMenu/BaseReportActionContextMenu.tsx +++ b/src/pages/home/report/ContextMenu/BaseReportActionContextMenu.tsx @@ -246,10 +246,8 @@ function BaseReportActionContextMenu({ !isArchivedNonExpenseReport(transactionThreadReportID ? childReport : parentReport, transactionThreadReportID ? isChildReportArchived : isParentReportArchived); const shouldEnableArrowNavigation = !isMini && (isVisible || shouldKeepOpen); - const isHarvestReport = useMemo( - () => isHarvestCreatedExpenseReport(reportNameValuePairs?.origin, reportNameValuePairs?.originalID), - [reportNameValuePairs?.origin, reportNameValuePairs?.originalID], - ); + const isHarvestReport = isHarvestCreatedExpenseReport(reportNameValuePairs?.origin, reportNameValuePairs?.originalID); + let filteredContextMenuActions = ContextMenuActions.filter( (contextAction) => !disabledActions.includes(contextAction) &&