Skip to content

[Due for payment 2025-11-14] Investigate violations under a receipt on the one expense report view not showing sometimes #72444

Closed

Description

@mountiny

Shawn raised in this thread that on staging a receipt that shows some violations, it does not show the specific violations under the receipt. It is showing correctly when signed in again in incognito mode. Can you investigate, given the onyx state, why the violations are not showing and fix that to be always showing. https://expensify.slack.com/archives/C049HHMV9SM/p1760350193472079?thread_ts=1760340175.741989&cid=C049HHMV9SM

Note: the data is in internal thread so this is available only for internal developers/ c+ and experts

Issue OwnerCurrent Issue Owner: @greg-schroeder

Activity

  1. added
    External
    Daily
    Bug
    on Oct 13, 2025
  2. added
    Help Wanted
    on Oct 13, 2025
  3. melvin-bot commented on Oct 13, 2025

    @melvin-bot

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

  4. melvin-bot commented on Oct 13, 2025

    @melvin-bot

    Triggered auto assignment to @greg-schroeder (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.

  5. dukenv0307 commented on Oct 13, 2025

    @dukenv0307
    Contributor

    🚨 Edited by proposal-police: This proposal was edited at 2025-10-13 11:27:11 UTC.

    Proposal

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

    Investigate violations under a receipt on the one expense report view not showing sometimes

    What is the root cause of that problem?

    Sometimes the receipt isn't loaded, so the violation doesn't show here

    {!!shouldShowAuditMessage && hasReceipt && !isLoading && receiptAuditMessagesRow}

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

    We can remove isLoading condition here. Or we can set isLoading to false when the image fails to load

    {!!shouldShowAuditMessage && hasReceipt && !isLoading && receiptAuditMessagesRow}

    What specific scenarios should we cover in automated tests to prevent reintroducing this issue in the future?

    None

    What alternative solutions did you explore? (Optional)

    Only checking the isLoading state if we're in wide RHP view

    {!!shouldShowAuditMessage && hasReceipt && (!isLoading || !fillSpace) && receiptAuditMessagesRow}
    

    {!!shouldShowAuditMessage && hasReceipt && !isLoading && receiptAuditMessagesRow}

    Reminder: Please use plain English, be brief and avoid jargon. Feel free to use images, charts or pseudo-code if necessary. Do not post large multi-line diffs or write walls of text. Do not create PRs unless you have been hired for this job.

  6. RKCODE2015 commented on Oct 14, 2025

    @RKCODE2015

    Proposal

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

    When a user views an expense report, critical violation messages that should appear directly under a receipt are sometimes missing. This inconsistent behavior can confuse the user, as they might not be aware of important issues with their expense that require action. The issue appears to resolve itself upon a fresh session (like in Incognito mode), suggesting a problem related to the component's loading state rather than a lack of data.

    What is the root cause of that problem?

    The root cause is an incorrect dependency in the rendering logic within the MoneyRequestReceiptView.tsx component. The display of the violation messages is incorrectly coupled with the loading state of the receipt image.

    The current logic to render the violation messages is as follows:

    show_violations IF (there_are_violations_to_show) AND (a_receipt_exists) AND (the_image_has_finished_loading)

    The problematic condition is the final one: (the_image_has_finished_loading). This creates a race condition. If the violation data loads quickly but the receipt image loads slowly (or fails to load entirely), the critical violation messages will never be rendered because the component is still waiting for a non-critical image.

    This is a logical flaw, as the textual violation information is not dependent on the visual receipt image itself. They should render independently.

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

    The solution is to decouple the rendering of violation messages from the image's loading state. We should remove the !isLoading check from the conditional statement that controls the visibility of receiptAuditMessagesRow.

    This ensures that as soon as the violation data is available, it will be displayed to the user, regardless of how long the receipt image takes to load.

    App/src/components/ReportActionItem/MoneyRequestReceiptView.tsx

    Current Code:

    // Problem: The "!isLoading" condition blocks violation messages from rendering
    // until the image has completely loaded.
    {!!shouldShowAuditMessage && hasReceipt && !isLoading && receiptAuditMessagesRow}
    

    Proposed Change:

    // Fix: Remove the "!isLoading" dependency. Violation messages will now
    // render as soon as they are available.
    {!!shouldShowAuditMessage && hasReceipt && receiptAuditMessagesRow}
    

    This change is simple, direct, and addresses the root cause of the issue by correcting the component's rendering logic.

    What alternative solutions did you explore? (Optional)

    1. Setting isLoading to false on image load failure: One alternative is to add an onError handler to the image component to ensure isLoading is set to false if the image fails to load. While this would solve the problem for failed images, it would not fix the issue for images that are simply slow to load. The user would still have to wait for the image, which is not ideal.

    2. Making the check conditional on the view: Another idea was to only apply the !isLoading check in certain layouts (e.g., when the receipt is not filling the full space). This is a symptom-based fix, not a root cause fix. It would make the code more complex and would not solve the underlying logical flaw, which could reappear in other layouts or future refactors.

    Ultimately, both alternatives are partial or indirect fixes. The most robust solution is to remove the incorrect dependency entirely, as proposed above.

  7. abdulrahuman5196 commented on Oct 14, 2025

    @abdulrahuman5196
    Contributor

    @dukenv0307 , I tested by mocking the code and sending empty string as source for the image, and the image load failed and the violations where also not shown. So the RCA hypothesis is correct. And also tested with the isLoading state which is also working.

    could you kindly update your proposal with all the information discussed in the slack?

  8. abdulrahuman5196 commented on Oct 14, 2025

    @abdulrahuman5196
    Contributor

    @dukenv0307 's proposal here #72444 (comment) looks good and works well.

    🎀 👀 🎀
    C+ Reviewed

  9. 11 remaining items

  10. removed
    Reviewing
    on Nov 7, 2025
  11. melvin-bot commented on Nov 7, 2025

    @melvin-bot

    Reviewing label has been removed, please complete the "BugZero Checklist".

  12. melvin-bot commented on Nov 7, 2025

    @melvin-bot

    The solution for this issue has been 🚀 deployed to production 🚀 in version 9.2.46-3 and is now subject to a 7-day regression period 📆. Here is the list of pull requests that resolve this issue:

    If no regressions arise, payment will be issued on 2025-11-14. 🎊

    For reference, here are some details about the assignees on this issue:

  13. melvin-bot commented on Nov 7, 2025

    @melvin-bot

    @abdulrahuman5196 / @dukenv0307 @greg-schroeder The PR fixing this issue has been merged! The following checklist (instructions) will need to be completed before the issue can be closed. Please copy/paste the BugZero Checklist from here into a new comment on this GH and complete it. If you have the K2 extension, you can simply click: [this button]

  14. abdulrahuman5196 commented on Nov 11, 2025

    @abdulrahuman5196
    Contributor

    BugZero Checklist:

    • [Contributor] The offending PR has been commented on, pointing out the bug it caused and why, so the author and reviewers can learn from the mistake.

      Link to comment: Doesn't seem to be a regression. Implementation miss - https://github.com/Expensify/App/pull/69875/files#r2515180999

    • [Contributor] If the regression was CRITICAL (e.g. interrupts a core flow) A discussion in #expensify-open-source has been started about whether any other steps should be taken (e.g. updating the PR review checklist) in order to catch this type of bug sooner.

      Link to discussion: NA

    • [Contributor] If it was decided to create a regression test for the bug, please propose the regression test steps using the template below to ensure the same bug will not reach production again.

    I don't think we can create regression test for this issue, since it expects the image load to fail which rarely happens.

    Regression Test Proposal Template
    • [BugZero Assignee] Create a GH issue for creating/updating the regression test once above steps have been agreed upon.

      Link to issue:

    Regression Test Proposal

    Precondition:

    Test:

    Do we agree 👍 or 👎

  15. moved this from HIGH to AWAITING DEPLOYMENT in [#whatsnext] #qualityon Nov 11, 2025
  16. added
    Daily
    and removed
    Weekly
    on Nov 14, 2025
  17. melvin-bot commented on Nov 14, 2025

    @melvin-bot

    Payment Summary

    Upwork Job

    BugZero Checklist (@greg-schroeder)

    • (if NewFeature) I have created a PR for any necessary HelpDot updates, or I confirmed no updates are necessary.
    • I have verified the correct assignees and roles are listed above and updated the necessary manual offers
    • I have verified that there are no duplicate or incorrect contracts on Upwork for this job (https://www.upwork.com/ab/applicants//hired)
    • I have verified the PR was not reverted
    • I have applied any discounts due to bugs/regressions introduced by this PR
    • I have paid out the Upwork contracts or cancelled the ones that are incorrect
    • I have verified the payment summary above is correct
  18. greg-schroeder commented on Nov 18, 2025

    @greg-schroeder
    Contributor

    Payment summary above is good ☝️

  19. moved this from AWAITING DEPLOYMENT to Done in [#whatsnext] #qualityon Nov 18, 2025
  20. quinthar commented on Nov 28, 2025

    @quinthar
    Contributor

    Approved $250 to @abdulrahuman5196

  21. twisterdotcom commented on Dec 2, 2025

    @twisterdotcom
    Contributor

    @dukenv0307 has submitted payment for this report on ND here.

    SO: https://stackoverflowteams.com/c/expensify/questions/7582

    Zapier Logs Run ID: 00040eee-ff1e-aab4-89fc-21b617a108f4
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

Awaiting PaymentBugDailyExternalOverdue

Type

No type

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions