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 2023-11-29] [$500] Status - Different chat report opens when clicking on the back button in Status modal #30509

Closed
2 of 6 tasks
izarutskaya opened this issue Oct 27, 2023 · 29 comments
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

@izarutskaya
Copy link

izarutskaya commented Oct 27, 2023

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: v1.3.92-0
Reproducible in staging?: Y
Reproducible in production?: Y
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: Applause-Internal Team
Slack conversation: @

Action Performed:

Precondition: User has set a status.

  1. Go to staging.new.expensify.com
  2. Open different chat reports.
  3. Click on the status on the top left.
  4. Click on the back button.

Expected Result:

The current chat report remains open.

Actual Result:

A different chat report opens.

Workaround:

Unknown

Platforms:

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

  • Android: Native
  • Android: mWeb Chrome
  • iOS: Native
  • iOS: mWeb Safari
  • MacOS: Chrome / Safari
  • MacOS: Desktop

Screenshots/Videos

Android: Native
Android: mWeb Chrome
iOS: Native
iOS: mWeb Safari
MacOS: Chrome / Safari
Bug6253028_1698396389798.20231027_164311.mp4
MacOS: Desktop

View all open jobs on GitHub

Upwork Automation - Do Not Edit
  • Upwork Job URL: https://www.upwork.com/jobs/~01f903eb3ac10fe198
  • Upwork Job ID: 1717888354588504064
  • Last Price Increase: 2023-10-27
  • Automatic offers:
    • shubham1206agra | Reviewer | 27537929
    • dukenv0307 | Contributor | 27537933
@izarutskaya izarutskaya added External Added to denote the issue can be worked on by a contributor Daily KSv2 Bug Something is broken. Auto assigns a BugZero manager. labels Oct 27, 2023
@melvin-bot melvin-bot bot changed the title Status - Different chat report opens when clicking on the back button in Status modal [$500] Status - Different chat report opens when clicking on the back button in Status modal Oct 27, 2023
@melvin-bot
Copy link

melvin-bot bot commented Oct 27, 2023

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

@melvin-bot
Copy link

melvin-bot bot commented Oct 27, 2023

Triggered auto assignment to @CortneyOfstad (Bug), see https://stackoverflow.com/c/expensify/questions/14418 for more details.

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

melvin-bot bot commented Oct 27, 2023

Bug0 Triage Checklist (Main S/O)

  • This "bug" occurs on a supported platform (ensure Platforms in OP are ✅)
  • This bug is not a duplicate report (check E/App issues and #expensify-bugs)
    • If it is, comment with a link to the original report, close the issue and add any novel details to the original issue instead
  • This bug is reproducible using the reproduction steps in the OP. S/O
    • If the reproduction steps are clear and you're unable to reproduce the bug, check with the reporter and QA first, then close the issue.
    • If the reproduction steps aren't clear and you determine the correct steps, please update the OP.
  • This issue is filled out as thoroughly and clearly as possible
    • Pay special attention to the title, results, platforms where the bug occurs, and if the bug happens on staging/production.
  • I have reviewed and subscribed to the linked Slack conversation to ensure Slack/Github stay in sync

@melvin-bot
Copy link

melvin-bot bot commented Oct 27, 2023

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

@namhihi237
Copy link
Contributor

namhihi237 commented Oct 27, 2023

Proposal

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

Different chat report opens when clicking on the back button in Status modal

What is the root cause of that problem?

In the StatusPage we pass navigateBackToSettingsPage into onBackButtonPress prop.
In navigateBackToSettingsPage we pass the param shouldPopToTop = true here

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

I think we can remove the shouldPopToTop param

        Navigation.goBack(ROUTES.SETTINGS_PROFILE, false)

What alternative solutions did you explore? (Optional)

N/A

@s-alves10
Copy link
Contributor

s-alves10 commented Oct 27, 2023

Proposal

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

When go to status page after navigating several reports, back button navigates to the report other than the current report

What is the root cause of that problem?

When we navigate to status page, we set shouldPopAllStateOnUP to true and go to the page

Navigation.setShouldPopAllStateOnUP();

And when we go back, we call navigate.goBack with shouldPopToTop = true
const navigateBackToSettingsPage = useCallback(() => Navigation.goBack(ROUTES.SETTINGS_PROFILE, false, true), []);

This makes the route stack pop to the first page, which is home page.

if (shouldPopToTop) {
if (shouldPopAllStateOnUP) {
shouldPopAllStateOnUP = false;
navigationRef.current.dispatch(StackActions.popToTop());
return;
}
}

For wide screen devices, we navigate to the last accessed report when navigating to home page

const reportID = getLastAccessedReportID(reports, !canUseDefaultRooms, policies, isFirstTimeNewExpensifyUser, lodashGet(route, 'params.openOnAdminRoom', false));

We determine the last access report by its lastReadTime.

let sortedReports = sortReportsByLastRead(reports);

The problem is here. When we call OpenReport API, lastReadTime isn't updated
image

This is the root cause

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

I think this issue should be fixed in the backend.
OpenReport call should return the updated lastReadTime

What alternative solutions did you explore? (Optional)

We can simply call Navigation.goBack(ROUTES.SETTINGS_PROFILE), that is, call goBack with shouldPopToTop = false

@dukenv0307
Copy link
Contributor

dukenv0307 commented Oct 28, 2023

Proposal

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

A different chat report opens when clicking back button in status modal.

What is the root cause of that problem?

We're setting shouldPopToTop: true when going back from the status page here. We're also calling setShouldPopAllStateOnUP here in the Avatar status.

This is so that:

  • If the user navigates to the StatusPage from the Avatar status, they should go back to the LHN (or the last report in the background, in case of wide screen)
  • If the user navigates to the StatusPage via deep link (not going through the Avatar status), they should go back to the Profile settings page normally (because in this case setShouldPopAllStateOnUP is not set)

But this causes a side effect, which is this issue, where we go back to a different report, because the report that was open when avatar status is clicked might not be the last read report of the LHN.

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

We just need to add a condition, if there's a report open in the background of the status page (in that case there exists a topmost report id), we should go back to that report instead. We can update this to

const topmostReportId = Navigation.getTopmostReportId();
const navigateBackToSettingsPage = useCallback(() => {
        if (topmostReportId) {
            Navigation.goBack(ROUTES.REPORT_WITH_ID.getRoute(topmostReportId))
        } else {
            Navigation.goBack(ROUTES.SETTINGS_PROFILE, false, true);
        }
    }
, [topmostReportId]);

This will keep our intended behavior for using shouldPopToTop, while fixing the side effect that causes this issue.

What alternative solutions did you explore? (Optional)

NA

@melvin-bot melvin-bot bot added the Overdue label Oct 30, 2023
@CortneyOfstad
Copy link
Contributor

@shubham1206agra thoughts on the proposals above? Thanks!

@melvin-bot melvin-bot bot removed the Overdue label Oct 30, 2023
@shubham1206agra
Copy link
Contributor

@dukenv0307's proposal works correctly.
But @s-alves10 comment about lastReadTime not being updated seems correct, too.
We can go with @dukenv0307, but I think we should discuss the backend call for the OpenReport API with an engineer.
🎀 👀 🎀 C+ reviewed

@melvin-bot
Copy link

melvin-bot bot commented Oct 31, 2023

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

@s-alves10
Copy link
Contributor

I suggest to try with backend updates updating lastReadTime first. Obviously this is a bug, I think. If it doesn't solve the issue. we can go with @dukenv0307 's proposal

@dukenv0307
Copy link
Contributor

dukenv0307 commented Oct 31, 2023

I suggest to try with backend updates updating lastReadTime first

@s-alves10 @shubham1206agra that bug has its own separate GH here, and was closed due to this reasoning.

I was also trying to get it reopened, but if it should be fixed, it should be fixed there, also I don't think it's the root cause of this issue so we can go forward with this one. That's because, @s-alves10 even after that BE issue is fixed, if you open the Status page, then in another device you read another report, then coming back to this device and click back on Status modal, it will go to that other report rather than the report in the background of the Status page.

@shubham1206agra
Copy link
Contributor

Ok let's go with @dukenv0307 proposal then

@s-alves10
Copy link
Contributor

Even after that BE issue is fixed, if you open the Status page, then in another device you read another report, then coming back to this device and click back on Status modal, it will go to that other report rather than the report in the background of the Status page.

@dukenv0307

Maybe you're right, but from my research, I don't think so

By the way, don't you think not updating lastReadTime is a bug? I am sure we need to update the lastReadTime when we call OpenReport API call. That's why I suggested to fix the backend first.

Anyway, these are just my personal thoughts.

@shubham1206agra
Copy link
Contributor

@s-alves10 Please don't worry about this. Let me ask this in Slack.

@shubham1206agra
Copy link
Contributor

Is there any specific reason we do not update lastReadTime when opening a report using OpenReport API call?

Yes, because with OpenReport we're just fetching reports for user from the server. The report is read when we actually render them on the screen. These are two closely related but different actions and hence we have different API calls.
More information is in the description of this issue #23171

This is the answer I got @s-alves10

@dukenv0307
Copy link
Contributor

By the way, don't you think not updating lastReadTime is a bug? I am sure we need to update the lastReadTime when we call OpenReport API call.

@s-alves10 yes I agree with you on this, but it's part of this separate issue, which I'm advocating to reopen. It can be fixed separately IMO

@shubham1206agra
Copy link
Contributor

@Beamanator Friendly bump

@Beamanator
Copy link
Contributor

@shubham1206agra thanks for bringing that convo to slack, can you please link it here so it's easy access? If you're having trouble getting that separate issue to reopen, we may also want to bring that up in slack (if you haven't already)

So @shubham1206agra you're still advocating for going with @dukenv0307 's proposal, right? Anything you need from me other than a review as well?

@shubham1206agra
Copy link
Contributor

@Beamanator You can proceed with @dukenv0307 right now

I do have seperate issue for this too which are open. I will start a discussion there only (maybe in slack too)

@melvin-bot melvin-bot bot removed the Help Wanted Apply this label when an issue is open to proposals by contributors label Nov 6, 2023
@Beamanator
Copy link
Contributor

Thanks @shubham1206agra !

Copy link

melvin-bot bot commented Nov 6, 2023

📣 @shubham1206agra 🎉 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 Nov 6, 2023

📣 @dukenv0307 🎉 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 📖

@dukenv0307
Copy link
Contributor

@shubham1206agra The PR is ready for 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 22, 2023
@melvin-bot melvin-bot bot changed the title [$500] Status - Different chat report opens when clicking on the back button in Status modal [HOLD for payment 2023-11-29] [$500] Status - Different chat report opens when clicking on the back button in Status modal Nov 22, 2023
Copy link

melvin-bot bot commented Nov 22, 2023

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

@melvin-bot melvin-bot bot removed the Reviewing Has a PR in review label Nov 22, 2023
Copy link

melvin-bot bot commented Nov 22, 2023

The solution for this issue has been 🚀 deployed to production 🚀 in version 1.4.1-13 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 2023-11-29. 🎊

After the hold period is over and BZ checklist items are completed, please complete any of the applicable payments for this issue, and check them off once done.

  • External issue reporter — Applause Team, so no payment needed
  • Contributor that fixed the issue — @shubham1206agra paid $500 via Upwork
  • Contributor+ that helped on the issue and/or PR — @dukenv0307 paid $500 via Upwork

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

Copy link

melvin-bot bot commented Nov 22, 2023

BugZero Checklist: The PR fixing this issue has been merged! The following checklist (instructions) will need to be completed before the issue can be closed:

  • [@shubham1206agra] The PR that introduced the bug has been identified. Link to the PR:
  • [@shubham1206agra] 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:
  • [@shubham1206agra] A discussion in #expensify-bugs 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:
  • [@shubham1206agra] Determine if we should create a regression test for this bug.
  • [@shubham1206agra] If we decide to create a regression test for the bug, please propose the regression test steps to ensure the same bug will not reach production again.
  • [@CortneyOfstad] Link the GH issue for creating/updating the regression test once above steps have been agreed upon: https://github.com/Expensify/Expensify/issues/341483

@shubham1206agra
Copy link
Contributor

BugZero Checklist: The PR fixing this issue has been merged! The following checklist (instructions) will need to be completed before the issue can be closed:

  1. Open the App with an account that has a status set already.
  2. Open different chat reports.
  3. Click on the status on the top left.
  4. Click on the back button.

@melvin-bot melvin-bot bot added Daily KSv2 Overdue and removed Weekly KSv2 labels Nov 28, 2023
@CortneyOfstad
Copy link
Contributor

@shubham1206agra @dukenv0307 — both of you have been paid in NewDot and regression test was created here — closing!

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
None yet
Development

No branches or pull requests

7 participants