Skip to content

Fix import/no-cycle - part 15 - #101721

Merged
roryabraham merged 25 commits into
Expensify:mainfrom
callstack-internal:fix/no-cycle-part15-reportutils-workflow-reads-v1
Oct 8, 2026
Merged

roryabraham merged 25 commits into
Expensify:mainfrom
callstack-internal:fix/no-cycle-part15-reportutils-workflow-reads-v1

Conversation

@LukasMod

@LukasMod LukasMod commented Sep 21, 2026 •

Copy link
Copy Markdown
Contributor

Explanation of Change

  • The read-only IOU workflow checks (canApproveIOU, canIOUBePaid, canSubmitReport, getBadgeFromIOUReport, getIOUReportActionWithBadge) moved from actions/IOU/ReportWorkflow.ts into ReportUtils.ts. ReportUtils no longer imports ReportWorkflow, which clears the import loop. ReportWorkflow keeps only the write actions (submit, approve, pay, reopen, retract).
  • changeMoneyRequestHoldStatus moved from ReportUtils into actions/IOU/Hold.ts, so ReportUtils no longer imports unholdRequest. It now takes policy from the caller instead of looking it up in a global cache.
  • The badge checks no longer read the deprecated global violations cache. Callers pass violations in, down through the LHN derived value, the option list, the debug page and useOptimisticNextStep. The "every expense auto-rejected" rule that hides the Submit badge depends on this.
  • canIOUBePaid now reads the chat's archived flag from ReportUtils' own copy of the report name-value pairs. It is the same Onyx collection, read through a different module.
  • The unread indicator reuses the pre-computed requiresAttention from the report attributes instead of recomputing it.
  • Cleanup: isPayAtEndExpenseReport and isReportExcludedForHeldExpenses are no longer exported, and isPaidGroupPolicy(policy) became isPaidGroupPolicyByType(policy.type), which has the same body.
  • The module caches are the blocker for moving this into totally new module, all other options recreate no-cycle issue

Covered by automated tests

  • Auto-rejected expenses hide the Submit badge, the attention dot and the option-list GBR: tests/actions/IOUTest/ReportWorkflowTest.ts:5100.
  • The debug page shows no GBR for auto-rejected reports: tests/unit/DebugUtilsTest.ts:1154 and :1385.
  • changeMoneyRequestHoldStatus navigates to the hold reason or unholds: tests/actions/IOUTest/HoldTest.ts:513 and :526.
  • The context menu passes the expense report's policy when unholding: tests/ui/components/BaseReportActionContextMenuTest.tsx:408.
  • The moved Approve, Pay and Submit logic: the existing ReportWorkflowTest cases, now importing from ReportUtils.

import/no-cycle cleared (whole repo, 120 → 99)

Fixed Issues

$ #99650
PROPOSAL:

Tests

  • Verify that no errors appear in the JS console

Prerequisites: a team workspace with approvals on; account A approves and pays, account S submits.

Test 1: Smoke test for workflow buttons, badges and hold

  1. As A, open a report awaiting approval, tap Approve, and confirm it moves to Approved.
  2. As A, open a report where A is the payer and confirm Pay opens the pay flow.
  3. As S, open an open report and confirm Submit submits it.
  4. Confirm each LHN row shows the matching Pay, Approve or Submit badge.
  5. On an expense, choose Hold from the header, then Unhold , confirm both work

Test 2: Auto-rejected expenses hide the Submit badge in the LHN

Prerequisite: a report where every one of S's expenses was auto-rejected and A is the report manager.

  1. As A, find that workspace chat in the LHN.
  2. Confirm the row shows no Submit badge and no green dot.
  3. Open the chat and confirm the report preview offers no Submit action.

Test 3: No Pay option in an archived chat

Archiving is automatic, there is no manual "Archive" button. A chat is archived
when its workspace/account relationship ends (member removed, workspace deleted,
account closed/merged). Archived chats appear under the "Archived" header in the LHN.

Prerequisite: you are the invoice receiver/payer of an unpaid invoice; the invoice chat then gets
archived (e.g. the sending workspace is deleted).

  1. As the payer, expand the "Archived" section and open that invoice chat.
  2. Confirm the LHN row shows no Pay badge.
  3. Confirm the report preview shows no Pay button.

Test 4: Unread count still includes reports that need attention

Prerequisite: account A has an unread chat whose report is waiting on A to Approve or Pay.

  1. As A, stay on a different chat.
  2. Confirm the unread count (browser tab title or app icon badge) includes that chat.
  3. Open the chat and mark it read.
  4. Confirm the unread count drops by one.

Offline tests

QA Steps

  • Verify that no errors appear in the JS console

PR Author Checklist

  • I linked the correct issue in the ### Fixed Issues section above
  • I wrote clear testing steps that cover the changes made in this PR
    • I added steps for local testing in the Tests section
    • I added steps for the expected offline behavior in the Offline steps section
    • I added steps for Staging and/or Production testing in the QA steps section
    • I added steps to cover failure scenarios (i.e. verify an input displays the correct error message if the entered data is not correct)
    • I turned off my network connection and tested it while offline to ensure it matches the expected behavior (i.e. verify the default avatar icon is displayed if app is offline)
    • I tested this PR with a High Traffic account against the staging or production API to ensure there are no regressions (e.g. long loading states that impact usability).
  • I included screenshots or videos for tests on all platforms
  • I ran the tests on all platforms & verified they passed on:
    • Android: Native
    • Android: mWeb Chrome
    • iOS: Native
    • iOS: mWeb Safari
    • MacOS: Chrome / Safari
  • I verified there are no console errors (if there's a console error not related to the PR, report it or open an issue for it to be fixed)
  • I verified there are no new alerts related to the canBeMissing param for useOnyx
  • I followed proper code patterns (see Reviewing the code)
    • I verified that any callback methods that were added or modified are named for what the method does and never what callback they handle (i.e. toggleReport and not onIconClick)
    • I verified that comments were added to code that is not self explanatory
    • I verified that any new or modified comments were clear, correct English, and explained "why" the code was doing something instead of only explaining "what" the code was doing.
    • I verified any copy / text shown in the product is localized by adding it to src/languages/* files and using the translation method
      • If any non-english text was added/modified, I used JaimeGPT to get English > Spanish translation. I then posted it in #expensify-open-source and it was approved by an internal Expensify engineer. Link to Slack message:
    • I verified all numbers, amounts, dates and phone numbers shown in the product are using the localization methods
    • I verified any copy / text that was added to the app is grammatically correct in English. It adheres to proper capitalization guidelines (note: only the first word of header/labels should be capitalized), and is either coming verbatim from figma or has been approved by marketing (in order to get marketing approval, ask the Bug Zero team member to add the Waiting for copy label to the issue)
    • I verified proper file naming conventions were followed for any new files or renamed files. All non-platform specific files are named after what they export and are not named "index.js". All platform-specific files are named for the platform the code supports as outlined in the README.
    • I verified the JSDocs style guidelines (in STYLE.md) were followed
  • If a new code pattern is added I verified it was agreed to be used by multiple Expensify engineers
  • I followed the guidelines as stated in the Review Guidelines
  • I tested other components that can be impacted by my changes (i.e. if the PR modifies a shared library or component like Avatar, I verified the components using Avatar are working as expected)
  • I verified all code is DRY (the PR doesn't include any logic written more than once, with the exception of tests)
  • I verified any variables that can be defined as constants (ie. in CONST.ts or at the top of the file that uses the constant) are defined as such
  • I verified that if a function's arguments changed that all usages have also been updated correctly
  • If any new file was added I verified that:
    • The file has a description of what it does and/or why is needed at the top of the file if the code is not self explanatory
  • If a new CSS style is added I verified that:
    • A similar style doesn't already exist
    • The style can't be created with an existing StyleUtils function (i.e. StyleUtils.getBackgroundAndBorderStyle(theme.componentBG))
  • If new assets were added or existing ones were modified, I verified that:
    • The assets are optimized and compressed (for SVG files, run npm run compress-svg)
    • The assets load correctly across all supported platforms.
  • If the PR modifies code that runs when editing or sending messages, I tested and verified there is no unexpected behavior for all supported markdown - URLs, single line code, code blocks, quotes, headings, bold, strikethrough, and italic.
  • If the PR modifies a generic component, I tested and verified that those changes do not break usages of that component in the rest of the App (i.e. if a shared library or component like Avatar is modified, I verified that Avatar is working as expected in all cases)
  • If the PR modifies a component related to any of the existing Storybook stories, I tested and verified all stories for that component are still working as expected.
  • If the PR modifies a component or page that can be accessed by a direct deeplink, I verified that the code functions as expected when the deeplink is used - from a logged in and logged out account.
  • If the PR modifies the UI (e.g. new buttons, new UI components, changing the padding/spacing/sizing, moving components, etc) or modifies the form input styles:
    • I verified that all the inputs inside a form are aligned with each other.
    • I added Design label and/or tagged @Expensify/design so the design team can review the changes.
  • If a new page is added, I verified it's using the ScrollView component to make it scrollable when more elements are added to the page.
  • I added unit tests for any new feature or bug fix in this PR to help automatically prevent regressions in this user flow.
  • If the main branch was merged into this PR after a review, I tested again and verified the outcome was still expected according to the Test steps.

Screenshots/Videos

Android: Native
android.native.mov
Android: mWeb Chrome
android.web.mov
iOS: Native
ios.native.1-2.mov
ios.native.3.mov.mov
ios.native.4.mov
iOS: mWeb Safari
ios.web.1-4.mov
MacOS: Chrome / Safari
web-1.mov
web-2.mov
Screenshot 2026-09-24 at 14 21 47
web.4.mov

canIOUBePaid, canApproveIOU, getBadgeFromIOUReport and getIOUReportActionWithBadge
are pure read-side predicates, but they lived in libs/actions/IOU/ReportWorkflow.
Every component that needed them had to import an actions module, which is the
edge keeping the ReportUtils <-> IOU actions cycle alive.

Move them into ReportUtils and update the import sites. ReportWorkflow keeps only
the write-side actions. ReportUtils gains a module-scoped TRANSACTION_VIOLATIONS
cache for the SUBMIT badge, which is computed inside the reportAttributes derived
value; the deprecated getAllTransactionViolations() getter in IOU/index.ts is not
importable from here without recreating the cycle.
Drop the new Onyx.connectWithoutView violations cache in ReportUtils and pass the collection from the reportAttributes derived value instead. Thread it through getReasonAndReportActionThatRequiresAttention into getIOUReportActionWithBadge/getBadgeFromIOUReport down to canSubmitAndIsAwaitingForCurrentUser. generateReportAttributes already had the collection in scope, so no new module-level Onyx state is needed.
@codecov

codecov Bot commented Sep 21, 2026 •

Copy link
Copy Markdown

Nothing outside ReportUtils imports it now that the workflow predicates live here.
@LukasMod
LukasMod force-pushed the fix/no-cycle-part15-reportutils-workflow-reads-v1 branch from e11875e to ec3474b Compare September 21, 2026 10:59
isPaidGroupPolicy and isPaidGroupPolicyByType are the identical TEAM/CORPORATE check, but only isPaidGroupPolicy is a restricted import name. ReportUtils already uses the type-based sibling isGroupPolicyByType(policy?.type), so switch canApproveIOU/canIOUBePaid to isPaidGroupPolicyByType(policy.type) and drop the no-restricted-imports disable. No behavior change.
ReportWorkflow keeps the deletion of the moved predicates, and upstream's getReimbursementChoice reads are ported into canIOUBePaid in ReportUtils. Dropped the now-unused getReimbursementChoice import in ReportWorkflow.
The only callers moved to ReportUtils with canIOUBePaid.
@MelvinBot

Copy link
Copy Markdown
Contributor

🤖 Code review — [No QA] Fix import/no-cycle - part 15

The refactor is sound: ReportUtils no longer imports anything from actions/IOU (verified — zero matches for from './actions/IOU), the moved bodies are byte-equivalent apart from alias renames, and isPaidGroupPolicy(policy) → isPaidGroupPolicyByType(policy.type) is a true no-op (PolicyUtils.ts:1450-1456). ESLint, typecheck, knip and all 8 Jest shards are green.

One real regression, and it's the one you flagged yourself. Dropping the deprecated global violations read from getBadgeFromIOUReport breaks the chain at requiresAttentionFromCurrentUser, which has no way to supply violations. Please fix before merge.

1. requiresAttentionFromCurrentUser loses the auto-rejected suppression 🔴

ReportUtils.ts:4966-4974 calls getReasonAndReportActionThatRequiresAttention without the new transactionViolations argument, so allViolations arrives as undefined at getBadgeFromIOUReport. Inside canSubmitAndIsAwaitingForCurrentUser the violation list then resolves to [], hasAutoRejectedTransactionsForManager becomes false, and the SUBMIT badge is returned where main suppressed it (ReportUtils.ts:3130-3141).

That makes reasonForReportToBeInOptionList return HAS_GBR for a report where every expense was auto-rejected and the current user is the manager.

The LHN is safe — generateReportAttributes threads violations and passes requiresAttention precomputed (ReportUtils.ts:13851). These two callers do not, so they hit the broken fallback:

Suggested fix: add an optional transactionViolations param to requiresAttentionFromCurrentUser and to ShouldReportBeInOptionListParams, then forward it from both call sites. Alternatively give ReportUtils its own module-level Onyx.connect on COLLECTION.TRANSACTION_VIOLATIONS and default allViolations ?? allTransactionViolations — that restores the old behavior exactly without reintroducing the cycle, at the cost of one more global cache.

Your two other named callers turn out to be harmless, so no action needed there:

Why useOptimisticNextStep and DebugUtils are fine
  • useOptimisticNextStep.ts:78 only reads gbrResult.reason === HAS_DEW_APPROVE_FAILED, and only on STATUS_NUM.SUBMITTED reports. The auto-rejected suppression only affects the SUBMIT badge, which requires an open report — unreachable here.
  • DebugUtils.ts:1601 is debug-only tooling.

2. The new test doesn't cover the regression

should not return SUBMIT actionBadge when every transaction of the report was auto-rejected (tests/actions/IOUTest/ReportWorkflowTest.ts:5167) passes allViolations explicitly, so it is green on both main and this branch. Add a case that calls requiresAttentionFromCurrentUser (or shouldReportBeInOptionList without requiresAttention) on that same fixture — that one fails today and would have caught this.

3. Archived-chat pay gate — verified equivalent

canIOUBePaid:3227 now reads allReportNameValuePair instead of getAllReportNameValuePairs(). Both subscribe to the same collection key with a plain Onyx.connect and no waitForCollectionCallback (which no longer exists in react-native-onyx@3.0.111), so both hold the full collection. The only difference is the if (!value) return; guard at ReportUtils.ts:1210-1219, which keeps the last non-empty snapshot where actions/IOU/index.ts:61-67 would clear it. That only diverges on a full Onyx.clear(), so I'd treat your Test 3 as nice-to-have rather than required.

4. changeMoneyRequestHoldStatus policy threading — verified correct

Hoisting the policy lookup out of Hold.ts:1061 into six callers is the riskiest mechanical change here, and all six resolve to the money-request report's policy, matching the old internal lookup:

Per-call-site check
Call site Policy source Matches old lookup
MoneyReportHeaderEducationalModals.tsx POLICY[moneyRequestReport.policyID] ✅
RemoveHoldPrimaryAction.tsx:34 POLICY[moneyRequestReport.policyID] ✅
useHoldRejectActions.ts POLICY[moneyRequestReport.policyID] ✅
BaseReportActionContextMenu.tsx:239 POLICY[REPORT[moneyRequestAction.reportID].policyID] ✅
MoneyRequestHeaderPrimaryAction.tsx:71 POLICY[transactionThread.policyID] ✅ — buildTransactionThread copies policyID from the money request report (ReportUtils.ts:9843)
MoneyRequestHeaderSecondaryActions.tsx:151 same as above ✅

The BaseReportActionContextMenuTest change is a good trade: it stops asserting unholdRequest args but now pins the new policy argument, and HoldTest's two new cases cover the hold/unhold branches directly. Net coverage is up.

5. Nits

  • Stale aliases. canIOUBePaid as canIOUBePaidAction and canIOUBePaidIOUActions (useReportPreviewActionDecision.ts:8, useLifecycleActions.tsx:13) now name a ReportUtils read helper "Action". Dropping the alias in this PR avoids another rename pass later.
  • Mixed module alias. This PR adds both @libs/actions/IOU/Hold and @userActions/IOU/Hold for the same module. Pick one.
  • Lost TODO. The // TODO: https://github.com/Expensify/App/issues/66512 that documented the deprecated global read is gone, but ReportUtils.ts:3371 still suppresses no-deprecated for getReportTransactions. Re-add the link so that call stays tracked.
  • Import member order. canIOUBePaid lands before canEditMultipleTransactions in useSearchBulkActions.ts and hasAnyTransactionWithoutRTERViolation after hasNoticeTypeViolation in ReportUtils.ts. ESLint doesn't enforce it, so cosmetic only.
  • Removing isPayAtEndExpenseReport from the export list is correct — the only three references are inside ReportUtils itself.

Reply with @MelvinBot <feedback> to refine this review.

ReportWorkflow keeps the deletion of the moved predicates. Upstream's held-expense exclusion and the report-actions parameter for getBadgeFromIOUReport land in the moved copies in ReportUtils, where the collection param is named allReportActionsParam to avoid shadowing the module-level cache.
Its only outside caller was the canIOUBePaid/getBadgeFromIOUReport pair that now lives here, so the export is dead. Knip flagged it as a new unused export on this branch.
@LukasMod

Copy link
Copy Markdown
Contributor Author

@MelvinBot review

@MelvinBot

Copy link
Copy Markdown
Contributor

🤖 Re-review — [No QA] Fix import/no-cycle - part 15 (head b0c7b2a)

Every finding from my last pass is fixed, and I found nothing new that blocks merge. All checks green except Check independent approval, which just needs a human reviewer.

Prior findings — all resolved ✅

1. requiresAttentionFromCurrentUser losing the auto-rejected suppression — fixed. requiresAttentionFromCurrentUser now takes transactionViolations and forwards it as the 10th positional arg, and ShouldReportBeInOptionListParams carries it through to the fallback (ReportUtils.ts:10624). Both broken callers are covered, by two different means:

I verified the positional-argument threading at all four call sites — the new param lands in the right slot every time.

2. Missing regression test — fixed, twice. ReportWorkflowTest.ts:5168 now asserts requiresAttentionFromCurrentUser returns false on the auto-rejected fixture, and DebugUtilsTest.ts:1302 covers the GBR-reason path. Both fail without the threading.

3–5. Nits — all addressed. The canIOUBePaidAction / canIOUBePaidIOUActions aliases are gone, every changeMoneyRequestHoldStatus import now uses @libs/actions/IOU/Hold (no more mixed @userActions spelling), the 66512 TODO link is back at ReportUtils.ts:3346, and the useSearchBulkActions import order is sorted.

What I re-checked on the delta

Verification details
  • Moved bodies survived both main merges. Diffed all six helpers against main at the current merge base (53f9fb1). Still equivalent modulo local-variable renames that avoid shadowing the now-local function names (isOpenExpenseReport → isReportOpen, isClosedReport → isReportClosed, isPayAtEndExpenseReport → isReportPayAtEnd).
  • isPaidGroupPolicyByType(policy?.type) ≡ isPaidGroupPolicy(policy) still holds at PolicyUtils.ts:1457-1463, including the policy === undefined case in canIOUBePaid.
  • getIOUReportActionWithBadge param rename is required, not cosmetic. ReportUtils has a module-level allReportActions; renaming the param to allReportActionsParam keeps the no-fallback lookup the function always had.
  • Unexporting isReportExcludedForHeldExpenses is safe — only three references remain, all inside ReportUtils.
  • changeMoneyRequestHoldStatus move to Hold.ts:1061. moneyRequestPolicy in BaseReportActionContextMenu already existed for shouldShow; it resolves to POLICY[REPORT[(moneyRequestAction ?? reportAction).reportID].policyID], matching the old internal lookup. That component is the only builder of the onPress payload, so the optional param is always supplied.
  • Tests relocated, not dropped. The two changeMoneyRequestHoldStatus cases deleted from ReportUtilsTest land in HoldTest, and the unhold case now asserts on the resulting Onyx report action instead of a spy — a stronger assertion than before.

One note, not a blocker

UnreadIndicatorUpdater now sources requiresAttention from the reportAttributes derived value. triggerUnreadUpdate only fires on COLLECTION.REPORT changes, and memoizedGetUnreadReportsForUnreadIndicator keys on allReports, so if the derived value ever lags a report write by more than the 300 ms debounce, the unread count and tab title hold the stale value until the next report change. This is the same dependency derivedIsEmptyReport already has in that file, and reading the derived value actually makes the count more consistent with the LHN (it is computed with the real parentReportAction, which the fallback passes as undefined). I'd merge as-is.

Also cosmetic: hasAnyTransactionWithoutRTERViolation sits after hasMissingSmartscanFieldsForRBR at ReportUtils.ts:276 rather than alphabetically before it. ESLint doesn't enforce it.


This review is static analysis only — the browser environment was unavailable for this run, so I could not exercise Tests 1–4 in NewDot. Your Test 2 (auto-rejected suppression) is now covered by unit tests; Tests 1, 3, and 4 still want a manual pass.

Reply with @MelvinBot <feedback> to refine this review.

@LukasMod LukasMod changed the title [No QA] Fix import/no-cycle - part 15 Fix import/no-cycle - part 15 Sep 24, 2026
@LukasMod
LukasMod marked this pull request as ready for review September 24, 2026 13:51
@LukasMod
LukasMod requested review from a team as code owners September 24, 2026 13:51
@melvin-bot
melvin-bot Bot requested review from JmillsExpensify and thelullabyy and removed request for a team September 24, 2026 13:51
@melvin-bot

melvin-bot Bot commented Sep 24, 2026

Copy link
Copy Markdown

@thelullabyy Please copy/paste the Reviewer Checklist from here into a new comment on this PR and complete it. If you have the K2 extension, you can simply click: [this button]

@melvin-bot
melvin-bot Bot removed the request for review from a team September 24, 2026 13:51

@thelullabyy thelullabyy left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[lullabyy agent] Reviewed the move of the read-only workflow checks into ReportUtils and of changeMoneyRequestHoldStatus into Hold.ts. The moved logic matches the original, and every hold caller passes the expense report's policy, the same one the old global lookup returned. I left a few inline comments: one about the API, one about lost test coverage, and one about test docs.

Comment thread src/libs/ReportUtils.ts Outdated
currentUserLogin: string,
currentUserAccountID: number,
iouReportActions: OnyxEntry<ReportActions>,
allViolations?: OnyxCollection<TransactionViolations>,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[lullabyy agent] allViolations is optional here and in getIOUReportActionWithBadge (line 3443). The old code always read the global violations cache. If a caller leaves this argument out, canSubmitAndIsAwaitingForCurrentUser gets undefined, the "every expense auto-rejected" check silently stops working, and the SUBMIT badge comes back with no type error. This PR is meant to fix exactly that case, so could we make the parameter required (allViolations: OnyxCollection<TransactionViolations> | undefined)? Then every current and future caller has to choose what to pass. The same applies to the new transactionViolations? parameter on getReasonAndReportActionThatRequiresAttention and requiresAttentionFromCurrentUser.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

applied

mockedCanSubmitReport.mockReturnValue(true);
const result = canSubmitAndIsAwaitingForCurrentUser(iouReport, chatReport, basePolicy, transactions, {}, 'user@test.com', CURRENT_USER_ACCOUNT_ID, undefined);
expect(result).toBe(true);
});

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[lullabyy agent] This PR removes the forwards the passed iouReportOwnerLogin instead of looking it up in the personal details list test because canSubmitReport now lives in the same module and can't be mocked. That leaves the iouReportOwnerLogin ?? getLoginByAccountID(...) branch in canSubmitAndIsAwaitingForCurrentUser with no tests. Could we add a behavior-based test instead? For example, seed no personal details, add a transaction with a pending RTER violation that belongs to 'threaded.owner@test.com', and assert that the result changes depending on whether the owner login is passed.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

canSubmitAndIsAwaitingForCurrentUser passes undefined violations to canSubmitReport, and main does the same. The owner login only matters when a dismissed violation gets checked, so on this path the result is the same with or without the fallback, and a behavior test can’t see it. I added a test on canSubmitReport instead, since that’s where the login decides whether a dismissal counts. Passing the violations through would change the SUBMIT badge, so I don't want to touch it in this PR

expect(result.actionBadge).toBe(CONST.REPORT.ACTION_BADGE.SUBMIT);
});

it('should not return SUBMIT actionBadge when every transaction of the report was auto-rejected', async () => {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[lullabyy agent] This new test has // Then comments but no // Given or // When comments. Per tests/README.md#documenting-tests, every test case should explain why it does what it does. Please add a // Given comment above the setup (an open report whose only expense is auto-rejected, with the current user as owner and manager) and a // When comment above the getIOUReportActionWithBadge call. The first two expects also need a // Then comment.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

applied

});

it('calls unholdRequest when pressing the unhold action', async () => {
it('calls changeMoneyRequestHoldStatus with the money request policy when pressing the unhold action', async () => {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[lullabyy agent] This test was renamed and rewritten to check the new changeMoneyRequestHoldStatus contract, so it would be a good time to add the required // Given / // When / // Then comments. For example: Given an on-hold expense whose report belongs to policyID; When the Unhold menu item is pressed; Then the hold action gets the money request report's policy rather than the chat's.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

applied

@thelullabyy

Copy link
Copy Markdown
Contributor

@LukasMod Overall PR LGTM, I left some comments from my agent. Please check and resolve conflicts as well so that I can approve the PR

…eportutils-workflow-reads-v1

Keep the workflow predicates (canApproveIOU, canIOUBePaid, canSubmitReport,
getBadgeFromIOUReport) in ReportUtils, where this branch moved them, and port
upstream's canAdminPayReport() helper into canIOUBePaid.
Optional violations parameters let a caller silently drop the
auto-rejected-expense check and resurrect the SUBMIT badge with no type
error. Make allViolations/transactionViolations required
(OnyxCollection | undefined) on getBadgeFromIOUReport,
getIOUReportActionWithBadge, getReasonAndReportActionThatRequiresAttention
and requiresAttentionFromCurrentUser, hoisting each to the last required
position since TS forbids a required parameter after an optional one.
@LukasMod

LukasMod commented Oct 5, 2026

Copy link
Copy Markdown
Contributor Author

@thelullabyy thanks for review, I applied feedback and answered 👍 conflicts resolved

@LukasMod
LukasMod requested a review from thelullabyy October 5, 2026 13:35
@thelullabyy

Copy link
Copy Markdown
Contributor

@LukasMod Thank you for the update. Changes look good, however, it got conflicts again :((

…eportutils-workflow-reads-v1

# Conflicts:
#	src/libs/ReportUtils.ts
#	src/libs/actions/IOU/ReportWorkflow.ts
@LukasMod

LukasMod commented Oct 5, 2026

Copy link
Copy Markdown
Contributor Author

@thelullabyy resolved! :)

@LukasMod

LukasMod commented Oct 7, 2026

Copy link
Copy Markdown
Contributor Author

I updated getReasonAndReportActionThatRequiresAttention to pass eslint max params issue after last merge

…eportutils-workflow-reads-v1

# Conflicts:
#	src/libs/ReportUtils.ts
#	tests/ui/components/BaseReportActionContextMenuTest.tsx
#	tests/unit/ReportUtilsTest.ts
@melvin-bot
melvin-bot Bot requested a review from roryabraham October 7, 2026 17:54
…eportutils-workflow-reads-v1

# Conflicts:
#	src/libs/actions/IOU/ReportWorkflow.ts
@LukasMod

LukasMod commented Oct 8, 2026

Copy link
Copy Markdown
Contributor Author

Conflicts each 2 hours 😭

@roryabraham
roryabraham merged commit abd8011 into Expensify:main Oct 8, 2026
34 of 35 checks passed
@OSBotify

OSBotify commented Oct 8, 2026

Copy link
Copy Markdown
Contributor

✋ This PR was not deployed to staging yet because QA is ongoing. It will be automatically deployed to staging after the next production release.

@github-actions

github-actions Bot commented Oct 8, 2026

Copy link
Copy Markdown
Contributor

🚧 roryabraham has triggered a test Expensify/App build. You can view the workflow run here.

@OSBotify OSBotify mentioned this pull request Oct 8, 2026
90 tasks done
@OSBotify

OSBotify commented Oct 8, 2026

Copy link
Copy Markdown
Contributor

🚀 Deployed to staging by https://github.com/roryabraham in version: 9.5.6-0 🚀

platform result
🕸 web 🕸 success ✅
🤖 android 🤖 success ✅
🍎 iOS 🍎 success ✅

@MelvinBot

Copy link
Copy Markdown
Contributor

No help site update needed. This PR moves IOU workflow and hold logic between modules to clear import cycles, so no existing article sentence becomes incorrect.


view run

@OSBotify

OSBotify commented Oct 9, 2026

Copy link
Copy Markdown
Contributor

🚀 Deployed to production by https://github.com/puneetlath in version: 9.5.6-6 🚀

platform result
🕸 web 🕸 success ✅
🤖 android 🤖 success ✅
🍎 iOS 🍎 success ✅

Bundle Size Analysis (Sentry):

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants