diff --git a/src/components/MoneyReportHeader.tsx b/src/components/MoneyReportHeader.tsx index 8883c246e821..e33a2431f66f 100644 --- a/src/components/MoneyReportHeader.tsx +++ b/src/components/MoneyReportHeader.tsx @@ -1231,7 +1231,7 @@ function MoneyReportHeader({ duplicateExpenseTransaction([transaction]); }, - shouldCloseModalOnSelect: false, + shouldCloseModalOnSelect: activePolicyExpenseChat?.iouReportID === moneyRequestReport?.reportID, }, [CONST.REPORT.SECONDARY_ACTIONS.CHANGE_WORKSPACE]: { text: translate('iou.changeWorkspace'), diff --git a/src/components/PopoverMenu.tsx b/src/components/PopoverMenu.tsx index cbb34e0ac02d..ea703609f0a9 100644 --- a/src/components/PopoverMenu.tsx +++ b/src/components/PopoverMenu.tsx @@ -309,19 +309,19 @@ function BasePopoverMenu({ setEnteredSubMenuIndexes([...enteredSubMenuIndexes, index]); const selectedSubMenuItemIndex = selectedItem?.subMenuItems.findIndex((option) => option.isSelected); setFocusedIndex(selectedSubMenuItemIndex); + } else if (selectedItem.shouldCloseModalOnSelect === false) { + onItemSelected?.(selectedItem, index, event); + selectedItem.onSelected?.(); + setFocusedIndex(-1); } else if (selectedItem.shouldCallAfterModalHide && (!isSafari() || shouldAvoidSafariException)) { onItemSelected?.(selectedItem, index, event); - if (selectedItem.shouldCloseModalOnSelect !== false) { - close( - () => { - selectedItem.onSelected?.(); - }, - undefined, - selectedItem.shouldCloseAllModals, - ); - } else { - selectedItem.onSelected?.(); - } + close( + () => { + selectedItem.onSelected?.(); + }, + undefined, + selectedItem.shouldCloseAllModals, + ); } else { onItemSelected?.(selectedItem, index, event); selectedItem.onSelected?.(); diff --git a/src/libs/ReportSecondaryActionUtils.ts b/src/libs/ReportSecondaryActionUtils.ts index d8b3ff80303e..ecc197349d48 100644 --- a/src/libs/ReportSecondaryActionUtils.ts +++ b/src/libs/ReportSecondaryActionUtils.ts @@ -767,8 +767,7 @@ function getSecondaryReportActions({ options.push(CONST.REPORT.SECONDARY_ACTIONS.MERGE); } - // Disabled for now to fix deploy blockers. Will be re-enabled in https://github.com/Expensify/App/pull/77343 - if (isDuplicateAction(report, reportTransactions) && false) { + if (isDuplicateAction(report, reportTransactions)) { options.push(CONST.REPORT.SECONDARY_ACTIONS.DUPLICATE); } @@ -848,8 +847,7 @@ function getSecondaryTransactionThreadActions( options.push(CONST.REPORT.TRANSACTION_SECONDARY_ACTIONS.MERGE); } - // Disabled for now to fix deploy blockers. Will be re-enabled in https://github.com/Expensify/App/pull/77343 - if (isDuplicateAction(parentReport, [reportTransaction]) && false) { + if (isDuplicateAction(parentReport, [reportTransaction])) { options.push(CONST.REPORT.TRANSACTION_SECONDARY_ACTIONS.DUPLICATE); } diff --git a/src/libs/actions/IOU.ts b/src/libs/actions/IOU.ts index c3381b0b394a..9bab1d4d9f93 100644 --- a/src/libs/actions/IOU.ts +++ b/src/libs/actions/IOU.ts @@ -6924,13 +6924,13 @@ function duplicateExpenseTransaction( ...transaction, ...transactionDetails, attendees: transactionDetails?.attendees as Attendee[] | undefined, - comment: transactionDetails?.comment, + comment: Parser.htmlToMarkdown(transactionDetails?.comment ?? ''), created: format(new Date(), CONST.DATE.FNS_FORMAT_STRING), customUnitRateID: transaction?.comment?.customUnit?.customUnitRateID, isTestDrive: transaction?.receipt?.isTestDriveReceipt, merchant: transaction?.modifiedMerchant ? transaction.modifiedMerchant : (transaction?.merchant ?? ''), modifiedAmount: undefined, - originalTransactionID: transaction?.comment?.originalTransactionID, + originalTransactionID: undefined, receipt: undefined, source: undefined, waypoints: transactionDetails?.waypoints as WaypointCollection | undefined, @@ -6945,12 +6945,6 @@ function duplicateExpenseTransaction( // If no workspace is provided the expense should be unreported if (!targetPolicy) { - const selfDMReport = allReports?.[`${ONYXKEYS.COLLECTION.REPORT}${findSelfDMReportID()}`]; - - if (!selfDMReport) { - return; - } - const trackExpenseParams: CreateTrackExpenseParams = { ...params, participantParams: { @@ -6961,7 +6955,7 @@ function duplicateExpenseTransaction( ...(params.transactionParams ?? {}), validWaypoints: transactionDetails?.waypoints as WaypointCollection | undefined, }, - report: selfDMReport, + report: undefined, isDraftPolicy: false, }; return trackExpense(trackExpenseParams); diff --git a/tests/unit/ReportSecondaryActionUtilsTest.ts b/tests/unit/ReportSecondaryActionUtilsTest.ts index af5c782e03b9..0510967f30cf 100644 --- a/tests/unit/ReportSecondaryActionUtilsTest.ts +++ b/tests/unit/ReportSecondaryActionUtilsTest.ts @@ -1721,50 +1721,49 @@ describe('getSecondaryAction', () => { expect(result).not.toContain(CONST.REPORT.SECONDARY_ACTIONS.REMOVE_HOLD); }); - // Will be re-enabled in https://github.com/Expensify/App/pull/77343 - // it('include DUPLICATE option for single-transaction expense report', () => { - // const report = { - // reportID: REPORT_ID, - // type: CONST.REPORT.TYPE.EXPENSE, - // ownerAccountID: EMPLOYEE_ACCOUNT_ID, - // statusNum: CONST.REPORT.STATUS_NUM.SUBMITTED, - // stateNum: CONST.REPORT.STATE_NUM.SUBMITTED, - // } as unknown as Report; - - // const TRANSACTION_ID = 'TRANSACTION_ID'; - - // const transaction1 = { - // transactionID: TRANSACTION_ID, - // reportID: REPORT_ID, - // } as unknown as Transaction; - - // const reportActions = [ - // { - // reportActionID: '1', - // actorAccountID: EMPLOYEE_ACCOUNT_ID, - // actionName: CONST.REPORT.ACTIONS.TYPE.IOU, - // originalMessage: { - // IOUTransactionID: TRANSACTION_ID, - // IOUReportID: REPORT_ID, - // }, - // }, - // ] as unknown as ReportAction[]; - - // const policy = {} as unknown as Policy; - - // const result = getSecondaryReportActions({ - // currentUserEmail: EMPLOYEE_EMAIL, - // currentUserAccountID: EMPLOYEE_ACCOUNT_ID, - // report, - // chatReport, - // reportTransactions: [transaction1], - // originalTransaction: {} as Transaction, - // violations: {}, - // policy, - // reportActions, - // }); - // expect(result.includes(CONST.REPORT.SECONDARY_ACTIONS.DUPLICATE)).toBe(true); - // }); + it('include DUPLICATE option for single-transaction expense report', () => { + const report = { + reportID: REPORT_ID, + type: CONST.REPORT.TYPE.EXPENSE, + ownerAccountID: EMPLOYEE_ACCOUNT_ID, + statusNum: CONST.REPORT.STATUS_NUM.SUBMITTED, + stateNum: CONST.REPORT.STATE_NUM.SUBMITTED, + } as unknown as Report; + + const TRANSACTION_ID = 'TRANSACTION_ID'; + + const transaction1 = { + transactionID: TRANSACTION_ID, + reportID: REPORT_ID, + } as unknown as Transaction; + + const reportActions = [ + { + reportActionID: '1', + actorAccountID: EMPLOYEE_ACCOUNT_ID, + actionName: CONST.REPORT.ACTIONS.TYPE.IOU, + originalMessage: { + IOUTransactionID: TRANSACTION_ID, + IOUReportID: REPORT_ID, + }, + }, + ] as unknown as ReportAction[]; + + const policy = {} as unknown as Policy; + + const result = getSecondaryReportActions({ + currentUserEmail: EMPLOYEE_EMAIL, + currentUserAccountID: EMPLOYEE_ACCOUNT_ID, + report, + chatReport, + reportTransactions: [transaction1], + originalTransaction: {} as Transaction, + violations: {}, + policy, + reportActions, + }); + expect(result.includes(CONST.REPORT.SECONDARY_ACTIONS.DUPLICATE)).toBe(true); + }); it('does not include DUPLICATE option if there are no transactions', async () => { const report = {