-
Notifications
You must be signed in to change notification settings - Fork 3.3k
Expense - Negative sign disappears after moving expense with negative sign to self DM #65920
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 - Negative sign disappears after moving expense with negative sign to self DM #65920
Conversation
@ikevin127 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] |
…9/negative-sign-expense
…9/negative-sign-expense
…9/negative-sign-expense
Reviewer Checklist
Screenshots/VideosAndroid: HybridAppandroid-hybrid.mp4Android: mWeb Chromeandroid-mweb.mp4iOS: HybridAppios-hybrid.MP4iOS: mWeb Safariios-mweb.mp4MacOS: Chrome / Safariweb.movMacOS: Desktopdesktop.mov |
@@ -408,8 +410,7 @@ function getUpdatedTransaction({ | |||
shouldStopSmartscan = true; | |||
} | |||
if (Object.hasOwn(transactionChanges, 'amount') && typeof transactionChanges.amount === 'number') { | |||
updatedTransaction.modifiedAmount = isFromExpenseReport ? -transactionChanges.amount : transactionChanges.amount; | |||
shouldStopSmartscan = true; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@thelullabyy Not supposed to remove shouldStopSmartscan = true;
from here, right ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for noticing this. I've reverted the code
tests/unit/IOUUtilsTest.ts
Outdated
@@ -383,4 +383,16 @@ describe('Check valid amount for IOU/Expense request', () => { | |||
const expenseAmount = TransactionUtils.getAmount(expenseTransaction, true, false); | |||
expect(expenseAmount).toBeLessThan(0); | |||
}); | |||
|
|||
test('Return correct unreported transaction amount with negative sign', () => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
test('Return correct unreported transaction amount with negative sign', () => { | |
test('Unreported expense amount should retain negative sign', () => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed
@thelullabyy There are two other
![]()
![]() Here's the Diffdiff --git a/src/libs/ReportUtils.ts b/src/libs/ReportUtils.ts
index eb19633c453..91ee7e2e7d0 100644
--- a/src/libs/ReportUtils.ts
+++ b/src/libs/ReportUtils.ts
@@ -4469,7 +4469,7 @@ function getTransactionReportName({
}
const report = getReportOrDraftReport(transaction?.reportID, reports);
- const amount = getTransactionAmount(transaction, !isEmptyObject(report) && isExpenseReport(report)) ?? 0;
+ const amount = getTransactionAmount(transaction, !isEmptyObject(report) && isExpenseReport(report), transaction?.reportID === CONST.REPORT.UNREPORTED_REPORT_ID) ?? 0;
const formattedAmount = convertToDisplayString(amount, getCurrency(transaction)) ?? '';
const comment = getMerchantOrDescription(transaction);
@@ -4524,7 +4524,7 @@ function getReportPreviewMessage(
return translateLocal('iou.receiptMissingDetails');
}
- const amount = getTransactionAmount(linkedTransaction, !isEmptyObject(report) && isExpenseReport(report)) ?? 0;
+ const amount = getTransactionAmount(linkedTransaction, !isEmptyObject(report) && isExpenseReport(report), linkedTransaction?.reportID === CONST.REPORT.UNREPORTED_REPORT_ID) ?? 0;
const formattedAmount = convertToDisplayString(amount, getCurrency(linkedTransaction)) ?? '';
return translateLocal('iou.didSplitAmount', {formattedAmount, comment: getMerchantOrDescription(linkedTransaction)});
}
@@ -4546,7 +4546,7 @@ function getReportPreviewMessage(
return translateLocal('iou.receiptMissingDetails');
}
- const amount = getTransactionAmount(linkedTransaction, !isEmptyObject(report) && isExpenseReport(report)) ?? 0;
+ const amount = getTransactionAmount(linkedTransaction, !isEmptyObject(report) && isExpenseReport(report), linkedTransaction?.reportID === CONST.REPORT.UNREPORTED_REPORT_ID) ?? 0;
const formattedAmount = convertToDisplayString(amount, getCurrency(linkedTransaction)) ?? '';
return translateLocal('iou.trackedAmount', {formattedAmount, comment: getMerchantOrDescription(linkedTransaction)});
}
@@ -9185,7 +9185,7 @@ function getIOUReportActionDisplayMessage(reportAction: OnyxEntry<ReportAction>,
return translateLocal(translationKey, {amount: formattedAmount, payer: ''});
}
- const amount = getTransactionAmount(transaction, !isEmptyObject(iouReport) && isExpenseReport(iouReport)) ?? 0;
+ const amount = getTransactionAmount(transaction, !isEmptyObject(iouReport) && isExpenseReport(iouReport), transaction?.reportID === CONST.REPORT.UNREPORTED_REPORT_ID) ?? 0;
const formattedAmount = convertToDisplayString(amount, getCurrency(transaction)) ?? '';
const isRequestSettled = isSettled(IOUReportID);
const isApproved = isReportApproved({report: iouReport});
how things look with the fix: ![]() The other |
🟢 Reviewer Checklist Completed⏳ Awaiting for author to apply requested changes before reviewing again and Approving. |
…9/negative-sign-expense
@ikevin127 Thanks for your review, I've resolved & updated the code based on your suggestions. Please help check again. About the failed test job 01, I believe it is the known issue due to flaky test |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the changes!
LGTM (the failing test seems unrelated to this PRs changes)
@thelullabyy I'd recommend to sync w/ main though, just to make sure you're up to date - otherwise there might be regressions reported even though they are not caused by this PRs changes.
…9/negative-sign-expense
Not related to this PRs changes, but I noticed a bug while testing, which did not hit staging yet, reported it on Slack and will be handled by QA. ☝️That's why I suggested a sync with main, besides addressing the failed flaky unit test which seems to have been fixed, thanks for the sync. @youssef-lr We're good to merge here if everything looks good to you. |
@thelullabyy Can you solve the conflict before CME will get to this PR so we can avoid further delay ? Thanks! |
|
@ikevin127 I have resolved the conflict. Pls check again |
Thanks, awaiting final review and merge from @youssef-lr |
✋ This PR was not deployed to staging yet because QA is ongoing. It will be automatically deployed to staging after the next production release. |
Explanation of Change
Fixed Issues
$ #64799
PROPOSAL: #64799 (comment)
Tests
Offline tests
QA Steps
PR Author Checklist
### Fixed Issues
section aboveTests
sectionOffline steps
sectionQA steps
sectioncanBeMissing
param foruseOnyx
toggleReport
and notonIconClick
)src/languages/*
files and using the translation methodSTYLE.md
) were followedAvatar
, I verified the components usingAvatar
are working as expected)StyleUtils.getBackgroundAndBorderStyle(theme.componentBG)
)Avatar
is modified, I verified thatAvatar
is working as expected in all cases)Design
label and/or tagged@Expensify/design
so the design team can review the changes.ScrollView
component to make it scrollable when more elements are added to the page.main
branch was merged into this PR after a review, I tested again and verified the outcome was still expected according to theTest
steps.Screenshots/Videos
Android: Native
android_compressed.mp4
Android: mWeb Chrome
android_web.mov
iOS: Native
ios_compressed.mp4
iOS: mWeb Safari
ios_web_compressed.mp4
MacOS: Chrome / Safari
web-main.mp4
web_1_compressed.mp4
web_2.mp4
web_3.mp4
MacOS: Desktop
desktop_compressed.mp4