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-06-06] [$250] Distance is not optimistically updated #41817

Closed
1 of 6 tasks
m-natarajan opened this issue May 7, 2024 · 28 comments
Closed
1 of 6 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 May 7, 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: 1.4.71-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: @neil-marcellini
Slack conversation: https://expensify.slack.com/archives/C049HHMV9SM/p1713898800427079

Action Performed:

  1. Go to an existing distance request
  2. Click the distance field
  3. Edit the waypoints and click save

Expected Result:

The distance optimistically updates to the correct new value.

Actual Result:

The distance does not optimistically update to the correct new value while online. It updates to a big value, then showing "pending" and then updates.

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

Recording.9.mp4
Screen.Recording.2024-04-23.at.11.56.01.AM.mov

View all open jobs on GitHub

Upwork Automation - Do Not Edit
  • Upwork Job URL: https://www.upwork.com/jobs/~01e08c348144daf8d9
  • Upwork Job ID: 1788075386637766656
  • Last Price Increase: 2024-05-15
  • Automatic offers:
    • nkdengineer | Contributor | 0
@m-natarajan m-natarajan added Daily KSv2 Bug Something is broken. Auto assigns a BugZero manager. labels May 7, 2024
Copy link

melvin-bot bot commented May 7, 2024

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

@Christinadobrzyn Christinadobrzyn added the External Added to denote the issue can be worked on by a contributor label May 8, 2024
@melvin-bot melvin-bot bot changed the title Distance is not optimistically updated [$250] Distance is not optimistically updated May 8, 2024
Copy link

melvin-bot bot commented May 8, 2024

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

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

melvin-bot bot commented May 8, 2024

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

@Christinadobrzyn
Copy link
Contributor

cc @neil-marcellini and @paultsimura since you were involved in the slack chat - https://expensify.slack.com/archives/C049HHMV9SM/p1713898800427079

@nkdengineer
Copy link
Contributor

Proposal

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

The distance does not optimistically update to the correct new value while online. It updates to a big value, then showing "pending" and then updates.

What is the root cause of that problem?

We always set amount to default amount in optimistic data if the waypoints is changed.

App/src/libs/actions/IOU.ts

Lines 2322 to 2323 in 55c56bf

amount: CONST.IOU.DEFAULT_AMOUNT,
modifiedAmount: CONST.IOU.DEFAULT_AMOUNT,

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

We should check if the route is also updated, we will calculate the amount and update it in optimistic data. The way to calculate the same as we do in MoneyRequestConfirmationList here

  1. Accept routes params in updateMoneyRequestDistance function and add it to transactionChanges here
const transactionChanges: TransactionChanges = {
    waypoints,
    routes
};

App/src/libs/actions/IOU.ts

Lines 2861 to 2862 in 55c56bf

