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

Distance - Preview amount after edit distance not update, incorrect report calculations #35178

Closed
5 of 6 tasks
lanitochka17 opened this issue Jan 25, 2024 · 16 comments
Closed
5 of 6 tasks
Assignees

Comments

@lanitochka17
Copy link

lanitochka17 commented Jan 25, 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: 1.4.32-2
Reproducible in staging?: Y
Reproducible in production?: N
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: Applause- Internal Team
Slack conversation:

Issue found when executing PR #34107

Action Performed:

Prerequisite: Free workspace exists for user

  1. Log in to New Expensify
  2. Navigate to workspace chat
  3. Create Distance request
  4. Edit the distance
  5. Navigate back to the workspace chat and verify request preview
  6. Click on request preview and verify total, out of pocket and company spend amounts

Expected Result:

Request preview should display updated request amount, and request report should show correct calculations

Actual Result:

Request amount does not update in the original workspace chat
Total in report is not updated, and can lead to negative company spend values if new distance is greater than the original
Pay XXX with Expensify button value is not updated

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

Bug6355033_1706210343376.2024-01-25_19-06-54.mp4

View all open jobs on GitHub

@lanitochka17 lanitochka17 added the DeployBlockerCash This issue or pull request should block deployment label Jan 25, 2024
Copy link

melvin-bot bot commented Jan 25, 2024

Triggered auto assignment to @amyevans (DeployBlockerCash), see https://stackoverflowteams.com/c/expensify/questions/9980/ for more details.

Copy link
Contributor

👋 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:

  1. Identify the pull request that introduced this issue and revert it.
  2. Find someone who can quickly fix the issue.
  3. Fix the issue yourself.

@lanitochka17
Copy link
Author

We think that this bug might be related to #wave5.
CC @dylanexpensify

@amyevans
Copy link
Contributor

I think an additional condition that's necessary to reproduce this is: have at least one other request on the report, which is set as non-reimbursable. Does that seem right @lanitochka17? And do you have a recording of it from production?

Also cc @aldo-expensify in case you have any additional context on the bug since this was discovered while QAing #34107.

@aldo-expensify
Copy link
Contributor

I couldn't reproduce in production, and I was able to reproduce in staging.
I didn't need to create any other request besides the distance request being edited. I used a free workspace in an expensifail account to test.

@aldo-expensify
Copy link
Contributor

I'm guessing that the backend is not pushing the updates for the report, I'll check

@aldo-expensify
Copy link
Contributor

aldo-expensify commented Jan 26, 2024

Onyx updates in production coming in `response`
[
    {
        "onyxMethod": "merge",
        "key": "transactions_6665153331617603740",
        "value": {
            "amount": -12,
            "billable": false,
            "cardID": 0,
            "category": "Car",
            "comment": {
                "comment": "",
                "customUnit": {
                    "attributes": [],
                    "customUnitID": "23F5CDD250EB4",
                    "customUnitRateID": "6443B06178838",
                    "name": "Distance",
                    "quantity": 1.45,
                    "subRates": []
                },
                "type": "customUnit",
                "waypoints": {
                    "waypoint0": {
                        "address": "3300 Heather Street, Vancouver, BC, Canada",
                        "lat": 49.25610529999999,
                        "lng": -123.1201544,
                        "name": "3300 Heather St"
                    },
                    "waypoint1": {
                        "address": "5000 Heather Street, Vancouver, BC, Canada",
                        "lat": 49.2404922,
                        "lng": -123.1199583,
                        "name": "5000 Heather St"
                    }
                }
            },
            "created": "2024-01-25",
            "currency": "CAD",
            "filename": "w_a85b979868dc1a2d5444a682c3dd7f202e74adef.png",
            "merchant": "0.18 mi @ C$0.67 / mi",
            "modifiedAmount": -97,
            "modifiedCreated": "2024-01-25",
            "modifiedCurrency": "CAD",
            "modifiedMerchant": "1.45 mi @ C$0.67 / mi",
            "originalAmount": 0,
            "originalCurrency": "",
            "parentTransactionID": "",
            "receipt": {
                "receiptID": 689208855,
                "state": "OPEN",
                "source": "https://www.expensify.com/receipts/w_a85b979868dc1a2d5444a682c3dd7f202e74adef.png"
            },
            "reimbursable": true,
            "reportID": "3837832816596176",
            "status": "Posted",
            "tag": "",
            "transactionID": "6665153331617603740",
            "hasEReceipt": false
        }
    },
    {
        "onyxMethod": "merge",
        "key": "report_3815997082592743",
        "value": {
            "reportID": "3815997082592743",
            "maxSequenceNumber": 3,
            "lastVisibleActionCreated": "2024-01-26 00:38:43.438",
            "lastReadTime": "2024-01-26 00:38:43.439",
            "lastMentionedTime": null,
            "lastMessageText": "You",
            "lastActorAccountID": 16309584
        }
    },
    {
        "onyxMethod": "merge",
        "key": "reportActions_3815997082592743",
        "value": {
            "6650447322382397561": {
                "person": [
                    {
                        "type": "TEXT",
                        "style": "strong",
                        "text": "[email protected]"
                    }
                ],
                "actorAccountID": 16309584,
                "message": [
                    {
                        "type": "TEXT",
                        "style": "strong",
                        "text": "You"
                    },
                    {
                        "type": "TEXT",
                        "style": "normal",
                        "text": " modified expense '0.43 mi @ C$0.67 / mi'. "
                    },
                    {
                        "type": "TEXT",
                        "style": "normal",
                        "text": "New merchant is '1.45 mi @ C$0.67 / mi' (previously '0.43 mi @ C$0.67 / mi'). "
                    },
                    {
                        "type": "TEXT",
                        "style": "normal",
                        "text": "New amount is 'C$0.97' (previously 'C$0.29'). "
                    }
                ],
                "originalMessage": {
                    "amount": 97,
                    "currency": "CAD",
                    "lastModified": "2024-01-26 00:38:43.438",
                    "merchant": "1.45 mi @ C$0.67 / mi",
                    "oldAmount": 29,
                    "oldCurrency": "CAD",
                    "oldMerchant": "0.43 mi @ C$0.67 / mi"
                },
                "avatar": "https://d2k5nsl2zxldvw.cloudfront.net/images/avatars/default-avatar_7.png",
                "created": "2024-01-26 00:38:43.438",
                "timestamp": 1706229523,
                "reportActionTimestamp": 1706229523438,
                "automatic": false,
                "actionName": "MODIFIEDEXPENSE",
                "shouldShow": true,
                "reportActionID": "6650447322382397561",
                "previousReportActionID": "70323599490171598",
                "lastModified": "2024-01-26 00:38:43.438",
                "actorEmail": "[email protected]",
                "whisperedToAccountIDs": [],
                "sequenceNumber": 3,
                "isAttachment": false
            }
        },
        "shouldNotify": true
    },
    {
        "onyxMethod": "merge",
        "key": "report_3837832816596176",
        "value": {
            "reportID": "3837832816596176",
            "reportName": "Expense Report #3837832816596176",
            "type": "expense",
            "chatType": "",
            "ownerAccountID": 16309584,
            "managerID": 16309584,
            "policyID": "34CC91B2A58E34A7",
            "participantAccountIDs": [],
            "visibleChatMemberAccountIDs": [],
            "isPinned": false,
            "lastReadTime": "2024-01-26 00:34:10.646",
            "lastMentionedTime": null,
            "lastReadSequenceNumber": 0,
            "lastVisibleActionCreated": "2024-01-26 00:34:10.646",
            "lastVisibleActionLastModified": "2024-01-26 00:34:10.646",
            "lastMessageText": "CA$0.12 request for 0.18 miles",
            "lastActorAccountID": 16309584,
            "notificationPreference": "hidden",
            "welcomeMessage": "",
            "stateNum": 1,
            "statusNum": 1,
            "oldPolicyName": "",
            "visibility": null,
            "isOwnPolicyExpenseChat": false,
            "lastMessageHtml": "CA$0.12 request for 0.18 miles",
            "iouReportID": null,
            "hasOutstandingChildRequest": false,
            "policyName": null,
            "hasParentAccess": true,
            "parentReportID": "5329212264991405",
            "parentReportActionID": "4336444692735853023",
            "writeCapability": "all",
            "description": "",
            "isDeletedParentAction": null,
            "reportFields": null,
            "total": -97,
            "currency": "CAD",
            "submitterPayPalMeAddress": "",
            "chatReportID": "5329212264991405",
            "isWaitingOnBankAccount": false,
            "nonReimbursableTotal": 0,
            "isCancelledIOU": false
        }
    }
]
Onyx updates coming in response in `staging`
[
    {
        "onyxMethod": "merge",
        "key": "transactions_6665153331617603740",
        "value": {
            "amount": -12,
            "billable": false,
            "cardID": 0,
            "category": "Car",
            "comment": {
                "comment": "",
                "customUnit": {
                    "attributes": [],
                    "customUnitID": "23F5CDD250EB4",
                    "customUnitRateID": "6443B06178838",
                    "name": "Distance",
                    "quantity": 0.88,
                    "subRates": []
                },
                "type": "customUnit",
                "waypoints": {
                    "waypoint0": {
                        "address": "3300 Heather Street, Vancouver, BC, Canada",
                        "lat": 49.25610529999999,
                        "lng": -123.1201544,
                        "name": "3300 Heather St"
                    },
                    "waypoint1": {
                        "address": "2000 Heather Street, Vancouver, BC, Canada",
                        "lat": 49.2656839,
                        "lng": -123.1197975,
                        "name": "2000 Heather St"
                    }
                }
            },
            "created": "2024-01-25",
            "currency": "CAD",
            "filename": "w_7a7ab41ed50a09bfca3e95c558f93d7d474d06a4.png",
            "merchant": "0.18 mi @ C$0.67 / mi",
            "modifiedAmount": -59,
            "modifiedCreated": "2024-01-25",
            "modifiedCurrency": "CAD",
            "modifiedMerchant": "0.88 mi @ C$0.67 / mi",
            "originalAmount": 0,
            "originalCurrency": "",
            "parentTransactionID": "",
            "receipt": {
                "receiptID": 689208855,
                "state": "OPEN",
                "source": "https://staging.expensify.com/receipts/w_7a7ab41ed50a09bfca3e95c558f93d7d474d06a4.png"
            },
            "reimbursable": true,
            "reportID": "3837832816596176",
            "status": "Posted",
            "tag": "",
            "transactionID": "6665153331617603740",
            "hasEReceipt": false
        }
    },
    {
        "onyxMethod": "merge",
        "key": "report_3815997082592743",
        "value": {
            "reportID": "3815997082592743",
            "maxSequenceNumber": 4,
            "lastVisibleActionCreated": "2024-01-26 00:39:35.211",
            "lastReadTime": "2024-01-26 00:38:43.439",
            "lastMentionedTime": null,
            "lastMessageText": "You",
            "lastActorAccountID": 16309584
        }
    },
    {
        "onyxMethod": "merge",
        "key": "reportActions_3815997082592743",
        "value": {
            "324025560165939807": {
                "person": [
                    {
                        "type": "TEXT",
                        "style": "strong",
                        "text": "[email protected]"
                    }
                ],
                "actorAccountID": 16309584,
                "message": [
                    {
                        "type": "TEXT",
                        "style": "strong",
                        "text": "You"
                    },
                    {
                        "type": "TEXT",
                        "style": "normal",
                        "text": " modified expense '1.45 mi @ C$0.67 / mi'. "
                    },
                    {
                        "type": "TEXT",
                        "style": "normal",
                        "text": "New merchant is '0.88 mi @ C$0.67 / mi' (previously '1.45 mi @ C$0.67 / mi'). "
                    },
                    {
                        "type": "TEXT",
                        "style": "normal",
                        "text": "New amount is 'C$0.59' (previously 'C$0.97'). "
                    }
                ],
                "originalMessage": {
                    "amount": 59,
                    "currency": "CAD",
                    "lastModified": "2024-01-26 00:39:35.211",
                    "merchant": "0.88 mi @ C$0.67 / mi",
                    "oldAmount": 97,
                    "oldCurrency": "CAD",
                    "oldMerchant": "1.45 mi @ C$0.67 / mi"
                },
                "avatar": "https://d2k5nsl2zxldvw.cloudfront.net/images/avatars/default-avatar_7.png",
                "created": "2024-01-26 00:39:35.211",
                "timestamp": 1706229575,
                "reportActionTimestamp": 1706229575211,
                "automatic": false,
                "actionName": "MODIFIEDEXPENSE",
                "shouldShow": true,
                "reportActionID": "324025560165939807",
                "previousReportActionID": "6650447322382397561",
                "lastModified": "2024-01-26 00:39:35.211",
                "actorEmail": "[email protected]",
                "whisperedToAccountIDs": [],
                "sequenceNumber": 4,
                "isAttachment": false
            }
        },
        "shouldNotify": true
    },
    {
        "onyxMethod": "merge",
        "key": "report_3837832816596176",
        "value": {
            "reportID": "3837832816596176",
            "reportName": "Expense Report #3837832816596176",
            "type": "expense",
            "chatType": "",
            "ownerAccountID": 16309584,
            "managerID": 16309584,
            "policyID": "34CC91B2A58E34A7",
            "participantAccountIDs": [],
            "visibleChatMemberAccountIDs": [],
            "isPinned": false,
            "lastReadTime": "2024-01-26 00:34:10.646",
            "lastMentionedTime": null,
            "lastReadSequenceNumber": 0,
            "lastVisibleActionCreated": "2024-01-26 00:34:10.646",
            "lastVisibleActionLastModified": "2024-01-26 00:34:10.646",
            "lastMessageText": "CA$0.12 request for 0.18 miles",
            "lastActorAccountID": 16309584,
            "notificationPreference": "hidden",
            "welcomeMessage": "",
            "stateNum": 1,
            "statusNum": 1,
            "oldPolicyName": "",
            "visibility": null,
            "isOwnPolicyExpenseChat": false,
            "lastMessageHtml": "CA$0.12 request for 0.18 miles",
            "iouReportID": null,
            "hasOutstandingChildRequest": false,
            "policyName": null,
            "hasParentAccess": true,
            "parentReportID": "5329212264991405",
            "parentReportActionID": "4336444692735853023",
            "writeCapability": "all",
            "description": "",
            "isDeletedParentAction": null,
            "reportFields": null,
            "total": -97,
            "currency": "CAD",
            "submitterPayPalMeAddress": "",
            "chatReportID": "5329212264991405",
            "isWaitingOnBankAccount": false,
            "nonReimbursableTotal": -38,
            "isCancelledIOU": false
        }
    }
]

