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

Expense - Total amount and pay button reload each time any field other than amount is edited #57530

Open
8 tasks done
mitarachim opened this issue Feb 27, 2025 · 2 comments
Open
8 tasks done
Assignees
Labels
Bug Something is broken. Auto assigns a BugZero manager. Daily KSv2

Comments

@mitarachim
Copy link

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: 9.1.7-0
Reproducible in staging?: Yes
Reproducible in production?: Yes
If this was caught on HybridApp, is this reproducible on New Expensify Standalone?: N/A
If this was caught during regression testing, add the test name, ID and link from TestRail: Exp
Email or phone of affected tester (no customers): [email protected]
Issue reported by: Applause Internal Team
Device used: Mac 15.0 / Chrome
App Component: Money Requests

Action Performed:

Precondition:

  • Delayed submissions and Add approval are disabled
  • Workspace has no unsettled expense.
  1. Go to staging.new.expensify.com
  2. Go to workspace chat
  3. Submit a manual expense with currency that is not the default workspace currency.
  4. Go to expense report.
  5. Click any field other than Amount (description, merchant or date).
  6. Edit the amount and save it.

Expected Result:

Total amount and pay button will not reload each time any field other than amount is edited because amount is not modified.

Actual Result:

Total amount and pay button reload each time any field other than amount is edited.

Workaround:

Unknown

Platforms:

  • Android: Standalone
  • Android: HybridApp
  • Android: mWeb Chrome
  • iOS: Standalone
  • iOS: HybridApp
  • iOS: mWeb Safari
  • MacOS: Chrome / Safari
  • MacOS: Desktop

Screenshots/Videos

Bug6755962_1740644030293.20250227_161224.mp4

View all open jobs on GitHub

@mitarachim mitarachim added Bug Something is broken. Auto assigns a BugZero manager. Daily KSv2 labels Feb 27, 2025
Copy link

melvin-bot bot commented Feb 27, 2025

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

@daledah
Copy link
Contributor

daledah commented Feb 27, 2025

Proposal

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

Total amount and pay button reload each time any field other than amount is edited.

What is the root cause of that problem?

When we update the description or date, ... we will get the calculatedDiffAmount

App/src/libs/actions/IOU.ts

Lines 3486 to 3487 in 0856182

const calculatedDiffAmount = calculateDiffAmount(iouReport, updatedTransaction, transaction);
// If calculatedDiffAmount is null it means we cannot calculate the new iou report total from front-end due to currency differences.

calculatedDiffAmount is null in this case because the currency is different from iouReport's currency

if (updatedCurrency === iouReport.currency && currentCurrency === iouReport.currency) {

So isTotalIndeterministic is true

then we add pendingFields for total

value: {...updatedMoneyRequestReport, ...(isTotalIndeterministic && {pendingFields: {total: CONST.RED_BRICK_ROAD_PENDING_ACTION.UPDATE}})},

If the total is pending we'll show the loading indicator

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

We should update calculateDiffAmount function to check updatedCurrency === currentCurrency && currentAmount == updatedAmount then return 0

if (updatedCurrency === currentCurrency && currentAmount == updatedAmount){
        return 0
    }

What specific scenarios should we cover in automated tests to prevent reintroducing this issue in the future?

Write test for calculateDiffAmount to cover:

  1. Different currency
  2. Different amount
  3. Same currency
  4. Same amount

What alternative solutions did you explore? (Optional)

Reminder: Please use plain English, be brief and avoid jargon. Feel free to use images, charts or pseudo-code if necessary. Do not post large multi-line diffs or write walls of text. Do not create PRs unless you have been hired for this job.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Something is broken. Auto assigns a BugZero manager. Daily KSv2
Projects
None yet
Development

No branches or pull requests

3 participants