Skip to content

Commit cf2829b

Browse files
authored
Merge pull request Expensify#64992 from nkdengineer/fix/62266
fix: Submit option for a duplicate expenses
2 parents dae3486 + b0b49d2 commit cf2829b

1 file changed

Lines changed: 15 additions & 3 deletions

File tree

src/libs/ReportSecondaryActionUtils.ts

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ import {
1616
isPreferredExporter,
1717
} from './PolicyUtils';
1818
import {getIOUActionForReportID, getIOUActionForTransactionID, getOneTransactionThreadReportID, isPayAction} from './ReportActionsUtils';
19-
import {isPrimaryPayAction} from './ReportPrimaryActionUtils';
19+
import {getReportPrimaryAction, isPrimaryPayAction} from './ReportPrimaryActionUtils';
2020
import {
2121
canAddTransaction,
2222
canEditReportPolicy,
@@ -108,6 +108,7 @@ function isSubmitAction(
108108
reportNameValuePairs?: ReportNameValuePairs,
109109
reportActions?: ReportAction[],
110110
isChatReportArchived = false,
111+
primaryAction?: ValueOf<typeof CONST.REPORT.PRIMARY_ACTIONS> | '',
111112
): boolean {
112113
if (isArchivedReport(reportNameValuePairs) || isChatReportArchived) {
113114
return false;
@@ -160,7 +161,7 @@ function isSubmitAction(
160161

161162
const isScheduledSubmitEnabled = policy?.harvesting?.enabled && autoReportingFrequency !== CONST.POLICY.AUTO_REPORTING_FREQUENCIES.MANUAL;
162163

163-
return !!isScheduledSubmitEnabled;
164+
return !!isScheduledSubmitEnabled || primaryAction !== CONST.REPORT.SECONDARY_ACTIONS.SUBMIT;
164165
}
165166

166167
function isApproveAction(report: Report, reportTransactions: Transaction[], violations: OnyxCollection<TransactionViolation[]>, policy?: Policy): boolean {
@@ -520,7 +521,18 @@ function getSecondaryReportActions({
520521
options.push(CONST.REPORT.SECONDARY_ACTIONS.ADD_EXPENSE);
521522
}
522523

523-
if (isSubmitAction(report, reportTransactions, policy, reportNameValuePairs, reportActions, isChatReportArchived)) {
524+
const primaryAction = getReportPrimaryAction({
525+
report,
526+
chatReport,
527+
reportTransactions,
528+
violations,
529+
policy,
530+
reportNameValuePairs,
531+
reportActions,
532+
isChatReportArchived,
533+
});
534+
535+
if (isSubmitAction(report, reportTransactions, policy, reportNameValuePairs, reportActions, isChatReportArchived, primaryAction)) {
524536
options.push(CONST.REPORT.SECONDARY_ACTIONS.SUBMIT);
525537
}
526538

0 commit comments

Comments
 (0)