Skip to content

Conversation

@nyomanjyotisa
Copy link
Contributor

@nyomanjyotisa nyomanjyotisa commented Nov 9, 2025

Explanation of Change

Fixed Issues

$ #74265
PROPOSAL: #74265 (comment)

Tests

Same as QA Steps

  • Verify that no errors appear in the JS console

Offline tests

Same as QA Steps

QA Steps

Prerequisite:

  • Account has at least one workspace
  1. Open any workspace chat
  2. Create a manual expense
  3. Open the report of the just created expense
  4. Tap on "More" and select "Split"
  5. Save the amounts
  6. When redirected to report, open both splits and note that no system message is displayed on any of them
  7. Open one of the splits again -> More -> Edit Splits
  8. Remove one split and revert the remaining split to its original value
  9. Verify that no system message is generated because no changes were actually made (reverse split operation)
  • Verify that no errors appear in the JS console

PR Author Checklist

  • I linked the correct issue in the ### Fixed Issues section above
  • I wrote clear testing steps that cover the changes made in this PR
    • I added steps for local testing in the Tests section
    • I added steps for the expected offline behavior in the Offline steps section
    • I added steps for Staging and/or Production testing in the QA steps section
    • I added steps to cover failure scenarios (i.e. verify an input displays the correct error message if the entered data is not correct)
    • I turned off my network connection and tested it while offline to ensure it matches the expected behavior (i.e. verify the default avatar icon is displayed if app is offline)
    • I tested this PR with a High Traffic account against the staging or production API to ensure there are no regressions (e.g. long loading states that impact usability).
  • I included screenshots or videos for tests on all platforms
  • I ran the tests on all platforms & verified they passed on:
    • Android: Native
    • Android: mWeb Chrome
    • iOS: Native
    • iOS: mWeb Safari
    • MacOS: Chrome / Safari
    • MacOS: Desktop
  • I verified there are no console errors (if there's a console error not related to the PR, report it or open an issue for it to be fixed)
  • I verified there are no new alerts related to the canBeMissing param for useOnyx
  • I followed proper code patterns (see Reviewing the code)
    • I verified that any callback methods that were added or modified are named for what the method does and never what callback they handle (i.e. toggleReport and not onIconClick)
    • I verified that comments were added to code that is not self explanatory
    • I verified that any new or modified comments were clear, correct English, and explained "why" the code was doing something instead of only explaining "what" the code was doing.
    • I verified any copy / text shown in the product is localized by adding it to src/languages/* files and using the translation method
      • If any non-english text was added/modified, I used JaimeGPT to get English > Spanish translation. I then posted it in #expensify-open-source and it was approved by an internal Expensify engineer. Link to Slack message:
    • I verified all numbers, amounts, dates and phone numbers shown in the product are using the localization methods
    • I verified any copy / text that was added to the app is grammatically correct in English. It adheres to proper capitalization guidelines (note: only the first word of header/labels should be capitalized), and is either coming verbatim from figma or has been approved by marketing (in order to get marketing approval, ask the Bug Zero team member to add the Waiting for copy label to the issue)
    • I verified proper file naming conventions were followed for any new files or renamed files. All non-platform specific files are named after what they export and are not named "index.js". All platform-specific files are named for the platform the code supports as outlined in the README.
    • I verified the JSDocs style guidelines (in STYLE.md) were followed
  • If a new code pattern is added I verified it was agreed to be used by multiple Expensify engineers
  • I followed the guidelines as stated in the Review Guidelines
  • I tested other components that can be impacted by my changes (i.e. if the PR modifies a shared library or component like Avatar, I verified the components using Avatar are working as expected)
  • I verified all code is DRY (the PR doesn't include any logic written more than once, with the exception of tests)
  • I verified any variables that can be defined as constants (ie. in CONST.ts or at the top of the file that uses the constant) are defined as such
  • I verified that if a function's arguments changed that all usages have also been updated correctly
  • If any new file was added I verified that:
    • The file has a description of what it does and/or why is needed at the top of the file if the code is not self explanatory
  • If a new CSS style is added I verified that:
    • A similar style doesn't already exist
    • The style can't be created with an existing StyleUtils function (i.e. StyleUtils.getBackgroundAndBorderStyle(theme.componentBG))
  • If new assets were added or existing ones were modified, I verified that:
    • The assets are optimized and compressed (for SVG files, run npm run compress-svg)
    • The assets load correctly across all supported platforms.
  • If the PR modifies code that runs when editing or sending messages, I tested and verified there is no unexpected behavior for all supported markdown - URLs, single line code, code blocks, quotes, headings, bold, strikethrough, and italic.
  • If the PR modifies a generic component, I tested and verified that those changes do not break usages of that component in the rest of the App (i.e. if a shared library or component like Avatar is modified, I verified that Avatar is working as expected in all cases)
  • If the PR modifies a component related to any of the existing Storybook stories, I tested and verified all stories for that component are still working as expected.
  • If the PR modifies a component or page that can be accessed by a direct deeplink, I verified that the code functions as expected when the deeplink is used - from a logged in and logged out account.
  • If the PR modifies the UI (e.g. new buttons, new UI components, changing the padding/spacing/sizing, moving components, etc) or modifies the form input styles:
    • I verified that all the inputs inside a form are aligned with each other.
    • I added Design label and/or tagged @Expensify/design so the design team can review the changes.
  • If a new page is added, I verified it's using the ScrollView component to make it scrollable when more elements are added to the page.
  • I added unit tests for any new feature or bug fix in this PR to help automatically prevent regressions in this user flow.
  • If the main branch was merged into this PR after a review, I tested again and verified the outcome was still expected according to the Test steps.

Screenshots/Videos

Android: Native
Android-Native.mp4
Android: mWeb Chrome
Android-mWeb.Chrome.mp4
iOS: Native
iOS-Native.mp4
iOS: mWeb Safari
iOS-mWeb.Safari.mp4
MacOS: Chrome / Safari
MacOS-Chrome.mp4
MacOS: Desktop
MacOS-Desktop.mp4

@codecov
Copy link

codecov bot commented Nov 9, 2025

Codecov Report

❌ Looks like you've decreased code coverage for some files. Please write tests to increase, or at least maintain, the existing level of code coverage. See our documentation here for how to interpret this table.

Files with missing lines Coverage Δ
src/libs/actions/IOU.ts 63.77% <0.00%> (-0.85%) ⬇️
... and 109 files with indirect coverage changes

@nyomanjyotisa nyomanjyotisa marked this pull request as ready for review November 9, 2025 17:22
@nyomanjyotisa nyomanjyotisa requested review from a team as code owners November 9, 2025 17:22
@melvin-bot
Copy link

melvin-bot bot commented Nov 9, 2025

@dukenv0307 Please copy/paste the Reviewer Checklist from here into a new comment on this PR and complete it. If you have the K2 extension, you can simply click: [this button]

@melvin-bot melvin-bot bot removed request for a team November 9, 2025 17:22
@nyomanjyotisa
Copy link
Contributor Author

While working on this PR, I believe it's expected to see the changed the amount system message because the amount differs from the original before the split. In my opinion, the current behavior (before this PR) is correct. We got the changed the amount system message because we don't reset the remaining expense to its original value

New-Expensify-2.mp4

If we reverse the split and set the remaining expense back to the original amount, we'd see the changed the expense system message without the amount change message

New-Expensify-2.mp4

What do you think? @dukenv0307

@dukenv0307
Copy link
Contributor

@nyomanjyotisa I think it's the bug that we need to fix, because after resetting the cache and restart, this system message changed the expense disappears

@nyomanjyotisa
Copy link
Contributor Author

@dukenv0307 I'm not entirely sure, but we also see the same changed the expense system message when saving an unchanged date for an expense. After resetting the cache and restarting, this message disappears as well

New-Expensify-2.mp4

I wonder if we expect the changed the expense system message when there is no change applied to the expense 🤔
Should we ask for confirmation on whether this is the expected behavior?

@dukenv0307
Copy link
Contributor

If there's no amount change, we shouldn't show the changed the amount system message. That's what we're fixing in this PR.

If I split $100 into 2 expenses ($50 for each)

Case 1: Delete one split without changing the amount of the second split -> should not show the system message changed the amount because from the user's point of view, there is no change

Case 2: If we reverse the split and set the remaining expense back to the original amount -> we should show the changed the amount to $100 (previously ₫50)

@dukenv0307
Copy link
Contributor

@nyomanjyotisa If that's still unclear, you can raise the discusson on Slack and tag me. Thanks

@nyomanjyotisa
Copy link
Contributor Author

@dukenv0307 That makes sense, I understand your point. However, I think it would be helpful to get more insight on this. I'll raise a discussion on Slack, thanks for the feedback!

@dukenv0307
Copy link
Contributor

@nyomanjyotisa Can you mention the Slack link here?

@nyomanjyotisa
Copy link
Contributor Author

@dukenv0307 Sorry for the late response, here is the link to the Slack thread

@heyjennahay
Copy link
Contributor

Getting some extra opinions for the Slack thread

@dukenv0307
Copy link
Contributor

@nyomanjyotisa any updates?

@heyjennahay
Copy link
Contributor

Case 1: Delete one split without changing the amount of the remaining split to the original amount

  • Should we show "changed the amount" message?

Yes, because the amount of the expense has change from the original (pre split) amount and there isn't another expense that makes up the difference any more so I think this should behave the same as reducing the amount of a non split expense

Case 2: Reverse the split and set remaining expense back to original amount

  • Should we show "changed the expense" message? Or should we show the "changed the amount" message?

I don't think we need to show anything here given the expense has returned to it's original state, meaning the amount hasn't changed (it is the pre split amount) and the expense isn't actually modified any more?

Let me know if you agree/disagree/something eles?

@nyomanjyotisa
Copy link
Contributor Author

Thanks for the answer @heyjennahay, I'll take a look at this tomorrow

@nyomanjyotisa nyomanjyotisa changed the title Fix: 'Changed the amount' message appears when splitting expense and deleting one split Fix: changed the expense message appears when splitting expense and then reverting the split Nov 24, 2025
@nyomanjyotisa
Copy link
Contributor Author

nyomanjyotisa commented Nov 24, 2025

@dukenv0307 I've updated the PR to remove the changed the expense system message when we reverse a split and restore the remaining expense to its original amount. In case 1, when we delete one split without updating the remaining split back to its original amount, the changed the amount system message will still appear as before

RCA

When reverting a split operation (remove one of the split and set remaining expense back to its original amount), the transactionID field remains in transactionChanges after the comparison loop, causing the changed the expense system message

transactionChanges object is created from currentSplit which includes transactionID

App/src/libs/actions/IOU.ts

Lines 14156 to 14159 in 5375071

const transactionChanges = {
...currentSplit,
comment: currentSplit?.comment?.comment,
} as TransactionChanges;

During the comparison loop, transactionID from currentSplit is compared against transactionID from existing. Since these transactionID are different, it remains in transactionChanges

App/src/libs/actions/IOU.ts

Lines 14166 to 14175 in 5375071

for (const key of Object.keys(transactionChanges)) {
const newValue = transactionChanges[key as keyof typeof transactionChanges];
const oldValue = existing?.[key as keyof typeof existing];
if (newValue === oldValue) {
delete transactionChanges[key as keyof typeof transactionChanges];
// Ensure we pass the currency to getUpdateMoneyRequestParams as well, so the amount message is created correctly
} else if (key === 'amount') {
transactionChanges.currency = originalTransactionDetails?.currency;
}
}

Solution

We need to remove the transactionID field from transactionChanges for reverse split operations

            if (isReverseSplitOperation) {
                delete transactionChanges.transactionID;
            }

App/src/libs/actions/IOU.ts

Lines 14166 to 14183 in 5375071

for (const key of Object.keys(transactionChanges)) {
const newValue = transactionChanges[key as keyof typeof transactionChanges];
const oldValue = existing?.[key as keyof typeof existing];
if (newValue === oldValue) {
delete transactionChanges[key as keyof typeof transactionChanges];
// Ensure we pass the currency to getUpdateMoneyRequestParams as well, so the amount message is created correctly
} else if (key === 'amount') {
transactionChanges.currency = originalTransactionDetails?.currency;
}
}
if (Object.keys(transactionChanges).length > 0) {
const {onyxData: moneyRequestParamsOnyxData, params} = getUpdateMoneyRequestParams({
transactionID: existingTransactionID,
transactionThreadReportID: isReverseSplitOperation ? splitExpense?.reportID : transactionThreadReportID,
transactionChanges,
policy,
policyTagList: policyTags ?? null,

@dukenv0307
Copy link
Contributor

@nyomanjyotisa

In case 1, when we delete one split without updating the remaining split back to its original amount, the changed the amount system message will still appear as before

It already happened on main, so what is the RCA for?

@nyomanjyotisa
Copy link
Contributor Author

It already happened on main, so what is the RCA for?

Yes, case 1 is the current behavior on main. The RCA is for case 2, where the changed the expense system message appears when we delete a split and restore the remaining amount to its original

@dukenv0307
Copy link
Contributor

dukenv0307 commented Nov 25, 2025

Reviewer Checklist

  • I have verified the author checklist is complete (all boxes are checked off).
  • I verified the correct issue is linked in the ### Fixed Issues section above
  • I verified testing steps are clear and they cover the changes made in this PR
    • I verified the steps for local testing are in the Tests section
    • I verified the steps for Staging and/or Production testing are in the QA steps section
    • I verified the steps cover any possible failure scenarios (i.e. verify an input displays the correct error message if the entered data is not correct)
    • I turned off my network connection and tested it while offline to ensure it matches the expected behavior (i.e. verify the default avatar icon is displayed if app is offline)
  • I checked that screenshots or videos are included for tests on all platforms
  • I included screenshots or videos for tests on all platforms
  • I verified that the composer does not automatically focus or open the keyboard on mobile unless explicitly intended. This includes checking that returning the app from the background does not unexpectedly open the keyboard.
  • I verified tests pass on all platforms & I tested again on:
    • Android: HybridApp
    • Android: mWeb Chrome
    • iOS: HybridApp
    • iOS: mWeb Safari
    • MacOS: Chrome / Safari
  • If there are any errors in the console that are unrelated to this PR, I either fixed them (preferred) or linked to where I reported them in Slack
  • I verified there are no new alerts related to the canBeMissing param for useOnyx
  • I verified proper code patterns were followed (see Reviewing the code)
    • I verified that any callback methods that were added or modified are named for what the method does and never what callback they handle (i.e. toggleReport and not onIconClick).
    • I verified that comments were added to code that is not self explanatory
    • I verified that any new or modified comments were clear, correct English, and explained "why" the code was doing something instead of only explaining "what" the code was doing.
    • I verified any copy / text shown in the product is localized by adding it to src/languages/* files and using the translation method
    • I verified all numbers, amounts, dates and phone numbers shown in the product are using the localization methods
    • I verified any copy / text that was added to the app is grammatically correct in English. It adheres to proper capitalization guidelines (note: only the first word of header/labels should be capitalized), and is either coming verbatim from figma or has been approved by marketing (in order to get marketing approval, ask the Bug Zero team member to add the Waiting for copy label to the issue)
    • I verified proper file naming conventions were followed for any new files or renamed files. All non-platform specific files are named after what they export and are not named "index.js". All platform-specific files are named for the platform the code supports as outlined in the README.
    • I verified the JSDocs style guidelines (in STYLE.md) were followed
  • If a new code pattern is added I verified it was agreed to be used by multiple Expensify engineers
  • I verified that this PR follows the guidelines as stated in the Review Guidelines
  • I verified other components that can be impacted by these changes have been tested, and I retested again (i.e. if the PR modifies a shared library or component like Avatar, I verified the components using Avatar have been tested & I retested again)
  • I verified all code is DRY (the PR doesn't include any logic written more than once, with the exception of tests)
  • I verified any variables that can be defined as constants (ie. in CONST.ts or at the top of the file that uses the constant) are defined as such
  • If a new component is created I verified that:
    • A similar component doesn't exist in the codebase
    • All props are defined accurately and each prop has a /** comment above it */
    • The file is named correctly
    • The component has a clear name that is non-ambiguous and the purpose of the component can be inferred from the name alone
    • The only data being stored in the state is data necessary for rendering and nothing else
    • For Class Components, any internal methods passed to components event handlers are bound to this properly so there are no scoping issues (i.e. for onClick={this.submit} the method this.submit should be bound to this in the constructor)
    • Any internal methods bound to this are necessary to be bound (i.e. avoid this.submit = this.submit.bind(this); if this.submit is never passed to a component event handler like onClick)
    • All JSX used for rendering exists in the render method
    • The component has the minimum amount of code necessary for its purpose, and it is broken down into smaller components in order to separate concerns and functions
  • If any new file was added I verified that:
    • The file has a description of what it does and/or why is needed at the top of the file if the code is not self explanatory
  • If a new CSS style is added I verified that:
    • A similar style doesn't already exist
    • The style can't be created with an existing StyleUtils function (i.e. StyleUtils.getBackgroundAndBorderStyle(theme.componentBG)
  • If the PR modifies code that runs when editing or sending messages, I tested and verified there is no unexpected behavior for all supported markdown - URLs, single line code, code blocks, quotes, headings, bold, strikethrough, and italic.
  • If the PR modifies a generic component, I tested and verified that those changes do not break usages of that component in the rest of the App (i.e. if a shared library or component like Avatar is modified, I verified that Avatar is working as expected in all cases)
  • If the PR modifies a component related to any of the existing Storybook stories, I tested and verified all stories for that component are still working as expected.
  • If the PR modifies a component or page that can be accessed by a direct deeplink, I verified that the code functions as expected when the deeplink is used - from a logged in and logged out account.
  • If the PR modifies the UI (e.g. new buttons, new UI components, changing the padding/spacing/sizing, moving components, etc) or modifies the form input styles:
    • I verified that all the inputs inside a form are aligned with each other.
    • I added Design label and/or tagged @Expensify/design so the design team can review the changes.
  • If a new page is added, I verified it's using the ScrollView component to make it scrollable when more elements are added to the page.
  • For any bug fix or new feature in this PR, I verified that sufficient unit tests are included to prevent regressions in this flow.
  • If the main branch was merged into this PR after a review, I tested again and verified the outcome was still expected according to the Test steps.
  • I have checked off every checkbox in the PR reviewer checklist, including those that don't apply to this PR.

Screenshots/Videos

Android: HybridApp
Screen.Recording.2025-11-25.at.22.18.22.mov
Android: mWeb Chrome
Screen.Recording.2025-11-25.at.22.11.36.mov
iOS: HybridApp
Screen.Recording.2025-11-25.at.22.21.49.mov
iOS: mWeb Safari
Screen.Recording.2025-11-25.at.22.10.10.mov
MacOS: Chrome / Safari
Screen.Recording.2025-11-25.at.22.05.41.mov

@melvin-bot melvin-bot bot requested a review from iwiznia November 25, 2025 15:25
}
}

if (isReverseSplitOperation) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry but I don't get why we delete transactionChanges.transactionID in this case, can you explain?
Also that was not the solution proposed in the proposal in the issue, right?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The issue solved in this PR is different from the original GH issue. It seems like the original GH issue is the expected behavior based on this comment. In this PR, we address case 2 from that comment to prevent showing any system message when user perform a reverse split and set the remaining expense back to its original amount

And then, we delete transactionChanges.transactionID when we reverse a split because the transactionID is different in this case. This causes the transactionID to remain in transactionChanges, and we get the "changed the expense" system message even when the user makes no change at all. I explained the detailed RCA and solution here

@iwiznia iwiznia merged commit 84228cb into Expensify:main Nov 26, 2025
34 checks passed
@OSBotify
Copy link
Contributor

✋ This PR was not deployed to staging yet because QA is ongoing. It will be automatically deployed to staging after the next production release.

@OSBotify
Copy link
Contributor

🚀 Deployed to staging by https://github.com/iwiznia in version: 9.2.65-0 🚀

platform result
🕸 web 🕸 success ✅
🤖 android 🤖 success ✅
🍎 iOS 🍎 success ✅

@OSBotify
Copy link
Contributor

🚀 Deployed to production by https://github.com/marcaaron in version: 9.2.65-6 🚀

platform result
🕸 web 🕸 success ✅
🤖 android 🤖 success ✅
🍎 iOS 🍎 success ✅

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants