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 |
| } | ||
| 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.
@thelullabyy Not supposed to remove shouldStopSmartscan = true; from here, right ?
There was a problem hiding this comment.
Thanks for noticing this. I've reverted the code
| expect(expenseAmount).toBeLessThan(0); | ||
| }); | ||
|
|
||
| test('Return correct unreported transaction amount with negative sign', () => { |
There was a problem hiding this comment.
| test('Return correct unreported transaction amount with negative sign', () => { | |
| test('Unreported expense amount should retain negative sign', () => { |
|
@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.
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. |
|
🚀 Deployed to staging by https://github.com/youssef-lr in version: 9.1.83-0 🚀
|
|
🚀 Deployed to production by https://github.com/cristipaval in version: 9.1.83-5 🚀
|



Explanation of Change
Fixed Issues
$ #64799
PROPOSAL: #64799 (comment)
Tests
Offline tests
QA Steps
PR Author Checklist
### Fixed Issuessection aboveTestssectionOffline stepssectionQA stepssectioncanBeMissingparam foruseOnyxtoggleReportand notonIconClick)src/languages/*files and using the translation methodSTYLE.md) were followedAvatar, I verified the components usingAvatarare working as expected)StyleUtils.getBackgroundAndBorderStyle(theme.componentBG))Avataris modified, I verified thatAvataris working as expected in all cases)Designlabel and/or tagged@Expensify/designso the design team can review the changes.ScrollViewcomponent to make it scrollable when more elements are added to the page.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_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