The problem I see is that staging is returning "nonReimbursableTotal": -38, while in production we get "nonReimbursableTotal": 0,

@aldo-expensify
Copy link
Contributor

I think the bug is that the command UpdateMoneyRequestDistance doesn't refresh the cached report total (report.total) and then this calculation in Auth gets the incorrect non-reimbursable amount here: https://github.com/Expensify/Auth/blob/5a6d859b28cdf7d89e42f69d0f2c575ae11ca8d2/auth/lib/Report.cpp#L5552

Maybe the second part about non-reimbursable doesn't matter and it is just the total that should be refreshed

@aldo-expensify
Copy link
Contributor

aldo-expensify commented Jan 26, 2024

@amyevans should we revert the App PR so we keep using the old end point and re-revert once the problem is fixed in Auth?

@aldo-expensify
Copy link
Contributor

I guess it depends on if we are planning to deploy App today

@aldo-expensify
Copy link
Contributor

Created PR to fix this: https://github.com/Expensify/Auth/pull/9745

Copy link

melvin-bot bot commented Jan 26, 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.

@thienlnam
Copy link
Contributor

The Auth PR is merged, but this issue will still be occurring until Auth deploy happens - so leaving the blocker label on

@amyevans
Copy link
Contributor

👍 Auth deploy probably won't be until Monday fwiw. I can retest to verify once deployed. Thanks for the quick PR @aldo-expensify!

@melvin-bot melvin-bot bot added the Overdue label Jan 29, 2024
@amyevans
Copy link
Contributor

Auth deployed this morning. Although now in testing, I'm just hitting #35280 so I can't reach the bug 😅. But I suppose that means we should just remove the blocker label and deploy. Do you agree @aldo-expensify?

@aldo-expensify
Copy link
Contributor

aldo-expensify commented Jan 29, 2024

Auth deployed this morning. Although now in testing, I'm just hitting #35280 so I can't reach the bug 😅. But I suppose that means we should just remove the blocker label and deploy. Do you agree @aldo-expensify?

I think you can go around that bug by refreshing the page before trying to edit the transaction (or something like that).

I was able to edit the waypoints and the total updated correctly:

Screen.Recording.2024-01-29.at.10.00.40.AM.mov

@aldo-expensify aldo-expensify removed the DeployBlockerCash This issue or pull request should block deployment label Jan 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants