Skip to content

Investigate workflow job failing on main: test / test (job 7) #85235

Closed

Description

@github-actions

🚨 Failure Summary 🚨:

⚠️ Action Required ⚠️:

🛠️ A recent merge appears to have caused a failure in the job named test / test (job 7).
🔍 This issue has been automatically created and labeled with Workflow Failure for investigation.

👀 Please look into the following:

  1. Why the PR caused the job to fail?
  2. Address any underlying issues.

🐛 We appreciate your help in squashing this bug!

Activity

  1. inimaga commented on Mar 13, 2026

    @inimaga
    Contributor

    @MelvinBot Could you investigate the issue and propose a fix

  2. MelvinBot commented on Mar 13, 2026

    @MelvinBot
    Contributor

    Proposal

    Please re-state the problem that we are trying to solve in this issue.

    The test IOURequestStepConfirmationPageTest › Unreported transaction tests › should route unreported distance expense to requestMoney and skip createDistanceRequest fails with TypeError: Cannot read properties of undefined (reading 'status') at src/libs/getCurrentPosition/index.ts:10, causing CI job 7 to fail on main.

    What is the root cause of that problem?

    The test file tests/ui/components/IOURequestStepConfirmationPageTest.tsx is missing a mock for @libs/getCurrentPosition.

    PR #85147 ("[No QA] Fix jest tests - job7 and job8") was merged just before the triggering PR and added await waitForBatchedUpdatesWithAct() after the button press. This correctly allowed the async createTransaction flow to complete — but it also means the code now reaches getCurrentPosition() in the distance expense path (src/pages/iou/request/step/IOURequestStepConfirmation.tsx).

    When getCurrentPosition runs, it calls requestForegroundPermissionsAsync() from expo-location. In the test environment, jest-expo mocks this as a plain jest.fn() (returns undefined) rather than a promise-returning function. So foregroundPermissionResponse.status throws TypeError: Cannot read properties of undefined.

    The data flow is:

    1. Test presses "Create expense" for a distance expense
    2. createTransaction callback runs in IOURequestStepConfirmation.tsx
    3. getCurrentPosition() is called at line ~1299
    4. requestForegroundPermissionsAsync() resolves to undefined (bad jest-expo mock)
    5. Accessing .status on undefined throws TypeError
    6. IOU.requestMoney is never called, so the assertion at line 1271 fails

    Other tests that deal with distance expenses (e.g., tests/actions/IOU/MoneyRequestTest.ts:48) avoid this by including jest.mock('@libs/getCurrentPosition').

    What changes do you think we should make in order to solve the problem?

    Add the missing mock to the test file tests/ui/components/IOURequestStepConfirmationPageTest.tsx:

    jest.mock('@libs/getCurrentPosition');

    This follows the established pattern from tests/actions/IOU/MoneyRequestTest.ts and prevents the unmocked expo-location code path from being reached during the test.

    Note: The triggering PR (#85028, which changed src/pages/ReportChangeWorkspacePage.tsx) is unrelated to this failure. The root cause was introduced by PR #85147 which fixed test timing but didn't add the necessary getCurrentPosition mock.


    Next Steps for Contributor+ team: Reply with @MelvinBot implement this to create a draft PR, @MelvinBot <your feedback> to refine this analysis, or explain why you are rejecting Melvin's proposal.

  3. inimaga commented on Mar 13, 2026

    @inimaga
    Contributor

    @MelvinBot implement this

  4. MelvinBot commented on Mar 13, 2026

    @MelvinBot
    Contributor

    I ran out of time before I could finish helping you. This usually means the task was too complex or I got stuck exploring. Please try again with a more specific request or post in the #melvinbot-ai.

    Run details: https://github.com/Expensify/Expensify/actions/runs/23056497163

  5. MelvinBot commented on Mar 13, 2026

    @MelvinBot
    Contributor

    MelvinBot Run Analysis — Cancelled (30-minute timeout)

    Run: https://github.com/Expensify/Expensify/actions/runs/23056497163

    What happened

    MelvinBot was asked to implement the fix proposed in its earlier analysis. The run hit the 30-minute workflow timeout-minutes limit and was cancelled.

    Timeline

    1. 14:53 UTC — Run started (resuming session 44aad2d3)
    2. 14:55 UTC — MelvinBot added jest.mock('@libs/getCurrentPosition') to the test file, which fixed the original TypeError: Cannot read properties of undefined (reading 'status')
    3. 14:55–14:56 UTC — MelvinBot attempted to run the test 5 times but was blocked by Bash permission errors (This command requires approval), burning cycles on retries
    4. 14:56 UTC — Test eventually ran but still failed — different error. The mock fixed the TypeError, but IOU.requestMoney received 0 calls instead of the expected ≥1 call. This is a deeper issue in the unreported distance expense flow in IOURequestStepConfirmation.tsx
    5. 14:57–15:24 UTC — MelvinBot spawned a researcher subagent to investigate the createTransaction code path for unreported distance expenses, trying to understand why requestMoney is never called even after the mock fix. It ran out of time during this investigation.

    Root Cause of Timeout

    The task was more complex than expected. Adding the getCurrentPosition mock was only half the fix. The test "should route unreported distance expense to requestMoney and skip createDistanceRequest" has a deeper issue: the createTransaction callback in IOURequestStepConfirmation.tsx takes a different code path for distance requests that doesn't reach requestMoney as the test expects. This could be:

    Relationship to #85142

    Issue #85142 tracked the same underlying test failure. PR #85147 (merged 13:46 UTC) fixed the RESULTS import in __mocks__/react-native-permissions.ts but did not address the getCurrentPosition mock or the deeper requestMoney assertion issue. The triggering PR #85028 (merged 14:06 UTC) ran against a commit that included the #85147 fix but still failed because the getCurrentPosition issue and the requestMoney code path issue persisted.

    Recommendation

    The fix requires both:

    1. Adding jest.mock('@libs/getCurrentPosition') to the test file
    2. Investigating why the createTransaction flow for unreported distance expenses doesn't call requestMoney — either fix the component code or correct the test expectation

    A more targeted @MelvinBot request focusing specifically on tracing the createTransaction → requestMoney code path for unreported distance expenses would be more likely to succeed within the 30-minute window.

  6. inimaga commented on Mar 16, 2026

    @inimaga
    Contributor

    Fixed by here. Thanks Robert!

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

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions