Skip to content

[$250] Odometer - Not here page opens after uploading odometer photo/opening uploaded photo #82661

Closed

Description

@jponikarchuk

If you haven’t already, check out our contributing guidelines for onboarding and email contributors@expensify.com to request to join our Slack channel!


Version Number: 9.3.20-4
Reproducible in staging?: Yes
Reproducible in production?: Yes
If this was caught during regression testing, add the test name, ID and link from BrowserStack: #80532
Email or phone of affected tester (no customers): applausetester+ihbuiivyw@applause.expensifail.com
Issue reported by: Applause Internal Team
Bug source: Exploratory - Significant User Experience Deterioration
Device used: Mac 26.2 / Chrome
App Component: Money Requests

Action Performed:

Precondition:

  • Log in with Expensifail account.
  1. Go to staging.new.expensify.com
  2. Go to workspace chat.
  3. Create an odometer expense.
  4. Open the expense.
  5. Click Distance.
  6. Click image thumbnail next to Start reading.
  7. Upload a photo.
  8. Click RHP back button.
  9. Click image thumbnail next to Start reading.

Expected Result:

In Step 7, after uploading photo, RHP will return to Distance page.
In Step 9, receipt will open in full screen.

Actual Result:

In Step 7, after uploading photo, RHP opens not here page.
In Step 9, not here page opens in full screen.

Workaround:

Unknown

Platforms:

  • Android: App
  • Android: mWeb Chrome
  • iOS: App
  • iOS: mWeb Safari
  • iOS: mWeb Chrome
  • Windows: Chrome
  • MacOS: Chrome / Safari

Screenshots/Videos

1.mp4

View all open jobs on GitHub

Issue OwnerCurrent Issue Owner: @brianlee-expensify
Upwork Automation - Do Not Edit
  • Upwork Job URL: https://www.upwork.com/jobs/~022028954847238304361
  • Upwork Job ID: 2028954847238304361
  • Last Price Increase: 2026-03-03

