@@ -14,7 +14,7 @@ import {
14
14
hasIntegrationAutoSync ,
15
15
isPrefferedExporter ,
16
16
} from './PolicyUtils' ;
17
- import { getIOUActionForReportID , isPayAction } from './ReportActionsUtils' ;
17
+ import { getIOUActionForReportID , getOneTransactionThreadReportID , isPayAction } from './ReportActionsUtils' ;
18
18
import {
19
19
canAddTransaction ,
20
20
isArchivedReport ,
@@ -274,11 +274,12 @@ function isMarkAsExportedAction(report: Report, policy?: Policy): boolean {
274
274
return ( isAdmin && syncEnabled ) || ( isExporter && ! syncEnabled ) ;
275
275
}
276
276
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 ) ;
278
279
const isOneExpenseReport = reportTransactions . length === 1 ;
279
280
const transaction = reportTransactions . at ( 0 ) ;
280
281
281
- if ( ! isOneExpenseReport || ! transaction ) {
282
+ if ( ( ! ! reportActions && ! transactionThreadReportID ) || ! isOneExpenseReport || ! transaction ) {
282
283
return false ;
283
284
}
284
285
@@ -319,14 +320,15 @@ function isChangeWorkspaceAction(report: Report, policy?: Policy): boolean {
319
320
return policies . filter ( ( newPolicy ) => isWorkspaceEligibleForReportChange ( newPolicy , report , session , policy ) ) . length > 0 ;
320
321
}
321
322
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 ?? [ ] ) ;
323
325
const isExpenseReport = isExpenseReportUtils ( report ) ;
324
326
const isIOUReport = isIOUReportUtils ( report ) ;
325
327
326
328
// This should be removed when is merged https://github.com/Expensify/App/pull/58020
327
329
const isSingleTransaction = reportTransactions . length === 1 ;
328
330
329
- if ( ( ! isExpenseReport && ! isIOUReport ) || ! isSingleTransaction ) {
331
+ if ( ( ! isExpenseReport && ! isIOUReport ) || ! isSingleTransaction || ( ! ! reportActions && ! transactionThreadReportID ) ) {
330
332
return false ;
331
333
}
332
334
@@ -410,7 +412,7 @@ function getSecondaryReportActions(
410
412
options . push ( CONST . REPORT . SECONDARY_ACTIONS . REOPEN ) ;
411
413
}
412
414
413
- if ( isHoldAction ( report , reportTransactions ) ) {
415
+ if ( isHoldAction ( report , reportTransactions , reportActions ) ) {
414
416
options . push ( CONST . REPORT . SECONDARY_ACTIONS . HOLD ) ;
415
417
}
416
418
@@ -422,7 +424,7 @@ function getSecondaryReportActions(
422
424
423
425
options . push ( CONST . REPORT . SECONDARY_ACTIONS . VIEW_DETAILS ) ;
424
426
425
- if ( isDeleteAction ( report , reportTransactions ) ) {
427
+ if ( isDeleteAction ( report , reportTransactions , reportActions ) ) {
426
428
options . push ( CONST . REPORT . SECONDARY_ACTIONS . DELETE ) ;
427
429
}
428
430
0 commit comments