Open izarutskaya opened 1 month ago
Triggered auto assignment to @alexpensify (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.
Triggered auto assignment to @francoisl (DeployBlockerCash
), see https://stackoverflowteams.com/c/expensify/questions/9980/ for more details.
:wave: Friendly reminder that deploy blockers are time-sensitive ⏱ issues! Check out the open `StagingDeployCash` deploy checklist to see the list of PRs included in this release, then work quickly to do one of the following:
Job added to Upwork: https://www.upwork.com/jobs/~021835712136231108969
Triggered auto assignment to Contributor-plus team member for initial proposal review - @s77rt (External
)
This is very minor and edge case flow with no real burden to the user, demoting
Upwork job price has been updated to $50
$50 for finding the offending PR
Offending PR seems to be https://github.com/Expensify/App/issues/47136
cc @paultsimura Can you check this one please
Managed to reproduce. I'll take a look in the morning. cc: @neil-marcellini
@neil-marcellini this is one of those edge cases that I wanted to fix holistically:
calculateAmountForUpdatedWaypointOrRate
into 2 separate functions as the logic here is gradually growing apart with every new specific test case:
calculateModifiedFieldsForUpdatedWaypoints
calculateModifiedFieldsForUpdatedDistanceRate
unit
& rate
– possibly hold for https://github.com/Expensify/App/issues/43588 to know what way we are going: updating the BE model or parsing the merchant.@s77rt do you agree with this plan? Thanks!
@neil-marcellini is working on https://github.com/Expensify/App/issues/43588 and this one is not a priority, holding makes sense to me
Thanks for the update. I've moved this to hold, and we can revisit it after #43588 is in production.
Weekly Update: On hold for https://github.com/Expensify/App/issues/43588
@s77rt - the update is live in NewExpensify, but one is pending for Old. Should we continue to wait or move forward here? Thanks!
@alexpensify We still need to wait for the frontend changes (https://github.com/Expensify/App/pull/50001)
Weekly Update: Updated on hold for https://github.com/Expensify/App/pull/50001
@s77rt the changes in https://github.com/Expensify/App/pull/50001 went to production yesterday. Can we move forward now?
@alexpensify Let's remove the hold. We now have two bugs:
https://github.com/user-attachments/assets/86a458b0-e77b-4283-8c34-f453a15bb2ab
https://github.com/user-attachments/assets/08d8bf26-6d2d-4c44-b61f-68c9a309b73c
@paultsimura I don't think we need to split calculateAmountForUpdatedWaypointOrRate
into two. The bug is that hasModifiedRateWithPendingWaypoints
returns false
because the updatedTransaction
overwrites the existing pendingFields
.
Simply adding ...updatedTransaction.pendingFields
won't work because after https://github.com/Expensify/App/pull/50001 we added these two lines https://github.com/Expensify/App/blob/be80f3d54bd1f36dd244da680de8140bd31d7de2/src/libs/actions/IOU.ts#L2735 and https://github.com/Expensify/App/blob/be80f3d54bd1f36dd244da680de8140bd31d7de2/src/libs/actions/IOU.ts#L2950
and we don't want to clear pending fields that are set in ACTION1 by ACTION2.
cc @neil-marcellini (for context)
I think we need to revert the above two lines and handle the problem that we were trying to resolve in a different way, the problem was that if you change the rate to a rate that uses a different unit we also need to change the waypoints (the distance) https://github.com/Expensify/App/blob/f0ec762fc6514b4e2627cbad519e6f40a1e6fd97/src/libs/TransactionUtils/index.ts#L286-L292
Now we basically need to move the above logic and add waypoints
to transactionChanges
I don't think we need to split calculateAmountForUpdatedWaypointOrRate into two... and we don't want to clear pending fields that are set in ACTION1 by ACTION2.
I can't entirely agree with this approach, let's take a look at the following scenario:
MODIFIEDEXPENSE
action for each atomic change: first, the distance was changed, then – the rate.There might be some other side effects, but this is the first one that comes to my mind, and splitting calculateAmountForUpdatedWaypointOrRate
into 2 seems to work fine with it.
I'll play with the code and add a proposal a bit later.
Edited by proposal-police: This proposal was edited at 2024-10-31 08:56:33 UTC.
There are 2 bugs as described by @s77rt here.
If we simply swap the waypoints the distance does not change to "Pending" but it should because the roadmap can still change
The report header still changes and shows "0.00 for Pending" if we go offline, add a new waypoint, and change the rate
For bug 1, we do not reset the customUnit.quantity
here:
Therefore, the hasRoute
returns true
:
And the MoneyRequestView
doesn't show Pending...
because of that:
For bug 2, we are trying to handle both distance & rate changes in 1 function – TransactionUtils.calculateAmountForUpdatedWaypointOrRate
– which is too generic and doesn't handle the consecutive change correctly.
For bug 1, we should reset the quantity:
comment: {
waypoints,
customUnit: {
quantity: null,
},
},
We already do it when saving or removing a waypoint:
For bug 2, move the TransactionUtils.calculateAmountForUpdatedWaypointOrRate
into 2 different places inside the TransactionUtils.getUpdatedTransaction
:
And remove these calls:
Also, refine other places where we can move distance-related transaction modifications from outside the TransactionUtils.getUpdatedTransaction
inside it, e.g.:
This way, we have more refined control over what data is changed when changing either distance or rate, also have more centralised logic for modifying the transaction, and it allows keeping the updatedTransaction
constant inside functions like getUpdateMoneyRequestParams
.
Updated approach with pendingWaypoints:
Add ...updatedTransaction.pendingFields
here:
Remove setting the pending field here:
Instead, add waypoints
to transactionChanges
in IOU.updateMoneyRequestDistanceRate
by adding this chunk of code:
const transaction = allTransactions?.[`${ONYXKEYS.COLLECTION.TRANSACTION}${transactionID}`];
if (transaction) {
const existingDistanceUnit = transaction?.comment?.customUnit?.distanceUnit;
lodashSet(transaction, 'comment.customUnit.customUnitRateID', transactionChanges.customUnitRateID);
lodashSet(transaction, 'comment.customUnit.defaultP2PRate', null);
const newDistanceUnit = DistanceRequestUtils.getUpdatedDistanceUnit({transaction, policy});
if (existingDistanceUnit && newDistanceUnit !== existingDistanceUnit) {
transactionChanges.waypoints = TransactionUtils.getWaypoints(transaction);
}
}
Revert the clearedPendingFields to pre- https://github.com/Expensify/App/pull/50001 state in getUpdateTrackExpenseParams
and getUpdateMoneyRequestParams
.
@paultsimura Thanks for the proposal.
Regarding the first bug, the RCA and the solution look good to me. Regarding the second bug, I don't think handling both fields in one function is the problem but I see what you are referring to, here is what I think we should do:
calculateAmountForUpdatedWaypointOrRate
logic into getUpdatedTransaction
so the updatedTransaction
becomes a constant. In the getUpdatedTransaction
there is the if-blocks where you can have the logic done depending on what field we are actually changinggetUpdatedTransaction
. This will ensure a single source of truthgetUpdatedTransaction
because it's still returning wrong pendingFields (even though this is not necessary to fix our bug here it's still something we should do)Let me know if that makes sense
One possible drawback of this is that we use calculateAmountForUpdatedWaypointOrRate
also when building the optimistic modifiedexpense
action. If we move this logic inside getUpdatedTransaction
, it won't be reusable🤔
@paultsimura We don't necessary have to remove that function, just use it in getUpdatedTransaction
.
Not overdue. Still looking for proposals
Same ^
I think we should be able to get proposals now. I updated the title.
@s77rt I've updated my proposal using your suggestions. Tried a rough version of it locally – this approach also solves the issue 👍
@paultsimura Overall looks good to me but can we fix getUpdatedTransaction
as well? (to return the correct pendingFields
)
@s77rt I'm not sure I understand the issue with the pending fields here. Could you please clarify a little?
Moreover, I'm kinda confused by this line:
Doesn't it get always overwritten by this final chunk?
Right, that's another reason that we need to add ...updatedTransaction.pendingFields,
📣 It's been a week! Do we have any satisfactory proposals yet? Do we need to adjust the bounty for this issue? 💸
Still working on the proposals
Same ^
@s77rt changing the way we work with pending fields is quite a fundamental change that will need a lot of extra testing for the stacked offline operations. Therefore, if it's not critical for this issue, I would like to avoid it here. However, if you insist – feel free to post this GH in Slack to get more 👀
@paultsimura We are not changing how we work with pending fields. Why do you think that's the case here?
You're right, I was mistaken here. I've updated the proposal – added the Updated approach with pendingWaypoints: section.
@paultsimura Thank you! Looks good to me but can you check if the linter complains about mutating transactionChanges
?
if the linter complains about mutating
transactionChanges
?
No, he's ok with it
@paultsimura Got it! Let's handle this in the PR.
🎀 👀 🎀 C+ reviewed Link to proposal
Current assignee @francoisl is eligible for the choreEngineerContributorManagement assigner, not assigning anyone new.
📣 @paultsimura 🎉 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 📖
Note to self: there were some changes to the existing logic in https://github.com/Expensify/App/issues/51285, need to make sure it doesn't break after this GH.
Issue not reproducible during KI retests. (First week)
The PR is ready for review: https://github.com/Expensify/App/pull/52197
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.35-4 Reproducible in staging?: Y Reproducible in production?: N If this was caught during regression testing, add the test name, ID and link from TestRail: https://expensify.testrail.io/index.php?/tests/view/4966766 Email or phone of affected tester (no customers): applausetester+kh010901@applause.expensifail.com Logs: https://stackoverflow.com/c/expensify/questions/4856 Issue reported by: Applause-Internal team
Action Performed:
Precondition:
Expected Result:
Report header will display "Pending" after changing distance and rate offline (production behavior).
Actual Result:
Report header displays "0.00 for Pending... @1.00 / mi" after changing distance and rate offline.
Workaround:
Unknown
Platforms:
Which of our officially supported platforms is this issue occurring on?
Screenshots/Videos
https://github.com/user-attachments/assets/c5aff1a5-907a-4142-95cf-eaba49917a8d
View all open jobs on GitHub
Upwork Automation - Do Not Edit