const transactionChanges: TransactionChanges = {
waypoints,

2. Pass routes and policy into IOU.updateMoneyRequestDistance function here

const isRouteChanged = !isEqual(transactionBackup?.routes, transaction?.routes)
if (isEqual(oldAddresses, addresses) && isRouteChanged) {
    Navigation.dismissModal();
    return;
}
IOU.updateMoneyRequestDistance({transactionID: transaction?.transactionID ?? '', transactionThreadReportID: report?.reportID ?? '', waypoints, ...(isRouteChanged ? {routes: transaction?.routes} : {}), policy});

IOU.updateMoneyRequestDistance({transactionID: transaction?.transactionID ?? '', transactionThreadReportID: report?.reportID ?? '', waypoints});

  1. If the routes exist in transactionChanges, we will calculate the amount otherwise set it as default
let updateAmount: number = CONST.IOU.DEFAULT_AMOUNT;
if (transactionChanges?.routes) {
    const customUnitRateID = TransactionUtils.getRateID(transaction) ?? '';
    const mileageRates = DistanceRequestUtils.getMileageRates(policy);
    const mileageRate = mileageRates?.[customUnitRateID];
    const {unit, rate} = mileageRate;
    const distance = TransactionUtils.getDistance(transaction);
    updateAmount = -DistanceRequestUtils.getDistanceRequestAmount(distance, unit, rate ?? 0);
}

updatedTransaction = {
    ...updatedTransaction,
    amount: updateAmount,
    modifiedAmount: updateAmount,
    modifiedMerchant: Localize.translateLocal('iou.fieldPending'),
};

if (transaction && updatedTransaction && hasPendingWaypoints) {

Do the same for getUpdateTrackExpenseParams.

OPTIONAL: We can create a util to update the amount when the waypoint is changed and use it in these functions

What alternative solutions did you explore? (Optional)

NA

Result

Screen.Recording.2024-05-08.at.12.28.02.mov

@neil-marcellini neil-marcellini self-assigned this May 8, 2024
@Christinadobrzyn
Copy link
Contributor

@akinwale can you check out the ^ proposal and review this convo with more context? Thank you!

@Christinadobrzyn
Copy link
Contributor

cc @paultsimura since you were in the Slack convo, just in case you have some input here.

@melvin-bot melvin-bot bot added the Overdue label May 13, 2024
Copy link

melvin-bot bot commented May 13, 2024

@akinwale, @neil-marcellini, @Christinadobrzyn Eep! 4 days overdue now. Issues have feelings too...

@neil-marcellini
Copy link
Contributor

Bump @akinwale please review

@melvin-bot melvin-bot bot removed the Overdue label May 13, 2024
@akinwale
Copy link
Contributor

@nkdengineer's proposal works here.

🎀👀🎀 C+ reviewed.

Copy link

melvin-bot bot commented May 14, 2024

Current assignee @neil-marcellini is eligible for the choreEngineerContributorManagement assigner, not assigning anyone new.

Copy link

melvin-bot bot commented May 15, 2024

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

@neil-marcellini
Copy link
Contributor

@nkdengineer's proposal works here.

🎀👀🎀 C+ reviewed.

I agree! Hired. I like the idea of using util functions to avoid repetition and simplify.

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

melvin-bot bot commented May 16, 2024

❌ There was an error making the offer to @akinwale for the Reviewer role. The BZ member will need to manually hire the contributor.

Copy link

melvin-bot bot commented May 16, 2024

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

@melvin-bot melvin-bot bot added Reviewing Has a PR in review and removed Daily KSv2 labels May 17, 2024
@melvin-bot melvin-bot bot added the Weekly KSv2 label May 17, 2024
@nkdengineer
Copy link
Contributor

@akinwale The PR is here.

@Christinadobrzyn
Copy link
Contributor

reviewing PR - #42337

@Christinadobrzyn
Copy link
Contributor

monitoring - #42337

Copy link

melvin-bot bot commented May 29, 2024

⚠️ Looks like this issue was linked to a Deploy Blocker here

If you are the assigned CME please investigate whether the linked PR caused a regression and leave a comment with the results.

If a regression has occurred and you are the assigned CM follow the instructions here.

If this regression could have been avoided please consider also proposing a recommendation to the PR checklist so that we can avoid it in the future.

@melvin-bot melvin-bot bot added Weekly KSv2 Awaiting Payment Auto-added when associated PR is deployed to production and removed Weekly KSv2 labels May 30, 2024
@melvin-bot melvin-bot bot changed the title [$250] Distance is not optimistically updated [HOLD for payment 2024-06-06] [$250] Distance is not optimistically updated May 30, 2024
@melvin-bot melvin-bot bot removed the Reviewing Has a PR in review label May 30, 2024
Copy link

melvin-bot bot commented May 30, 2024

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

Copy link

melvin-bot bot commented May 30, 2024

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

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

Copy link

melvin-bot bot commented May 30, 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:

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

@Christinadobrzyn
Copy link
Contributor

Christinadobrzyn commented Jun 5, 2024

@akinwale do we need a regression test for this?

Payouts due:

Upwork job is here.

@Christinadobrzyn Christinadobrzyn added Daily KSv2 and removed Weekly KSv2 labels Jun 5, 2024
@akinwale
Copy link
Contributor

akinwale commented Jun 5, 2024

@akinwale do we need a regression test for this?

@Christinadobrzyn Yes, we do.

Also, please note that there was a regression from the PR, so there should be a penalty of 50% of the due payment applied.

@melvin-bot melvin-bot bot added Daily KSv2 and removed Daily KSv2 labels Jun 6, 2024
@Christinadobrzyn
Copy link
Contributor

hi @akinwale can you provide the regression test for this? Thank you!

@akinwale
Copy link
Contributor

akinwale commented Jun 7, 2024

  • [@akinwale] The PR that introduced the bug has been identified. Link to the PR:
  • [@akinwale] 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:
  • [@akinwale] 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:

Not a regression.

  • [@akinwale] Determine if we should create a regression test for this bug.
  • [@akinwale] 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.

Regression Test Steps

  1. Launch the Expensify app
  2. Create a new distance request
  3. Navigate to the newly created distance request
  4. Change the distance by modifying any of the way points to new locations, or by adding additional waypoints
  5. Verify that the amount is updated immediately

Do we agree 👍 or 👎?

@akinwale
Copy link
Contributor

akinwale commented Jun 7, 2024

@Christinadobrzyn Done!

@melvin-bot melvin-bot bot added the Overdue label Jun 10, 2024
@Christinadobrzyn
Copy link
Contributor

Thanks @akinwale - regression test here - https://github.com/Expensify/Expensify/issues/403299

Paying out based on this payment summary - #41817 (comment)

Closing this out! let me know if I missed anything!

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
Archived in project
Development

No branches or pull requests

5 participants