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-08-22] [$250] Web - Expense - App navigates to not found page when paying part of an expense offline #46600

Closed
2 of 6 tasks
lanitochka17 opened this issue Jul 31, 2024 · 22 comments
Assignees
Labels
Awaiting Payment Auto-added when associated PR is deployed to production Bug Something is broken. Auto assigns a BugZero manager. External Added to denote the issue can be worked on by a contributor Reviewing Has a PR in review Weekly KSv2

Comments

@lanitochka17
Copy link

lanitochka17 commented Jul 31, 2024

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.0.14-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: N/A
Email or phone of affected tester (no customers): Yokabdk+new1@gmail.com
Issue reported by: Applause - Internal Team

Action Performed:

  1. Go to staging.new.expensify.com
  2. Go to settings and workspace and create a workspace
  3. Go to FAB
  4. Click on submit expense and click the workspace you created
  5. Enter an amount (e.g 100) and click Next
  6. Input a merchant and submit the expense
  7. Create another expense with a different amount (e.g 50)
  8. Navigate to the expense details page of the first expense (e.g 100)
  9. Click on header and click on hold
  10. Click on the subtitle "From" link to go back to the expense lists page (Important)
  11. Click on the drop down of the green pay button at the top right corner
  12. Click on "Pay elsewhere"
  13. Click on "Pay only 50" on the confirmation pop up

Expected Result:

App navigates to the expense lists page which is the behavior in online mode

Actual Result:

App navigates to not here page when clicking on the pay only ... button while offline

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

Bug6553411_1721982281588.VID_20240726_112408_394.mp4

View all open jobs on GitHub

Upwork Automation - Do Not Edit
  • Upwork Job URL: https://www.upwork.com/jobs/~0116c34258c5f026d6
  • Upwork Job ID: 1818936321732205498
  • Last Price Increase: 2024-08-01
  • Automatic offers:
    • brunovjk | Reviewer | 103423828
Issue OwnerCurrent Issue Owner: @twisterdotcom
@lanitochka17 lanitochka17 added Daily KSv2 Bug Something is broken. Auto assigns a BugZero manager. labels Jul 31, 2024
Copy link

melvin-bot bot commented Jul 31, 2024

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

@twisterdotcom 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

@bernhardoj
Copy link
Contributor

bernhardoj commented Aug 1, 2024

Proposal

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

Not found page when paying partial report.

What is the root cause of that problem?

The not found page is because the report action isn't found anymore. If we have a hold expense and then pay it partially, we will optimistically remove the hold expense and move it to a new expense report. This is introduced in #42573.

App/src/libs/actions/IOU.ts

Lines 6564 to 6572 in bbaa9da

if (!full) {
const holdReportOnyxData = getReportFromHoldRequestsOnyxData(chatReport, iouReport, recipient);
optimisticData.push(...holdReportOnyxData.optimisticData);
failureData.push(...holdReportOnyxData.failureData);
optimisticHoldReportID = holdReportOnyxData.optimisticHoldReportID;
optimisticHoldActionID = holdReportOnyxData.optimisticHoldActionID;
optimisticHoldReportExpenseActionIDs = JSON.stringify(holdReportOnyxData.optimisticHoldReportExpenseActionIDs);
}

If we link to the hold expense action, when it's moved to the new expense report, the not found page shows.

const shouldShowNotFoundLinkedAction =
(!isLinkedActionInaccessibleWhisper && isLinkedActionDeleted) ||
(shouldShowSkeleton &&
!reportMetadata.isLoadingInitialReportActions &&
!!reportActionIDFromRoute &&
!!sortedAllReportActions &&
sortedAllReportActions?.length > 0 &&
reportActions.length === 0 &&
!isLinkingToMessage);

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

We can follow a similar approach when deleting a comment by checking if the deleted action is the linked action, then clear the reportActionID from the params.

App/src/libs/actions/Report.ts

Lines 1498 to 1502 in d69b203

// if we are linking to the report action, and we are deleting it, and it's not a deleted parent action,
// we should navigate to its report in order to not show not found page
if (Navigation.isActiveRoute(ROUTES.REPORT_WITH_ID.getRoute(reportID, reportActionID)) && !isDeletedParentAction) {
Navigation.goBack(ROUTES.REPORT_WITH_ID.getRoute(reportID), true);
}

App/src/libs/actions/IOU.ts

Lines 6564 to 6572 in bbaa9da

if (!full) {
const holdReportOnyxData = getReportFromHoldRequestsOnyxData(chatReport, iouReport, recipient);
optimisticData.push(...holdReportOnyxData.optimisticData);
failureData.push(...holdReportOnyxData.failureData);
optimisticHoldReportID = holdReportOnyxData.optimisticHoldReportID;
optimisticHoldActionID = holdReportOnyxData.optimisticHoldActionID;
optimisticHoldReportExpenseActionIDs = JSON.stringify(holdReportOnyxData.optimisticHoldReportExpenseActionIDs);
}

for (const oldReportAction of holdReportOnyxData.optimisticHoldReportExpenseActionIDs) {
    if (Navigation.isActiveRoute(ROUTES.REPORT_WITH_ID.getRoute(iouReport.reportID, oldReportAction.oldReportActionID))) {
        Navigation.goBack(ROUTES.REPORT_WITH_ID.getRoute(iouReport.reportID), true);
        break;
    }
}

We will do the same for approving

What alternative solutions did you explore? (Optional)

In ReportScreen, if the linked action is previously available but is now deleted, clear the reportActionID.

const isLinkedActionDeleted = useMemo(() => !!linkedAction && !ReportActionsUtils.shouldReportActionBeVisible(linkedAction, linkedAction.reportActionID), [linkedAction]);

const prevIsLinkedActionDeleted = usePrevious(linkedAction ? isLinkedActionDeleted : undefined);

useEffect(() => {
    if (prevIsLinkedActionDeleted !== undefined && !prevIsLinkedActionDeleted && isLinkedActionDeleted) {
        Navigation.setParams({reportActionID: ''});
    }
}, [prevIsDeletedParentAction, isLinkedActionDeleted]);

But the user will notice a brief blink of the not found page because we clear the reportActionID not immediately and to prevent that, we can update the not found condition to only show if both the previous prevIsLinkedActionDeleted and isLinkedActionDeleted are true.

const shouldShowNotFoundLinkedAction =
(!isLinkedActionInaccessibleWhisper && isLinkedActionDeleted) ||

const shouldShowNotFoundLinkedAction =
    (!isLinkedActionInaccessibleWhisper && isLinkedActionDeleted && prevIsLinkedActionDeleted) ||

@twisterdotcom twisterdotcom added the External Added to denote the issue can be worked on by a contributor label Aug 1, 2024
Copy link

melvin-bot bot commented Aug 1, 2024

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

@melvin-bot melvin-bot bot changed the title Web - Expense - App navigates to not found page when paying part of an expense offline [$250] Web - Expense - App navigates to not found page when paying part of an expense offline Aug 1, 2024
@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 - @brunovjk (External)

@brunovjk
Copy link
Contributor

brunovjk commented Aug 1, 2024

@bernhardoj's proposal LGTM. The RCA seems correct to me, about the solution I'm not so sure, I tested and works fine but, I'll wait for @neil-marcellini opinion about it.

🎀👀🎀 C+ reviewed

Copy link

melvin-bot bot commented Aug 1, 2024

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

@brunovjk
Copy link
Contributor

brunovjk commented Aug 1, 2024

@neil-marcellini, what do you think of the proposed alternative solution? Thank you.

Copy link

melvin-bot bot commented Aug 5, 2024

@twisterdotcom, @neil-marcellini, @brunovjk 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
@twisterdotcom
Copy link
Contributor

Bump on this @neil-marcellini

@melvin-bot melvin-bot bot removed the Overdue label Aug 6, 2024
@neil-marcellini
Copy link
Contributor

@bernhardoj's proposal LGTM

I agree, we might need some tweaks in the PR, but we'll see.

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

melvin-bot bot commented Aug 6, 2024

📣 @brunovjk 🎉 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

@bernhardoj
Copy link
Contributor

PR is ready

cc: @brunovjk

@neil-marcellini
Copy link
Contributor

Head's up, I'll be working 50% for the rest of this week and next 🌲

@neil-marcellini
Copy link
Contributor

It's time to do payment and close this out

@brunovjk
Copy link
Contributor

Note

The production deploy automation failed: This should be on [HOLD for Payment 2024-08-22] according to #47356 prod deploy checklist, confirmed in #46942 (comment).

cc: @twisterdotcom

@twisterdotcom twisterdotcom changed the title [$250] Web - Expense - App navigates to not found page when paying part of an expense offline [HOLD for Payment 2024-08-22] [$250] Web - Expense - App navigates to not found page when paying part of an expense offline Aug 21, 2024
@twisterdotcom twisterdotcom added the Awaiting Payment Auto-added when associated PR is deployed to production label Aug 21, 2024
@brunovjk
Copy link
Contributor

Regression Test Proposal:

  • Go to settings and create a workspace
  • Go to FAB and click on submit expense
  • Select the workspace you created
  • Enter an amount (e.g., 100) and click Next
  • Input a merchant and submit the expense
  • Create another expense with a different amount (e.g., 50)
  • Navigate to the expense details page of the first expense (e.g., 100)
  • Click on the header and select "Hold"
  • Click on the "From" link in the subtitle to return to the expense list page
  • Click the dropdown of the green pay button at the top right corner
  • Select "Pay elsewhere"
  • Click on "Pay only 50" in the confirmation pop-up
  • Verify that the app navigates to the expense lists page, which is the behavior in online mode

Do we agree 👍 or 👎

@brunovjk
Copy link
Contributor

Hey @twisterdotcom, just a heads up that the payment for this issue is still pending. When you have a moment, could you help process it so we can close this out? Appreciate it!

@twisterdotcom
Copy link
Contributor

Ahh! Yes. Sorry, I'm OOO atm but will log in this evening to process it and close. Thanks for the bump.

@twisterdotcom
Copy link
Contributor

Payment Summary:

@bernhardoj
Copy link
Contributor

Requested in ND.

@JmillsExpensify
Copy link

$250 approved for @bernhardoj

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. External Added to denote the issue can be worked on by a contributor Reviewing Has a PR in review Weekly KSv2
Projects
None yet
Development

No branches or pull requests

6 participants