Repository navigation
Conversation
…e details page" This reverts commit a836772.
…lineTaxSign" This reverts commit 0e48804.
Co-authored-by: Bernhard Owen Josephus <bernhardoj@users.noreply.github.com>
Co-authored-by: Bernhard Owen Josephus <bernhardoj@users.noreply.github.com>
Co-authored-by: Bernhard Owen Josephus <bernhardoj@users.noreply.github.com>
Co-authored-by: Bernhard Owen Josephus <bernhardoj@users.noreply.github.com>
Co-authored-by: Georgia Monahan <grgia@users.noreply.github.com>
…essage The server sends taxAmount/oldTaxAmount with the stored (inverted) sign, so convert them with getTaxAmount. Store the optimistic values the same way so the message doesn't flip after the server responds. Co-authored-by: Bernhard Owen Josephus <bernhardoj@users.noreply.github.com>
…e system message Co-authored-by: Bernhard Owen Josephus <bernhardoj@users.noreply.github.com>
… and update the merge distance test Co-authored-by: Bernhard Owen Josephus <bernhardoj@users.noreply.github.com>
|
🤖 Web test steps verification results: ✅ pass In all three flows (report expense in another currency, expenses merged offline, and unreported self DM expense), changing a negative expense's tax rate gives a negative tax amount and a negative converted tax. One thing to check: right after you create a negative expense, before you change its tax rate, the details page shows a positive tax ($5.35 / €4.76 for -€100). Android showed the same positive value on the create form.
|
|
@MelvinBot add this to QA Steps Prerequisite:
A.
B.
C.
D.
E.
Also update Test steps and Offline steps to be "Same as QA Steps" |
|
🤖 Updated the PR description:
I kept the "Verify that no errors appear in the JS console" checkbox under Tests and QA Steps. Scenario C skips step 5 in your list, so GitHub renumbers that list when it renders. |
|
App/src/libs/actions/IOU/SplitExpenseItems.ts Line 900 in adb2c02 @MelvinBot to fix E, can we simply remove Also, to fix D, can we update this to |
…y tax rules Co-authored-by: Bernhard Owen Josephus <bernhardoj@users.noreply.github.com>
|
Both changes fix the reported case but flip the sign for the opposite case. I pushed sign-aware versions instead in 0c2bb95. E (split): Removing
If you only edit a positive split's description, D (category rule): I added unit tests for positive and negative amounts in both flows. I couldn't run Jest, lint, or typecheck locally, so CI on this push is the first check. Supporting evidence
|
|
MelvinBot has made 11 consecutive commits trying to fix CI failures. Automatic CI fix dispatches are now paused for this PR. Next steps: A human should review the recent commits and resolve the conflicting CI errors manually. |
|
@MelvinBot Replace the PR Author Checklist section with below PR Author Checklist
Replace the Screenshots/Videos section with below Screenshots/VideosAndroid: NativeAndroid: mWeb ChromeiOS: NativeiOS: mWeb SafariMacOS: Chrome / Safariunreport.mp4merge.1.mp4web.mp4merge.mp4catg.mp4spliot.mp4Also, check all Verify that no errors appear in the JS console. And can you investigate and find if there are any cases where the tax amount should be negative, but it currently isn't? |
|
I updated the PR description:
I also found 5 cases where a negative expense still gets a positive tax. They share one cause: these flows compute or show the tax with
Android evidence (cases 1 and 2)I couldn't run the review duplicates case on Android. A category rule on the test workspace reset both duplicates to 0% tax before the review screen opened. Smaller cases and what already worksEdge cases from the code:
Already correct:
Distance, per diem, invoices and split bills can't have a negative taxed amount. The fix for all five cases is the same: compute and show the tax from the signed amount instead of Reply |
|
@MelvinBot can you give reproduction steps for 3 and 4? 1, 2, and 5 should be handled separately on a different issue to allow the user to enter a negative tax amount on the IOU flow. |
|
Both cases reproduce on web, but only with offline (optimistic) data. Once you go back online, the server corrects the tax to negative. Case 3 also has an online bug that's visible on the confirmation page: a positive duplicate shows a negative tax there. This corrects my earlier table, which implied the wrong sign was saved. Precondition: a workspace with Taxes enabled and two non-zero rates (5% and 10%). Note: Because of case 1, a new negative expense can start with a positive tax. Before each test, open the expense and set its tax rate on the details page so the tax reads negative. Case 3: Review duplicatesA. Negative expense, offline (wrong saved sign)
B. Positive expense, online (wrong confirmation page)
Cause: DynamicReviewTaxCodePage.tsx:80 calculates the tax from Case 4: Bulk edit from Search (offline)
Cause: BulkEdit.ts:331 and BulkEdit.ts:376 calculate the tax from |
|
⏱️ Ran out of time before I could finish. This usually means the task was too complex or I got stuck exploring. Please try again with a more specific request or post in #melvinbot-ai. |
|
@MelvinBot fix both cases 3 and 4 |
…ulk edit Review duplicates calculated the tax from the absolute amount, so the confirmation page showed a negative tax for positive expenses and the optimistic tax of a negative expense became positive. Calculate it from the stored amount so it matches the stored tax sign. Bulk edit calculated the tax from the absolute amount, so a negative expense got a positive optimistic tax. Use the displayed amount instead. Co-authored-by: Bernhard Owen Josephus <bernhardoj@users.noreply.github.com>
|
🤖 I added cases 3 and 4 to the QA Steps as new scenarios after E:
F and H each have an extra prerequisite: two non-zero tax rates, for example 5% and 10%. The rest of the description is unchanged. The amount-only step in H (step 10) has a unit test but hasn't been confirmed in the UI yet. In the last web run, entering -60 saved as +60. Typing "-" in that field switches the sign, so check that the amount reads negative before you save. |
|
@MelvinBot mark it as ready for review |
|
🤖 This PR is now marked as ready for review. The Tests and QA Steps sections in the PR body are still TODO placeholders. Please fill them in before review, or the PR Author Checklist check will keep failing. |
|
@bernhardoj 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] |
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
Reviewer Checklist
Screenshots/VideosAndroid: HybridAppAndroid: mWeb ChromeiOS: HybridAppiOS: mWeb SafariMacOS: Chrome / Safariunreport.mp4merge.1.mp4web.mp4merge.mp4catg.mp4spliot.mp4bulk.edit.mp4dupe.positive.mp4dupe.neg.mp4 |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: cfad55344e
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
| if (categoryTaxCode && categoryTaxAmount !== undefined && categoryTaxValue) { | ||
| // The category tax is calculated from the absolute amount, so give it the sign of the displayed amount, | ||
| // then store it with the opposite sign on expense reports and unreported expenses, the same as the amount. | ||
| const isNegativeAmount = getAmount(transaction, isFromExpenseReport, isUnReportedExpense) < 0; |
There was a problem hiding this comment.
Base the category-tax sign on the edited amount
When a bulk edit changes both the amount's sign and the category, and the new category has a default tax rule, this reads the original transaction amount to choose the tax sign. For example, changing a positive expense to a negative amount while assigning such a category leaves the optimistic tax positive (and the reverse transition leaves it negative), so the expense displays an amount and tax with opposite signs while offline or until the server response arrives. Use transactionChanges.amount when present before falling back to the current displayed amount.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Codex is right. I pushed a fix in 59ec093.
The category tax now uses the edited transaction instead of the original one (getUpdatedTransaction.ts:411-416). This fixes the sign. It also fixes the tax size, which was calculated from the old amount when the amount changed in the same edit.
I added a unit test for both sign flips. I couldn't run Jest, lint, or typecheck locally, so CI on this push is the first check.
On web, I bulk-edited a +$100 expense offline to -$100 with a 5% category rule. The tax amount showed -$4.76 offline and stayed -$4.76 after going online.
Other notes
- Edit multiple only appears when 2 or more expenses are selected, so the test edited both expenses.
- After going online, the system message said "the tax amount to $4.76" with no minus sign, while the field showed -$4.76. That message came from the server, so this fix doesn't change it.
There was a problem hiding this comment.
@MelvinBot can you add this to a new QA Steps test case?
There was a problem hiding this comment.
🤖 I added this to the QA Steps as case I, after H. It covers both sign flips, offline, with Edit multiple:
- Positive to negative, with the category that has the 5% tax rule: the tax amount is negative.
- Negative to positive, with the same category: the tax amount is positive.
- After you go online, all 4 expenses keep a tax sign that matches their amount.
It reuses D's category rule as its prerequisite. The rest of the description is unchanged.
I confirmed only the positive-to-negative flip in the UI, in my last web run. A unit test covers the negative-to-positive flip, but no one has checked it in the UI yet.
Co-authored-by: Bernhard Owen Josephus <bernhardoj@users.noreply.github.com>
JmillsExpensify
left a comment
There was a problem hiding this comment.
No product review required on these. All fixes.
|
@bernhardoj could you help me to outline the BE issues we need to file? Im going to find someone to take lead on these tax issues from the BE |
|
@grgia
Optimistically, the tax rate is updated, but the BE ( |
|
Hey @bernhardoj @grgia I’m addressing an issue with a duplicate negative expense here: #103727. My question is: Considering the work we’re doing here, what do you expect the taxAmount to be when a user submits a negative expense with a non-zero tax? Screen.Recording.2026-10-21.at.17.35.17.movIs taxAmount |
|
@hoangzinh it should be |
|
@MelvinBot please merge with main and fix the conflict |
…eTaxAmount Co-authored-by: Bernhard Owen Josephus <bernhardoj@users.noreply.github.com> # Conflicts: # src/pages/TransactionDuplicate/DynamicReviewTaxCodePage.tsx # tests/unit/ReportUtilsTest.ts
|
I merged
I couldn't run typecheck or Jest here because of a local tooling problem, so CI will be the first check. |
| const taxAmount = convertToDisplayString(normalizeTaxAmountSign(reportActionOriginalMessage?.taxAmount, true), currency); | ||
| const oldTaxAmount = convertToDisplayString(normalizeTaxAmountSign(reportActionOriginalMessage?.oldTaxAmount, true), currency); |
There was a problem hiding this comment.
Blocks
an employee who edits a split's tax amount sees the new and previous tax shown as negative on a positive split.
UpdateSplitTransaction.cpp:800 sends abs() tax amounts in the split message, and normalizeTaxAmountSign(x, true) negates them. should the Auth side send the stored sign first, before this lands?



























Explanation of Change
This re-lands #102175, which was reverted in #103763. It also includes the follow-up fixes for the deploy blockers it raised.
On expense reports,
taxAmountis stored with the opposite sign of what we display. The expense details page wrapped the tax inMath.abs(), so a negative expense showed a positive tax. The report table showed it as negative.This PR includes:
getTaxAmount()as is inMoneyRequestView. AddgetConvertedTaxAmount(), exposed throughgetTransactionDetails, so the converted tax also keeps its sign.isFromTrackedExpenseto the tax helpers, and store edited tax with the opposite sign.Math.abs().Two small changes were needed to combine these PRs:
getModifiedExpenseOriginalMessagenow also flips the new optimistic tax amount for unreported expenses. Without this, the system message for an edited unreported expense would show the new tax with the wrong sign until the server responds.125) for a distance merchant. With Keep the tax sign of a merged expense in line with its amount offline #103677, the merge flow uses the displayed tax, so the test now expects-125, matching its-2500amount.Not included: the split flow deploy blocker (#103723) had no fix PR in the request.
Fixed Issues
$ #98098
PROPOSAL: #98098 (comment)
Tests
Same as QA Steps
Offline tests
Same as QA Steps
QA Steps
Prerequisite:
A.
B.
C.
D.
Extra prerequisite:
E.
F.
Extra prerequisite:
G.
H.
Extra prerequisite:
I.
Extra prerequisite:
PR Author Checklist
### Fixed Issuessection aboveTestssectionOffline stepssectionQA stepssectionAvatar, I verified the components usingAvatarare working as expected)npm run compress-svg)Avataris modified, I verified thatAvataris working as expected in all cases)Designlabel and/or tagged@Expensify/designso the design team can review the changes.mainbranch was merged into this PR after a review, I tested again and verified the outcome was still expected according to theTeststeps.Screenshots/Videos
Android: Native
Android: mWeb Chrome
iOS: Native
iOS: mWeb Safari
MacOS: Chrome / Safari
unreport.mp4
merge.1.mp4
web.mp4
merge.mp4
catg.mp4
spliot.mp4