Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[HOLD for payment 2024-11-21] [$250] Inbox showing GBR when there’s a report with RBR #50927

Closed
1 of 8 tasks
m-natarajan opened this issue Oct 16, 2024 · 31 comments
Closed
1 of 8 tasks
Assignees
Labels
Awaiting Payment Auto-added when associated PR is deployed to production Bug Something is broken. Auto assigns a BugZero manager. Daily KSv2 External Added to denote the issue can be worked on by a contributor

Comments

@m-natarajan
Copy link

m-natarajan commented Oct 16, 2024

If you haven’t already, check out our contributing guidelines for onboarding and email [email protected] to request to join our Slack channel!


Version Number: 9.0.49-0
Reproducible in staging?: y
Reproducible in production?: y
If this was caught on HybridApp, is this reproducible on New Expensify Standalone?:
If this was caught during regression testing, add the test name, ID and link from TestRail:
Email or phone of affected tester (no customers):
Logs: https://stackoverflow.com/c/expensify/questions/4856
Expensify/Expensify Issue URL:
Issue reported by: @pac-guerreiro
Slack conversation: https://expensify.slack.com/archives/C049HHMV9SM/p1728665408536049

Action Performed:

  1. Make sure there is at least a report with GBR and another with a RBR
  2. Select a report which hasn’t a RBR indicator
  3. Go to Troubleshoot, then click on Clear cache and restart
  4. Go back to Inbox and check that the Inbox is showing a GBR indicator
  5. Open the report that has the RBR indicator then refresh the page

Expected Result:

Should have same logic that should display RBR in inbox

Actual Result:

The inbox indicator doesn’t show an updated color until the page is refreshed and it shows the wrong color until a report is fully loaded

Workaround:

unknown

Platforms:

Which of our officially supported platforms is this issue occurring on?

  • Android: Standalone
  • Android: HybridApp
  • Android: mWeb Chrome
  • iOS: Standalone
  • iOS: HybridApp
  • iOS: mWeb Safari
  • MacOS: Chrome / Safari
  • MacOS: Desktop

Screenshots/Videos

Recording.665.mp4
Screen.Recording.2024-10-16.at.15.48.24.mov
Add any screenshot/video evidence

View all open jobs on GitHub

Upwork Automation - Do Not Edit
  • Upwork Job URL: https://www.upwork.com/jobs/~021847128366508796109
  • Upwork Job ID: 1847128366508796109
  • Last Price Increase: 2024-10-18
  • Automatic offers:
    • mkhutornyi | Reviewer | 104590221
    • truph01 | Contributor | 104590223
Issue OwnerCurrent Issue Owner: @alexpensify
@m-natarajan m-natarajan added Daily KSv2 Bug Something is broken. Auto assigns a BugZero manager. labels Oct 16, 2024
Copy link

melvin-bot bot commented Oct 16, 2024

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

@FitseTLT
Copy link
Contributor

Proposal

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

Inbox showing GBR when there’s a report with RBR

What is the root cause of that problem?

We are only recalculating chat tab rbr value for transactionViolation and activeWorkspaceID changes here

setChatTabBrickRoad(getChatTabBrickRoad(activeWorkspaceID));
}, [activeWorkspaceID, transactionViolations]);

But inside getChatTabBrickRoad we use the status of allReports to calculate the value of rbr. But, allReports will not be available immediately after a user clears caches/onyx data so the rbr value will be calculated without the list of reports which will result wrong value and there is no recalculation held when the reports are loaded in onyx so it will remain green until we reload the page

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

We should subscribe to reports collection and use it in the calculation of rbr value

const [chatTabBrickRoad, setChatTabBrickRoad] = useState<BrickRoad>(getChatTabBrickRoad(activeWorkspaceID));
useEffect(() => {
setChatTabBrickRoad(getChatTabBrickRoad(activeWorkspaceID));
}, [activeWorkspaceID, transactionViolations]);

const [chatTabBrickRoad, setChatTabBrickRoad] = useState<BrickRoad>(getChatTabBrickRoad(activeWorkspaceID));
useEffect(() => {
setChatTabBrickRoad(getChatTabBrickRoad(activeWorkspaceID));

    const [allReports] = useOnyx(ONYXKEYS.COLLECTION.REPORT);
    const [chatTabBrickRoad, setChatTabBrickRoad] = useState<BrickRoad>(getChatTabBrickRoad(activeWorkspaceID, allReports));

    useEffect(() => {
        setChatTabBrickRoad(getChatTabBrickRoad(activeWorkspaceID,allReports));
    }, [activeWorkspaceID, transactionViolations,allReports]);

function getChatTabBrickRoad(policyID?: string): BrickRoad | undefined {
const allReports = ReportConnection.getAllReports();

function getChatTabBrickRoad(policyID?: string, allReportsParam): BrickRoad | undefined {
    const allReports = allReportsParam ?? ReportConnection.getAllReports();
   

It's not a must to use the useOnyx allreports data in getChatTabBrickRoad to fix the issue; only adding allReports to useEffect's dependency suffices, but I think it is generally accepted approach to use it

What alternative solutions did you explore? (Optional)

@pac-guerreiro
Copy link
Contributor

pac-guerreiro commented Oct 17, 2024

I just want to clarify that there are two problems here:

  1. Inbox indicator is not updated in realtime
  2. Inbox indicator is green when there are reports with RBR until at least one RBR is opened manually by the user

To replicate the issue you can also do a fresh login instead of clearing onyx cache.

I had to fix the 1st problem on one of my debug mode PRs for it to work properly but the PR hasn't been merged yet (link to the fix).

If you agree, this bug could be just focused on the 2nd problem. Otherwise I'll discard the fix I did on my PR.

@truph01
Copy link
Contributor

truph01 commented Oct 17, 2024

Edited by proposal-police: This proposal was edited at 2024-10-17 09:47:30 UTC.

Proposal

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

Inbox has no GBR or RBR indicator until the page is refreshed

What is the root cause of that problem?

  • Currently, in the logic to get the RBR for policy, we do not consider the transaction violation and report violations as we did when display RBR in LHN:

if (oneTransactionThreadReportID) {
const oneTransactionThreadReport = ReportUtils.getReport(oneTransactionThreadReportID);
if (
ReportUtils.shouldDisplayTransactionThreadViolations(
oneTransactionThreadReport,
allTransactionViolations,
reportActions[oneTransactionThreadReport?.parentReportActionID ?? '-1'],
)
) {
doesReportContainErrors = CONST.BRICK_ROAD_INDICATOR_STATUS.ERROR;
}
}

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

  • We should add the logic to cover the violations in:
    let doesReportContainErrors = Object.keys(reportErrors ?? {}).length !== 0 ? CONST.BRICK_ROAD_INDICATOR_STATUS.ERROR : undefined;
    const parentReportActions = (altReportActions ?? allReportActions)?.[`${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${report?.parentReportID}`];
    const parentReportAction = parentReportActions?.[report?.parentReportActionID ?? '-1'];
    const shouldDisplayViolations = ReportUtils.shouldDisplayTransactionThreadViolations(report, allTransactionViolations, parentReportAction);
    const shouldDisplayReportViolations = ReportUtils.isReportOwner(report) && ReportUtils.hasReportViolations(report.reportID);
    const hasViolations = shouldDisplayViolations || shouldDisplayReportViolations;    
    if (hasViolations) {
        doesReportContainErrors = CONST.BRICK_ROAD_INDICATOR_STATUS.ERROR;
    }
  • And then update:

useEffect(() => {
setChatTabBrickRoad(getChatTabBrickRoad(activeWorkspaceID));
}, [activeWorkspaceID, transactionViolations]);

    const report = useOnyx(ONYXKEYS.COLLECTION.REPORT);
    const reportActions = useOnyx(ONYXKEYS.COLLECTION.REPORT_ACTIONS);
    const [chatTabBrickRoad, setChatTabBrickRoad] = useState<BrickRoad>(getChatTabBrickRoad(activeWorkspaceID));

    useEffect(() => {
        setChatTabBrickRoad(getChatTabBrickRoad(activeWorkspaceID));
    }, [activeWorkspaceID, transactionViolations, report, reportActions]);

to make sure the reports, reportActions data are updated immediately.

What alternative solutions did you explore? (Optional)

@alexpensify alexpensify added the External Added to denote the issue can be worked on by a contributor label Oct 18, 2024
@melvin-bot melvin-bot bot changed the title Inbox showing GBR when there’s a report with RBR [$250] Inbox showing GBR when there’s a report with RBR Oct 18, 2024
Copy link

melvin-bot bot commented Oct 18, 2024

Job added to Upwork: https://www.upwork.com/jobs/~021847128366508796109

@melvin-bot melvin-bot bot added the Help Wanted Apply this label when an issue is open to proposals by contributors label Oct 18, 2024
Copy link

melvin-bot bot commented Oct 18, 2024

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

@alexpensify
Copy link
Contributor

alexpensify commented Oct 18, 2024

@mkhutornyi - can you please identify if one of these proposals will fix this issue? Thanks!

Heads up, I will be offline until Tuesday, October 22, 2024, and will not actively watch over this GitHub during that period.

If this GitHub requires an urgent update, please ask for help in the #expensify-open-source Slack Room. If the inquiry can wait, I'll review it when I return online.

@muttmuure muttmuure moved this to MEDIUM in [#whatsnext] #quality Oct 18, 2024
@FitseTLT
Copy link
Contributor

The issue is very similar to #50364

@truph01
Copy link
Contributor

truph01 commented Oct 18, 2024

As mentioned by @pac-guerreiro, this bug is to fix:

Inbox indicator is green when there are reports with RBR until at least one RBR is opened manually by the user

Copy link

melvin-bot bot commented Oct 21, 2024

@alexpensify, @mkhutornyi Uh oh! This issue is overdue by 2 days. Don't forget to update your issues!

@melvin-bot melvin-bot bot added the Overdue label Oct 21, 2024
@mkhutornyi
Copy link
Contributor

reviewing 2 proposals

@melvin-bot melvin-bot bot removed the Overdue label Oct 21, 2024
@mkhutornyi
Copy link
Contributor

Inbox indicator is not updated in realtime

This was already fixed in #49962

Inbox indicator is green when there are reports with RBR until at least one RBR is opened manually by the user

This is bug to fix here.

@truph01 can you please explain why the bug is gone after at least one RBR is opened manually in RCA?

@truph01
Copy link
Contributor

truph01 commented Oct 22, 2024

can you please explain why the bug is gone after at least one RBR is opened manually in RCA?

As you can see, we are only considering the case the report is one transaction report:

if (oneTransactionThreadReportID) {
const oneTransactionThreadReport = ReportUtils.getReport(oneTransactionThreadReportID);
if (
ReportUtils.shouldDisplayTransactionThreadViolations(
oneTransactionThreadReport,
allTransactionViolations,
reportActions[oneTransactionThreadReport?.parentReportActionID ?? '-1'],
)
) {
doesReportContainErrors = CONST.BRICK_ROAD_INDICATOR_STATUS.ERROR;
}
}

And because the one transaction report data can only be available after we call OpenReport for the expense report, so the bug is gone after at least one RBR is opened.

@mkhutornyi
Copy link
Contributor

And because the one transaction report data can only be available after we call OpenReport for the expense report, so the bug is gone after at least one RBR is opened.

@truph01 I am confused. Are you saying that this bug happens only when one transaction report has RBR?

@truph01
Copy link
Contributor

truph01 commented Oct 22, 2024

Are you saying that this bug happens only when one transaction report has RBR

No, that's not what I meant. To clarify, the bug occurs in both cases—whether it's a single transaction report or not. However, when it's a single transaction report, the bug disappears after visiting the expense report page, which is what we are discussing.

@mkhutornyi
Copy link
Contributor

ok so if it's not a single transaction report, bug won't disappear even after refresh?

@truph01
Copy link
Contributor

truph01 commented Oct 22, 2024

ok so if it's not a single transaction report, bug won't disappear even after refresh?

Yes. If it's not a single transaction report, bug won't disappear even after refresh or visit any RBR report.

@mkhutornyi
Copy link
Contributor

@truph01's proposal looks good to me.
🎀👀🎀 C+ reviewed

Copy link

melvin-bot bot commented Oct 23, 2024

Triggered auto assignment to @tgolen, see https://stackoverflow.com/c/expensify/questions/7972 for more details.

@melvin-bot melvin-bot bot added the Overdue label Oct 25, 2024
Copy link

melvin-bot bot commented Oct 25, 2024

📣 @mkhutornyi 🎉 An offer has been automatically sent to your Upwork account for the Reviewer role 🎉 Thanks for contributing to the Expensify app!

Offer link
Upwork job

Copy link

melvin-bot bot commented Oct 25, 2024

📣 @truph01 🎉 An offer has been automatically sent to your Upwork account for the Contributor role 🎉 Thanks for contributing to the Expensify app!

Offer link
Upwork job
Please accept the offer and leave a comment on the Github issue letting us know when we can expect a PR to be ready for review 🧑‍💻
Keep in mind: Code of Conduct | Contributing 📖

@alexpensify
Copy link
Contributor

@truph01 - any update for the PR here? Thanks!

Copy link

melvin-bot bot commented Oct 28, 2024

@tgolen, @alexpensify, @mkhutornyi, @truph01 Whoops! This issue is 2 days overdue. Let's get this updated quick!

@muttmuure muttmuure moved this from MEDIUM to CRITICAL in [#whatsnext] #quality Oct 28, 2024
@melvin-bot melvin-bot bot added Reviewing Has a PR in review Weekly KSv2 and removed Daily KSv2 Overdue labels Oct 29, 2024
@alexpensify
Copy link
Contributor

Update: PR is in review!

@melvin-bot melvin-bot bot added Weekly KSv2 Awaiting Payment Auto-added when associated PR is deployed to production and removed Weekly KSv2 labels Nov 14, 2024
@melvin-bot melvin-bot bot changed the title [$250] Inbox showing GBR when there’s a report with RBR [HOLD for payment 2024-11-21] [$250] Inbox showing GBR when there’s a report with RBR Nov 14, 2024
@melvin-bot melvin-bot bot removed the Reviewing Has a PR in review label Nov 14, 2024
Copy link

melvin-bot bot commented Nov 14, 2024

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

Copy link

melvin-bot bot commented Nov 14, 2024

The solution for this issue has been 🚀 deployed to production 🚀 in version 9.0.61-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 2024-11-21. 🎊

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

Copy link

melvin-bot bot commented Nov 14, 2024

@tgolen @alexpensify @mkhutornyi / @truph01 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]

@melvin-bot melvin-bot bot added Daily KSv2 and removed Weekly KSv2 labels Nov 20, 2024
@alexpensify
Copy link
Contributor

alexpensify commented Nov 22, 2024

Payouts due: 2024-11-21

Upwork job is here.

@alexpensify
Copy link
Contributor

Everyone has been paid via Upwork. @mkhutornyi - can you please complete the checklist and confirm if there is a regression test? Thanks!

@melvin-bot melvin-bot bot added the Overdue label Nov 25, 2024
Copy link

melvin-bot bot commented Nov 25, 2024

@tgolen, @alexpensify, @mkhutornyi, @truph01 Uh oh! This issue is overdue by 2 days. Don't forget to update your issues!

@alexpensify
Copy link
Contributor

Closing

@melvin-bot melvin-bot bot removed the Overdue label Nov 25, 2024
@github-project-automation github-project-automation bot moved this from CRITICAL to Done in [#whatsnext] #quality Nov 25, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Awaiting Payment Auto-added when associated PR is deployed to production Bug Something is broken. Auto assigns a BugZero manager. Daily KSv2 External Added to denote the issue can be worked on by a contributor
Projects
Development

No branches or pull requests

7 participants