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-10-25] [$250] QAB - Destination opens in the background when starting QAB flow #46352

Closed
3 of 6 tasks
lanitochka17 opened this issue Jul 27, 2024 · 76 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

@lanitochka17
Copy link

lanitochka17 commented Jul 27, 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.13-3
Reproducible in staging?: Y
Reproducible in production?: Y
If this was caught during regression testing, add the test name, ID and link from TestRail: N/A
Issue reported by: Applause - Internal Team

Action Performed:

  1. Launch New Expensify app
  2. Go to workspace chat
  3. Submit an expense
  4. Return to LHN
  5. Tap FAB
  6. Tap Submit expense under QAB section
  7. Tap app back button

Expected Result:

App will return to LHN after closing QAB flow

Actual Result:

App will return to workspace chat (destination) after closing QAB flow
The destination (in this case, workspace chat) opens in the background when starting QAB flow

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

Add any screenshot/video evidence

Bug6554078_1722025287007.ScreenRecording_07-27-2024_04-17-08_1.mp4

View all open jobs on GitHub

Upwork Automation - Do Not Edit
  • Upwork Job URL: https://www.upwork.com/jobs/~01234964a7fed98878
  • Upwork Job ID: 1819145506544874650
  • Last Price Increase: 2024-09-26
  • Automatic offers:
    • tsa321 | Contributor | 104236266
Issue OwnerCurrent Issue Owner: @aimane-chnaif
@lanitochka17 lanitochka17 added Daily KSv2 Bug Something is broken. Auto assigns a BugZero manager. labels Jul 27, 2024
Copy link

melvin-bot bot commented Jul 27, 2024

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

@lanitochka17
Copy link
Author

@kevinksullivan FYI I haven't added the External label as I wasn't 100% sure about this issue. Please take a look and add the label if you agree it's a bug and can be handled by external contributors

@lanitochka17
Copy link
Author

We think that this bug might be related to #wave-collect - Release 1

@tsa321
Copy link
Contributor

tsa321 commented Jul 28, 2024

Edited by proposal-police: This proposal was edited at 2024-08-09 22:16:08 UTC.

Proposal

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

QAB - Destination opens in the background when starting QAB flow

What is the root cause of that problem?

Here:

if (rhpNavigator) {
// Routes
// - matching bottom tab
// - matching root route for rhp
// - found rhp
// This one will be defined because rhpNavigator is defined.
const focusedRHPRoute = findFocusedRoute(state);
const routes = [];
if (focusedRHPRoute) {
let matchingRootRoute = getMatchingRootRouteForRHPRoute(focusedRHPRoute);
const isRHPScreenOpenedFromLHN = focusedRHPRoute?.name && RHP_SCREENS_OPENED_FROM_LHN.includes(focusedRHPRoute?.name as RHPScreenOpenedFromLHN);
// This may happen if this RHP doens't have a route that should be under the overlay defined.
if (!matchingRootRoute || isRHPScreenOpenedFromLHN) {
metainfo.isCentralPaneAndBottomTabMandatory = false;
metainfo.isFullScreenNavigatorMandatory = false;
// If matchingRootRoute is undefined and it's a narrow layout, don't add a report screen under the RHP.
matchingRootRoute = matchingRootRoute ?? (!isNarrowLayout ? {name: SCREENS.REPORT} : undefined);
}

When the target navigation is RHP from the bottom tab navigator (LHN), as in the case of creating an IOU request, the isRHPScreenOpenedFromLHN does not include SCREENS.MONEY_REQUEST.CREATE. As a result, the isRHPScreenOpenedFromLHN condition evaluates to false, and since there is a matchingRootRoute, the metainfo values for isCentralPaneAndBottomTabMandatory and isFullScreenNavigatorMandatory remain true. Consequently, the navigation state adapts to include the central pane route (the matching root route, which in this case is the report screen).

If the user clicks on the FAB and selects "Submit Expense," the matchingRootRoute will be undefined because the report ID in the URL/route is generated optimistically. This change will update the metainfo to:
metainfo.isCentralPaneAndBottomTabMandatory = false; metainfo.isFullScreenNavigatorMandatory = false;

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

we should include the iou request create focused route, (in this case "manual") add SCREENS.MONEY_REQUEST.CREATE.MANUAL / CONST.TAB_REQUEST_MANUAL in RHP_SCREENS_OPENED_FROM_LHN, also we must check other related screens that can be opened from LHN, the scan and distance tab_request, etc...

Alternative solution

I think there will be many screens to include as well.

I believe a better fix is:

if (focusedRHPRoute) {
let matchingRootRoute = getMatchingRootRouteForRHPRoute(focusedRHPRoute);
const isRHPScreenOpenedFromLHN = focusedRHPRoute?.name && RHP_SCREENS_OPENED_FROM_LHN.includes(focusedRHPRoute?.name as RHPScreenOpenedFromLHN);
// This may happen if this RHP doens't have a route that should be under the overlay defined.
if (!matchingRootRoute || isRHPScreenOpenedFromLHN) {

to make the matchingRootRoute has correct value.

The getMatchingRootRouteForRHPRoute will always include the report screen if there is a reportID parameter in the route:

// check for valid reportID in the route params
// if the reportID is valid, we should navigate back to screen report in CPN
const reportID = (route.params as Record<string, string | undefined>)?.reportID;
if (ReportConnection.getAllReports()?.[`${ONYXKEYS.COLLECTION.REPORT}${reportID}`]) {
return {name: SCREENS.REPORT, params: {reportID}};
}

However, the route that must include the report screen is the route that starts with /r/. Other routes do not need to include the report screen. Therefore, the code changes should be:

// sometimes route path start with `/` and sometimes not. just to make sure here.
if (route?.path.indexOf('/r/') === 0 || route?.path.indexOf('r/') === 0) {
        const reportID = (route.params as Record < string, string | undefined > )?.reportID;
        if (!!reportID && ReportConnection.getAllReports()?.[`${ONYXKEYS.COLLECTION.REPORT}${reportID}`]) {
            return {name: SCREENS.REPORT, params: {reportID}};
        }
    }

Other routes which really require report of reportID param to be openened first can be included in exception list.

@melvin-bot melvin-bot bot added the Overdue label Jul 29, 2024
Copy link

melvin-bot bot commented Jul 30, 2024

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

Copy link

melvin-bot bot commented Aug 1, 2024

@kevinksullivan Eep! 4 days overdue now. Issues have feelings too...

@kevinksullivan
Copy link
Contributor

Reproduced. I think this is a polish item for collect.

@melvin-bot melvin-bot bot removed the Overdue label Aug 1, 2024
@kevinksullivan kevinksullivan added the External Added to denote the issue can be worked on by a contributor label Aug 1, 2024
@melvin-bot melvin-bot bot changed the title QAB - Destination opens in the background when starting QAB flow [$250] QAB - Destination opens in the background when starting QAB flow Aug 1, 2024
Copy link

melvin-bot bot commented Aug 1, 2024

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

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

melvin-bot bot commented Aug 1, 2024

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

@goldman727
Copy link

I have seen about this issue, what do you need fix exactly?

Copy link

melvin-bot bot commented Aug 5, 2024

@kevinksullivan, @aimane-chnaif Whoops! This issue is 2 days overdue. Let's get this updated quick!

@melvin-bot melvin-bot bot added the Overdue label Aug 5, 2024
@aimane-chnaif
Copy link
Contributor

reviewing

@melvin-bot melvin-bot bot removed the Overdue label Aug 5, 2024
@aimane-chnaif
Copy link
Contributor

Reproduced. This happens in various flows.

i.e. split expense

split.mp4

@tsa321 can you please share test branch covering all cases?

@tsa321
Copy link
Contributor

tsa321 commented Aug 7, 2024

@aimane-chnaif, I think there will be many screens to include as well.

I believe a better fix is:

if (focusedRHPRoute) {
let matchingRootRoute = getMatchingRootRouteForRHPRoute(focusedRHPRoute);
const isRHPScreenOpenedFromLHN = focusedRHPRoute?.name && RHP_SCREENS_OPENED_FROM_LHN.includes(focusedRHPRoute?.name as RHPScreenOpenedFromLHN);
// This may happen if this RHP doens't have a route that should be under the overlay defined.
if (!matchingRootRoute || isRHPScreenOpenedFromLHN) {

to make the matchingRootRoute has correct value.

The getMatchingRootRouteForRHPRoute will always include the report screen if there is a reportID parameter in the route:

// check for valid reportID in the route params
// if the reportID is valid, we should navigate back to screen report in CPN
const reportID = (route.params as Record<string, string | undefined>)?.reportID;
if (ReportConnection.getAllReports()?.[`${ONYXKEYS.COLLECTION.REPORT}${reportID}`]) {
return {name: SCREENS.REPORT, params: {reportID}};
}

However, the route that must include the report screen is the route that starts with /r/. Other routes do not need to include the report screen. Therefore, the code changes should be:

// sometimes route path start with `/` and sometimes not. just to make sure here.
if (route?.path.indexOf('/r/') === 0 || route?.path.indexOf('r/') === 0) {
        const reportID = (route.params as Record < string, string | undefined > )?.reportID;
        if (!!reportID && ReportConnection.getAllReports()?.[`${ONYXKEYS.COLLECTION.REPORT}${reportID}`]) {
            return {name: SCREENS.REPORT, params: {reportID}};
        }
    }

Alternatively, if you think a better solution would be to include the related screens in RHP_SCREENS_OPENED_FROM_LHN, I can list the screens.

@aimane-chnaif
Copy link
Contributor

I prefer general solution. If we can fix in navigation level (getAdaptedStateFromPath), that would be great.

@tsa321
Copy link
Contributor

tsa321 commented Aug 8, 2024

@aimane-chnaif then How about my code change, replace these lines:

// check for valid reportID in the route params
// if the reportID is valid, we should navigate back to screen report in CPN
const reportID = (route.params as Record<string, string | undefined>)?.reportID;
if (ReportConnection.getAllReports()?.[`${ONYXKEYS.COLLECTION.REPORT}${reportID}`]) {
return {name: SCREENS.REPORT, params: {reportID}};
}

with:

// sometimes route path start with `/` and sometimes not. just to make sure here.
if (route?.path.indexOf('/r/') === 0 || route?.path.indexOf('r/') === 0) {
        const reportID = (route.params as Record < string, string | undefined > )?.reportID;
        if (!!reportID && ReportConnection.getAllReports()?.[`${ONYXKEYS.COLLECTION.REPORT}${reportID}`]) {
            return {name: SCREENS.REPORT, params: {reportID}};
        }
    }

This will fix many similar issues.

Copy link

melvin-bot bot commented Aug 8, 2024

📣 It's been a week! Do we have any satisfactory proposals yet? Do we need to adjust the bounty for this issue? 💸

Copy link

melvin-bot bot commented Oct 1, 2024

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

@mallenexpensify
Copy link
Contributor

mallenexpensify commented Oct 1, 2024

Since I happen to be in this issue for some reason...
At a high level, if a contributor provides a solution on an issue that has the Help Wanted label, they might be eligible for compensation. I think my preference here would be to have @tsa321 raise the PR, since that keeps things easy, where they'd get paid the full amount. @aimane-chnaif is there a reason you wouldn't recommend this? (I realize you found the offending PR, thanks for helping there)

@aimane-chnaif
Copy link
Contributor

aimane-chnaif commented Oct 2, 2024

The bug didn't happen before so I was sure that this was recent regression. So I didn't accept any proposal without finding offending PR, which means the root cause is not accurate. That's only the reason.

@dangrous
Copy link
Contributor

dangrous commented Oct 2, 2024

Jumping in here too, I think if the solution is correct let's move forward with @tsa321; it's definitely not the ideal that the root cause was incorrect originally, but now that we've determined it and the proposal still solves it in the best way possible, I think that's okay.

I'll wait a bit for any further discussion and then plan to assign @tsa321 - let's just make sure in the future we make sure to find that correct root cause since that will give us the best solution!

Copy link

melvin-bot bot commented Oct 2, 2024

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

@Guccio163
Copy link
Contributor

I see that @tsa321 will handle this one, feel free to call me for a review etc. when the PR is done though ;)

@melvin-bot melvin-bot bot added Reviewing Has a PR in review Weekly KSv2 and removed Daily KSv2 labels Oct 4, 2024
@melvin-bot melvin-bot bot added Weekly KSv2 Awaiting Payment Auto-added when associated PR is deployed to production and removed Weekly KSv2 labels Oct 18, 2024
@melvin-bot melvin-bot bot changed the title [$250] QAB - Destination opens in the background when starting QAB flow [HOLD for payment 2024-10-25] [$250] QAB - Destination opens in the background when starting QAB flow Oct 18, 2024
@melvin-bot melvin-bot bot removed the Reviewing Has a PR in review label Oct 18, 2024
Copy link

melvin-bot bot commented Oct 18, 2024

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

Copy link

melvin-bot bot commented Oct 18, 2024

The solution for this issue has been 🚀 deployed to production 🚀 in version 9.0.50-8 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-10-25. 🎊

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

Copy link

melvin-bot bot commented Oct 18, 2024

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:

  • [@aimane-chnaif] The PR that introduced the bug has been identified. Link to the PR:
  • [@aimane-chnaif] 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:
  • [@aimane-chnaif] 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:
  • [@aimane-chnaif] Determine if we should create a regression test for this bug.
  • [@aimane-chnaif] 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.
  • [@sonialiap] Link the GH issue for creating/updating the regression test once above steps have been agreed upon: https://github.com/Expensify/Expensify/issues/439489

@sonialiap
Copy link
Contributor

sonialiap commented Oct 25, 2024

Payment summary:

@sonialiap sonialiap added Daily KSv2 and removed Weekly KSv2 labels Oct 25, 2024
@melvin-bot melvin-bot bot added Daily KSv2 and removed Daily KSv2 labels Oct 25, 2024
@aimane-chnaif
Copy link
Contributor

aimane-chnaif commented Oct 28, 2024

Regression Test Proposal

  1. Complete the manual expense submission flow.
  2. Click on FAB, then select QAB to open the expense submission flow.
  3. Click the back button in the header.
  4. For small screens (Android and iOS), verify that the LHN screen opens instead of the report screen. For wide screens, ensure that the submit expense flow functions properly.
  5. Repeat steps 1–4 for the scan and distance expense submission flows.

@aimane-chnaif
Copy link
Contributor

@sonialiap I am still using upwork

@sonialiap
Copy link
Contributor

@aimane-chnaif oh sorry! I saw that you're whitelisted for ND payments. Offer sent in Upwork

Copy link

melvin-bot bot commented Oct 29, 2024

@dangrous @sonialiap Be sure to fill out the Contact List!

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
No open projects
Status: Polish
Development

No branches or pull requests