Skip to content

Commit c9bdbb1

Browse files
authored
Merge pull request #61761 from thelullabyy/fix/61448-app-crash-on-hold-option
2 parents 2b7a4a0 + f441fd0 commit c9bdbb1

File tree

1 file changed

+9
-7
lines changed

1 file changed

+9
-7
lines changed

src/libs/ReportSecondaryActionUtils.ts

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import {
1414
hasIntegrationAutoSync,
1515
isPrefferedExporter,
1616
} from './PolicyUtils';
17-
import {getIOUActionForReportID, isPayAction} from './ReportActionsUtils';
17+
import {getIOUActionForReportID, getOneTransactionThreadReportID, isPayAction} from './ReportActionsUtils';
1818
import {
1919
canAddTransaction,
2020
isArchivedReport,
@@ -274,11 +274,12 @@ function isMarkAsExportedAction(report: Report, policy?: Policy): boolean {
274274
return (isAdmin && syncEnabled) || (isExporter && !syncEnabled);
275275
}
276276

277-
function isHoldAction(report: Report, reportTransactions: Transaction[]): boolean {
277+
function isHoldAction(report: Report, reportTransactions: Transaction[], reportActions?: ReportAction[]): boolean {
278+
const transactionThreadReportID = getOneTransactionThreadReportID(report.reportID, reportActions);
278279
const isOneExpenseReport = reportTransactions.length === 1;
279280
const transaction = reportTransactions.at(0);
280281

281-
if (!isOneExpenseReport || !transaction) {
282+
if ((!!reportActions && !transactionThreadReportID) || !isOneExpenseReport || !transaction) {
282283
return false;
283284
}
284285

@@ -319,14 +320,15 @@ function isChangeWorkspaceAction(report: Report, policy?: Policy): boolean {
319320
return policies.filter((newPolicy) => isWorkspaceEligibleForReportChange(newPolicy, report, session, policy)).length > 0;
320321
}
321322

322-
function isDeleteAction(report: Report, reportTransactions: Transaction[]): boolean {
323+
function isDeleteAction(report: Report, reportTransactions: Transaction[], reportActions?: ReportAction[]): boolean {
324+
const transactionThreadReportID = getOneTransactionThreadReportID(report.reportID, reportActions ?? []);
323325
const isExpenseReport = isExpenseReportUtils(report);
324326
const isIOUReport = isIOUReportUtils(report);
325327

326328
// This should be removed when is merged https://github.com/Expensify/App/pull/58020
327329
const isSingleTransaction = reportTransactions.length === 1;
328330

329-
if ((!isExpenseReport && !isIOUReport) || !isSingleTransaction) {
331+
if ((!isExpenseReport && !isIOUReport) || !isSingleTransaction || (!!reportActions && !transactionThreadReportID)) {
330332
return false;
331333
}
332334

@@ -410,7 +412,7 @@ function getSecondaryReportActions(
410412
options.push(CONST.REPORT.SECONDARY_ACTIONS.REOPEN);
411413
}
412414

413-
if (isHoldAction(report, reportTransactions)) {
415+
if (isHoldAction(report, reportTransactions, reportActions)) {
414416
options.push(CONST.REPORT.SECONDARY_ACTIONS.HOLD);
415417
}
416418

@@ -422,7 +424,7 @@ function getSecondaryReportActions(
422424

423425
options.push(CONST.REPORT.SECONDARY_ACTIONS.VIEW_DETAILS);
424426

425-
if (isDeleteAction(report, reportTransactions)) {
427+
if (isDeleteAction(report, reportTransactions, reportActions)) {
426428
options.push(CONST.REPORT.SECONDARY_ACTIONS.DELETE);
427429
}
428430

0 commit comments

Comments
 (0)