Repository navigation
[HOLD for payment 2024-06-06] [$250] Distance is not optimistically updated #41817
Description
Activity
- addedDailyKSv2KSv2BugSomething is broken. Auto assigns a BugZero manager.Something is broken. Auto assigns a BugZero manager.
on 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.- addedExternalAdded to denote the issue can be worked on by a contributorAdded to denote the issue can be worked on by a contributor
on May 8, 2024 - changed the title
[-] Distance is not optimistically updated[/-][+][$250] Distance is not optimistically updated[/+]on May 8, 2024 Job added to Upwork: https://www.upwork.com/jobs/~01e08c348144daf8d9
- addedHelp WantedApply this label when an issue is open to proposals by contributorsApply this label when an issue is open to proposals by contributors
on May 8, 2024 Triggered auto assignment to Contributor-plus team member for initial proposal review - @akinwale (
External)cc @neil-marcellini and @paultsimura since you were involved in the slack chat - https://expensify.slack.com/archives/C049HHMV9SM/p1713898800427079
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
amountto default amount in optimistic data if the waypoints is changed.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
MoneyRequestConfirmationListhere- Accept
routesparams inupdateMoneyRequestDistancefunction and add it to transactionChanges here
const transactionChanges: TransactionChanges = { waypoints, routes };Lines 2861 to 2862 in 55c56bf
const transactionChanges: TransactionChanges = { waypoints,
2. PassroutesandpolicyintoIOU.updateMoneyRequestDistancefunction hereconst 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}); - 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'), };Line 2319 in 55c56bf
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
Reacted by Neil Marcellini- Accept
28 remaining items
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:
@akinwale do we need a regression test for this?
Payouts due:
- Contributor: $250 @nkdengineer (Paid in upwork - https://www.upwork.com/nx/wm/workroom/37320027/overview)
- Contributor+: $250 @akinwale (Paid in upwork - https://www.upwork.com/ab/applicants/1788075386637766656/offers)
Upwork job is here.
@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.
Reacted by Christina Dobrzynskihi @akinwale can you provide the regression test for this? Thank you!
- [@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
- Launch the Expensify app
- Create a new distance request
- Navigate to the newly created distance request
- Change the distance by modifying any of the way points to new locations, or by adding additional waypoints
- Verify that the amount is updated immediately
Do we agree 👍 or 👎?
@Christinadobrzyn Done!
Reacted by Christina DobrzynskiThanks @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!
- moved this from Polish to Done in [#whatsnext] #wave-collect
on Jun 10, 2024
Metadata
Metadata
Labels
Type
Projects
- StatusShow more project fieldsDone
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:
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?
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