Activity

  1. added
    BugSomething is broken. Auto assigns a BugZero manager.
    on Mar 3, 2026
  2. melvin-bot commented on Mar 3, 2026

    @melvin-bot

    Triggered auto assignment to @brianlee-expensify (Bug), see https://stackoverflow.com/c/expensify/questions/14418 for more details. Please add this bug to a GH project, as outlined in the SO.

  3. MelvinBot commented on Mar 3, 2026

    @MelvinBot
    Contributor

    🔍 Issue Analysis

    Summary: After uploading an odometer photo in the EDIT flow, the RHP shows a "not here" page instead of returning to the Distance page. Clicking the image thumbnail afterward also shows "not here" in full screen.

    Confidence: Medium — code evidence supports the hypothesis, but runtime confirmation would strengthen it.

    Proposal

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

    When editing an existing odometer expense (open expense → click Distance → click image thumbnail → upload photo), two things go wrong:

    1. After uploading the photo, the RHP shows a "not here" (not-found) page instead of returning to the Distance/Odometer page.
    2. Clicking the image thumbnail again opens the "not here" page in full screen instead of showing the uploaded receipt.

    What is the root cause of that problem?

    The root cause is in TransactionReceiptModalContent.tsx:217-218. The shouldShowNotFoundPage logic:

    const shouldShowNotFoundPage =
        isTrackExpenseReportValue || isDraftTransaction || ... ? !transaction : ...;
    

    When isDraftTransaction is true (which it is whenever action is provided — including the edit action at line 60: const isDraftTransaction = !!action), the page shows "not here" when !transaction is true — i.e., when the transaction draft doesn't exist.

    During the edit flow for an existing odometer expense, the TransactionReceiptModalContent reads the transaction from ONYXKEYS.COLLECTION.TRANSACTION_DRAFT (line 48), because isDraftTransaction = true. However, the edit flow for the distance/odometer step may not properly create a transaction draft for the given transactionID. Additionally, when setMoneyRequestOdometerImage is called during the upload (at IOU/index.ts:1769), it creates only a minimal draft containing just {comment: {odometerStartImage: ...}} via Onyx.merge — but this minimal draft may not satisfy all the conditions downstream.

    A contributing factor is the withWritableReportOrNotFound HOC wrapping IOURequestStepDistanceOdometer (IOURequestStepDistanceOdometer.tsx:666). This HOC calls canUserPerformWriteAction(report ?? {reportID: ''}, isReportArchived) at withWritableReportOrNotFound.tsx:95. If the report is momentarily unavailable in Onyx during navigation transitions, this returns false and renders <FullPageNotFoundView> — the "not here" page.

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

    Two fixes are needed:

    1. In TransactionReceiptModalContent.tsx — When isDraftTransaction is true and the transaction draft is not found, fall back to the main transaction (transactionMain) instead of immediately showing the not-found page. The shouldShowNotFoundPage logic should consider both the draft and the main transaction:

      • Check !transaction should become !transaction && !transactionMain (or similar), so that when viewing an odometer image during edit, the existing transaction can be used as a fallback.
    2. In IOURequestStepDistanceOdometer.tsx / the edit flow — Ensure the transaction draft is properly initialized when entering the distance/odometer edit step. When the user navigates to edit the distance of an existing expense, the full transaction data should be copied into TRANSACTION_DRAFT so that downstream components (receipt preview, odometer image) can find it.

    What alternative solutions did you explore? (Optional)

    • Adding a loading state guard in TransactionReceiptModalContent when isDraftTransaction is true but the draft hasn't loaded yet. However, this only addresses the race condition symptom, not the underlying missing draft issue.
    • Changing withWritableReportOrNotFound to be more lenient during the edit flow (e.g., skip the canUserPerformWriteAction check when action === 'edit'). This is too broad and could mask real access issues.
    Detailed Investigation

    Root Cause Analysis

    Component chain for IOURequestStepDistanceOdometer:
    withFullTransactionOrNotFound → withWritableReportOrNotFound → withCurrentUserPersonalDetails → IOURequestStepDistanceOdometer (lines 664-670)

    Component chain for IOURequestStepOdometerImage:
    withFullTransactionOrNotFound → IOURequestStepOdometerImage (line 518 of index.tsx)

    Key observations:

    1. withFullTransactionOrNotFound (withFullTransactionOrNotFound.tsx:85-90) only shows not-found when transactionID route param is falsy. It does NOT check if the transaction object itself exists in Onyx. So even if the draft is missing, this HOC passes through.

    2. withWritableReportOrNotFound (withWritableReportOrNotFound.tsx:95-97) shows not-found when canUserPerformWriteAction returns false. This calls canUserPerformWriteAction(report ?? {reportID: ''}, isReportArchived) (ReportUtils.ts:10086-10094). If report is null/undefined, the fallback {reportID: ''} makes canUserPerformWriteAction return false because the report && check at line 10094 fails.

    3. The receipt preview shouldShowNotFoundPage logic (TransactionReceiptModalContent.tsx:217-218) evaluates to !transaction when isDraftTransaction = true. The transaction comes from transactionDraft (line 64-66), which is fetched from ONYXKEYS.COLLECTION.TRANSACTION_DRAFT.

    4. setMoneyRequestOdometerImage (IOU/index.ts:1755-1774) stores the image via Onyx.merge into the draft. If the draft didn't exist before, this creates a minimal object with just the image data.

    5. The MONEY_REQUEST_RECEIPT_PREVIEW route type definition (Navigation/types.ts:2923-2929) does NOT include imageType in its params, while TRANSACTION_RECEIPT does (line 2921). The imageType is passed as a query parameter in the URL, which React Navigation parses into route params at runtime, so it works functionally but is a type inconsistency.

    Evidence Chain

    1. User opens existing odometer expense → clicks Distance → enters EDIT flow
    2. IOURequestStepDistanceOdometer loads with action = 'edit', isDraft = true
    3. withFullTransactionOrNotFound reads from TRANSACTION_DRAFT_{transactionID} → may be undefined if draft wasn't created
    4. User clicks image thumbnail → navigates to IOURequestStepOdometerImage
    5. User uploads photo → setMoneyRequestOdometerImage creates minimal draft via Onyx.merge
    6. navigateBack() returns to distance odometer page
    7. withWritableReportOrNotFound re-evaluates → if report is momentarily unavailable, shows "not here"
    8. If user clicks image thumbnail → navigates to MONEY_REQUEST_RECEIPT_PREVIEW → TransactionReceiptModalContent loads → isDraftTransaction = true → transaction = transactionDraft (minimal draft or undefined) → shouldShowNotFoundPage may be true

    Relevant Code

    • App/src/pages/media/AttachmentModalScreen/routes/TransactionReceiptModalContent.tsx:217-218 - shouldShowNotFoundPage logic
    • App/src/pages/iou/request/step/IOURequestStepDistanceOdometer.tsx:343-351 - handleViewOdometerImage navigation
    • App/src/pages/iou/request/step/IOURequestStepDistanceOdometer.tsx:664-670 - HOC wrapping chain
    • App/src/pages/iou/request/step/IOURequestStepOdometerImage/index.tsx:80-90 - Upload and navigateBack flow
    • App/src/pages/iou/request/step/withWritableReportOrNotFound.tsx:95-97 - Report writability check
    • App/src/pages/iou/request/step/withFullTransactionOrNotFound.tsx:85-90 - Transaction existence check
    • App/src/libs/actions/IOU/index.ts:1755-1774 - setMoneyRequestOdometerImage function
    • App/src/ROUTES.ts:1121-1131 - MONEY_REQUEST_RECEIPT_PREVIEW route definition

    Next Steps for Contributor+ team: Reply with @MelvinBot implement this to create a draft PR, or @MelvinBot <your feedback> to refine this analysis.

  4. added
    ExternalAdded to denote the issue can be worked on by a contributor
    on Mar 3, 2026
  5. added
    Help WantedApply this label when an issue is open to proposals by contributors
    on Mar 3, 2026
  6. melvin-bot commented on Mar 3, 2026

    @melvin-bot

    Triggered auto assignment to Contributor-plus team member for initial proposal review - @eVoloshchak (External)

  7. changed the title [-]Odometer - Not here page opens after uploading odometer photo/opening uploaded photo[/-] [+][$250] Odometer - Not here page opens after uploading odometer photo/opening uploaded photo[/+] on Mar 3, 2026
  8. melvin-bot commented on Mar 3, 2026

    @melvin-bot
  9. MelvinBot commented on Mar 3, 2026

    @MelvinBot
    Contributor

    Update — More Precise Root Cause Identified:

    After deeper investigation, the primary root cause is a race condition between Onyx.merge and useOnyx in the receipt preview flow:

    1. When the user uploads an odometer photo, setMoneyRequestOdometerImage (IOU/index.ts:1769) calls Onyx.merge to store the image in the transaction draft.
    2. Onyx.merge is asynchronous — it adds to the internal mergeQueue and starts an async get() from storage (Onyx.js:216-217). The merge stays pending until the storage read completes.
    3. When the user then clicks the image thumbnail (or when navigation returns), TransactionReceiptModalContent mounts and calls useOnyx for the transaction draft (TransactionReceiptModalContent.tsx:48).
    4. useOnyx detects the pending merge via hasPendingMergeForKey() and deliberately returns undefined to avoid stale data (useOnyx.js:204-206):
      if (isFirstConnectionRef.current && OnyxUtils.hasPendingMergeForKey(key) && !options?.allowStaleData) {
          newValueRef.current = undefined;
          newFetchStatus = 'loading';
      }
    5. With transaction = undefined, the shouldShowNotFoundPage logic (TransactionReceiptModalContent.tsx:217-218) evaluates to !undefined = true.
    6. The isLoading guard doesn't protect against this because it only checks reportMetadata?.isLoadingInitialReportActions (line 598), NOT the useOnyx loading status for the draft transaction.

    Recommended fix (refined):

    • Option A: Add allowStaleData: true to the useOnyx call for transactionDraft in TransactionReceiptModalContent — this prevents useOnyx from returning undefined when there's a pending merge.
    • Option B: Update the isLoading calculation to also check the useOnyx fetch status for the draft transaction, so it shows a loading spinner instead of "not here" while the merge is pending.
    • Option C: Also add imageType to the SCREENS.MONEY_REQUEST.RECEIPT_PREVIEW type definition in Navigation/types.ts:2923-2929 to fix the TypeScript gap (it's currently only in TRANSACTION_RECEIPT at line 2921).
  10. eVoloshchak commented on Mar 5, 2026

    @eVoloshchak
    Contributor

    @MelvinBot, implement this, let's go with option B

  11. MelvinBot commented on Mar 5, 2026

    @MelvinBot
    Contributor

    Draft PR created: #84291
    Please mark it as "Ready for review" when it is ready for review.

  12. removed
    Help WantedApply this label when an issue is open to proposals by contributors
    on Mar 5, 2026
  13. eVoloshchak commented on Mar 9, 2026

    @eVoloshchak
    Contributor

    This isn't reproducible after #82305 has been merged, now we just hide the ability to upload the image after odometer expense has been submitted. Melving does say that this is still reproducible (#84291 (comment)), but it isn't based on my testing.
    I think we might want to close this

    However, I did discover another bug while testing this:

    1. Click FAB -> Track distance -> Odometer
    2. Enter start and end readings, upload at least one image
    3. Click Next -> Select a workspace.
    4. Click on Distance menu item
    5. Upload another image (either replace the original one or add a second one)
    6. Notice that both images are reset to empty
    Screen.Recording.2026-03-09.at.18.01.01.mov

    cc: @brianlee-expensify

  14. brianlee-expensify commented on Mar 10, 2026

    @brianlee-expensify
    Contributor

    @jponikarchuk based on @eVoloshchak's comment above about a new bug with the steps to reproduce, can you create a new GH ticket accordingly?

    @mallenexpensify would love your thoughts on payment for this GH

  15. jponikarchuk commented on Mar 10, 2026

    @jponikarchuk
    Author
  16. mallenexpensify commented on Mar 10, 2026

    @mallenexpensify
    Contributor

    @eVoloshchak , can you report the bug in #expensify-open-source ? Post in the thread asking to be assigned and cc me plz.

    Unsure on payment... pre-Melvin we had

    50% to the contributor and C+ if they were 🎀👀🎀, hired, or assigned.

    I'm fine with that for now cuz @eVoloshchak invested time. My concern, going forward, is that we're setting precedence with Melv issues that, if they draft a PR paymente is due, even if the C+ only put in minimal time. Reckon we shoudl address that soon.

  17. eVoloshchak commented on Mar 11, 2026

    @eVoloshchak
    Contributor

    can you report the bug in #expensify-open-source ? Post in the thread asking to be assigned and cc me plz.

    This is being handled in #84772

  18. brianlee-expensify commented on Mar 11, 2026

    @brianlee-expensify
    Contributor

    Payment Summary

  19. trjExpensify commented on Mar 26, 2026

    @trjExpensify
    Contributor

    approved $125 for @eVoloshchak

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

Metadata

Metadata

Labels

BugSomething is broken. Auto assigns a BugZero manager.DailyKSv2ExternalAdded to denote the issue can be worked on by a contributor

Type

No type

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions