You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[$500] Expense - Preview shows 0.00 when receipt currency is different from workspace currency #34064
Version Number: 1.4.22-0 Reproducible in staging?: Y Reproducible in production?: Y If this was caught during regression testing, add the test name, ID and link from TestRail: Email or phone of affected tester (no customers): Logs:https://stackoverflow.com/c/expensify/questions/4856 Expensify/Expensify Issue URL: Issue reported by: Applause - Internal Team Slack conversation:
Action Performed:
Go to workspace chat
Create a scan request with a receipt which has different currency from the workspace default currency
Stay in the workspace chat and wait until the scanning is complete
Expected Result:
The expense preview shows the correct amount when the scanning is complete
Actual Result:
When the scanning is complete, the expense preview shows 0.00, while LHN preview has no issue displaying the amount
Workaround:
Unknown
Platforms:
Which of our officially supported platforms is this issue occurring on?
changed the title [-]Expense - Preview shows 0.00 when receipt currency is different from workspace currency[/-][+][$500] Expense - Preview shows 0.00 when receipt currency is different from workspace currency[/+]on Jan 5, 2024
Please re-state the problem that we are trying to solve in this issue.
What is the root cause of that problem?
The getDisplayAmount in the ReportPreview is returning the value '0.00' because totalDisplaySpend is zero and the REPORTPREVIEW action message does not update the message when the receipt has completed scanning.
However, the OptionRow and MoneyReportHeader components will be updated.
What changes do you think we should make in order to solve the problem?
The best option is to fix this at the backend, but frontend solution can also fix the issue.
Since the MoneyReportHeader components update immediately, we can use the ReportUtils.getReportName function if the props.action.message is not updated yet in the REPORTPREVIEW to update the displayAmount.
We should create a function to simplify the code above called getAmountFromMessage.
function getAmountFromMessage(message){
let displayAmount = '';
const splits = actionMessage.split(' ');
for (let i = 0; i < splits.length; i++) {
if (/\d/.test(splits[i])) {
displayAmount = splits[i];
}
}
return displayAmount
}
In the getDisplayAmount function, create a condition to return the appropriate amount to display.
// If iouReport is not available, get amount from the action message (Ex: "Domain20821's Workspace owes $33.00" or "paid ₫60" or "paid -₫60 elsewhere")
It will show the amount if totalDisplaySpend > 0, otherwise, it will take the amount from the report action message. However, the report action message amount is 0.
And the totalDisplaySpend is 0 too. When we reopen the report or open the associated IOU report, we will get the correct amount.
I think the report action message amount is 0 is already obvious that this is a BE problem. But why totalDisplaySpend is 0? We get the totalDisplaySpend from getMoneyRequestSpendBreakdown. It will return a non 0 totalDisplaySpend ONLY if nonReimbursableSpend + totalSpend is not 0.
What changes do you think we should make in order to solve the problem?
If we look at this PR commit, we previously show the total amount.
I think ideally we should fix this on the BE, but in case we want to have the same behavior as LHN's last message, we can fallback to the amount total
const total = ReportUtils.getMoneyRequestReimbursableTotal(props.iouReport);
if (totalDisplaySpend || total) {
return CurrencyUtils.convertToDisplayString(totalDisplaySpend || total, props.iouReport.currency);
}
(or do the fallback inside getMoneyRequestSpendBreakdown by replacing 0 with getMoneyRequestReimbursableTotal)
But with this fallback, we can potentially show the wrong amount when the totalDisplaySpend is indeed 0 (that is the case where both nonReimbursableSpend and totalSpend really cancel out each other, not because of a bug). In that case, perhaps we can update the last message logic to use getMoneyRequestSpendBreakdown and get the totalDisplaySpend so we can have consistent behavior.
Could you sum up what the issue is after the backend fixes? Are we left with some technical debt / duplicated frontend utils that cannot be directly expressed as a user-perceived scenario, or what?
After the BE is fixed, we actually don't need any FE changes for the OP repro steps, but I'm under the assumption that we want to update the last message and preview amount to use the same logic (for consistency) with the fact that the last message shows a different amount when the BE issue persists.
BE and FE issues are basically different, with the FE issue only noticeable when the BE issue persists.
@tgolen@luacmartins However I always personally favor all efforts to make the code cleaner, more consistent and better in general, we'd need an approval to go forward here.
The fact is that the issue, as described, is not reproducible.
@luacmartins@tgolen Please confirm whether you consider @bernhardoj not entitled for 25%/50% compensation. He investigated the issue and pointed the exact place in the backend which needs fixing.
Thank you for asking. I agree @bernhardoj should be partially compensated at 50%, so reopening this. @miljakljajic can you assist with this payment, please?
P.S. Is everyone reading this sure this is really a near-term priority? Be brave: if you disagree, go ahead and close it out. If someone disagrees, they'll reopen it, and if they don't: one less thing to do!
Activity
[-]Expense - Preview shows 0.00 when receipt currency is different from workspace currency[/-][+][$500] Expense - Preview shows 0.00 when receipt currency is different from workspace currency[/+]melvin-bot commentedon Jan 5, 2024
Job added to Upwork: https://www.upwork.com/jobs/~01487b67fb3f39c5a0
melvin-bot commentedon Jan 5, 2024
Triggered auto assignment to @miljakljajic (
Bug), see https://stackoverflow.com/c/expensify/questions/14418 for more details.melvin-bot commentedon Jan 5, 2024
Bug0 Triage Checklist (Main S/O)
Platformsin OP are ✅)melvin-bot commentedon Jan 5, 2024
Triggered auto assignment to Contributor-plus team member for initial proposal review - @cubuspl42 (
External)Tony-MK commentedon Jan 6, 2024
Proposal
Please re-state the problem that we are trying to solve in this issue.
What is the root cause of that problem?
The
getDisplayAmountin theReportPreviewis returning the value '0.00' becausetotalDisplaySpendis zero and theREPORTPREVIEWaction message does not update themessagewhen the receipt has completed scanning.However, the
OptionRowandMoneyReportHeadercomponents will be updated.App/src/components/ReportActionItem/ReportPreview.js
Lines 196 to 203 in 0c351a4
What changes do you think we should make in order to solve the problem?
The best option is to fix this at the backend, but frontend solution can also fix the issue.
Since the
MoneyReportHeadercomponents update immediately, we can use theReportUtils.getReportNamefunction if theprops.action.messageis not updated yet in theREPORTPREVIEWto update thedisplayAmount.We should create a function to simplify the code above called
getAmountFromMessage.In the
getDisplayAmountfunction, create a condition to return the appropriate amount to display.Optional: We should probably optimize and simplify the
getAmountFromMessagefunction further than is currently implemented inmain.aim-salam commentedon Jan 6, 2024
.
bernhardoj commentedon Jan 6, 2024
Proposal
Please re-state the problem that we are trying to solve in this issue.
When we do a scan request, the amount preview shows 0. This happens even if we have the same currency as workspace.
What is the root cause of that problem?
The amount will show based on
getDisplayAmountfunction.App/src/components/ReportActionItem/ReportPreview.js
Lines 180 to 204 in 0c351a4
It will show the amount if

totalDisplaySpend> 0, otherwise, it will take the amount from the report action message. However, the report action message amount is 0.And the
totalDisplaySpendis 0 too. When we reopen the report or open the associated IOU report, we will get the correct amount.I think the report action message amount is 0 is already obvious that this is a BE problem. But why
totalDisplaySpendis 0? We get thetotalDisplaySpendfromgetMoneyRequestSpendBreakdown. It will return a non 0totalDisplaySpendONLY ifnonReimbursableSpend+totalSpendis not 0.App/src/libs/ReportUtils.ts
Lines 1728 to 1742 in 0c351a4
If we check the amount of both

nonReimbursableSpendandtotalSpend, we can see that the amount cancel out each other.Thus, we return a 0
totalDisplaySpend.App/src/libs/ReportUtils.ts
Lines 1745 to 1749 in 0c351a4
But if we reopen the report or open the IOU report, the BE will returns a 0

nonReimbursableSpend.But why LHN's last message show the correct amount?

It's because the last message doesn't use
getMoneyRequestSpendBreakdownlogic and just gets the money request total amount.App/src/libs/ReportUtils.ts
Line 2095 in 0c351a4
App/src/libs/ReportUtils.ts
Lines 1693 to 1713 in 0c351a4
What changes do you think we should make in order to solve the problem?
If we look at this PR commit, we previously show the total amount.
I think ideally we should fix this on the BE, but in case we want to have the same behavior as LHN's last message, we can fallback to the amount total
But with this fallback, we can potentially show the wrong amount when the
totalDisplaySpendis indeed 0 (that is the case where bothnonReimbursableSpendandtotalSpendreally cancel out each other, not because of a bug). In that case, perhaps we can update the last message logic to usegetMoneyRequestSpendBreakdownand get thetotalDisplaySpendso we can have consistent behavior.35 remaining items
bernhardoj commentedon Jan 23, 2024
After the BE is fixed, we actually don't need any FE changes for the OP repro steps, but I'm under the assumption that we want to update the last message and preview amount to use the same logic (for consistency) with the fact that the last message shows a different amount when the BE issue persists.

BE and FE issues are basically different, with the FE issue only noticeable when the BE issue persists.
jakub-trzebiatowski commentedon Jan 23, 2024
@tgolen @luacmartins However I always personally favor all efforts to make the code cleaner, more consistent and better in general, we'd need an approval to go forward here.
The fact is that the issue, as described, is not reproducible.
luacmartins commentedon Jan 23, 2024
@bernhardoj I'm removing getMoneyRequestReimbursableTotal in this PR, so I think we'd solve the consistency issue there.
luacmartins commentedon Jan 23, 2024
I think we can close this issue, since it's no longer reproducible.
tgolen commentedon Jan 23, 2024
OK, looks like #34909 should cover the inconsistent frontend logic, so I agree with closing this.
jakub-trzebiatowski commentedon Jan 24, 2024
@luacmartins @tgolen Please confirm whether you consider @bernhardoj not entitled for 25%/50% compensation. He investigated the issue and pointed the exact place in the backend which needs fixing.
tgolen commentedon Jan 24, 2024
Thank you for asking. I agree @bernhardoj should be partially compensated at 50%, so reopening this. @miljakljajic can you assist with this payment, please?
melvin-bot commentedon Feb 19, 2024
This issue has not been updated in over 15 days. @tgolen, @cubuspl42, @luacmartins, @miljakljajic, @bernhardoj eroding to Monthly issue.
P.S. Is everyone reading this sure this is really a near-term priority? Be brave: if you disagree, go ahead and close it out. If someone disagrees, they'll reopen it, and if they don't: one less thing to do!
miljakljajic commentedon Mar 22, 2024
Paying now - missed this one
miljakljajic commentedon Mar 22, 2024
Paid!