@@ -4656,18 +4656,11 @@ function getReasonAndReportActionThatRequiresAttention(
46564656 const hasOnlyPendingTransactions = transactions.length > 0 && transactions.every((t) => isPending(t));
46574657
46584658 const iouReport = reports ? reports[`${ONYXKEYS.COLLECTION.REPORT}${iouReportID}`] : getReportOrDraftReport(iouReportID);
4659- const hasAllExpensesHeld = hasOnlyHeldExpenses(transactions);
46604659 const iouReportActions = allReportActionsParam?.[`${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${iouReportID}`] ?? getAllReportActions(iouReportID);
4661- // An all-held report can't move to its next state, so it isn't a to-do. Keep it only for a report awaiting
4662- // approval or payment where the current user placed a hold, since they can remove it. An open report stays
4663- // excluded because only its owner can place a hold there, and that owner is the one who submits.
46644660 // This only has to run on the fallback path: when a candidate was found, getBadgeFromIOUReport has already applied
46654661 // the same exclusion while picking it, so the chat is known to have an actionable child even when a sibling of that
46664662 // child is fully held.
4667- const isFallbackReportExcludedForHeldExpenses =
4668- !iouReportActionToApproveOrPay &&
4669- hasAllExpensesHeld &&
4670- (isOpenExpenseReport(iouReport) || !didCurrentUserPlaceHoldOnReportExpense(iouReportActions, transactions, currentUserAccountID));
4663+ const isFallbackReportExcludedForHeldExpenses = !iouReportActionToApproveOrPay && isReportExcludedForHeldExpenses(iouReport, transactions, iouReportActions, currentUserAccountID);
46714664
46724665 // Has a child report that is awaiting action (e.g. approve, pay, add bank account) from current user.
46734666 // A report whose only expenses are pending Expensify Card transactions can't be actioned until they post, so it
@@ -4942,6 +4935,18 @@ function didCurrentUserPlaceHoldOnReportExpense(reportActions: OnyxEntry<ReportA
49424935 });
49434936}
49444937
4938+ /**
4939+ * An all-held report can't move to its next state, so it isn't a to-do and doesn't get an action badge. Keep it only
4940+ * for a report awaiting approval or payment where the current user placed a hold, since they can remove it. An open
4941+ * report stays excluded because only its owner can place a hold there, and that owner is the one who submits.
4942+ */
4943+ function isReportExcludedForHeldExpenses(iouReport: OnyxEntry<Report>, transactions: Transaction[], reportActions: OnyxEntry<ReportActions>, currentUserAccountID?: number): boolean {
4944+ if (!hasOnlyHeldExpenses(transactions)) {
4945+ return false;
4946+ }
4947+ return isOpenExpenseReport(iouReport) || !didCurrentUserPlaceHoldOnReportExpense(reportActions, transactions, currentUserAccountID);
4948+ }
4949+
49454950/**
49464951 * Given a report field, check if the field can be edited or not.
49474952 * For title fields, its considered disabled if `deletable` prop is `true` (https://github.com/Expensify/App/issues/35043#issuecomment-1911275433)
@@ -14739,6 +14744,7 @@ export {
1473914744 isAwaitingFirstLevelApproval,
1474014745 isPublicRoom,
1474114746 isReportApproved,
14747+ isReportExcludedForHeldExpenses,
1474214748 isReportManuallyReimbursed,
1474314749 isReportFieldDisabled,
1474414750 isReportFieldDisabledForUser,
0 commit comments