Skip to content
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

[$250] Distance - Zero amount not displayed in receipt and expense details for distance expense #58478

Open
4 of 8 tasks
jponikarchuk opened this issue Mar 14, 2025 · 11 comments
Assignees
Labels
Bug Something is broken. Auto assigns a BugZero manager. Daily KSv2 External Added to denote the issue can be worked on by a contributor Help Wanted Apply this label when an issue is open to proposals by contributors

Comments

@jponikarchuk
Copy link

jponikarchuk commented Mar 14, 2025

If you haven’t already, check out our contributing guidelines for onboarding and email [email protected] to request to join our Slack channel!


Version Number: V9.1.13-0
Reproducible in staging?: Yes
Reproducible in production?: Yes
If this was caught on HybridApp, is this reproducible on New Expensify Standalone?: Yes, reproducible on both
If this was caught during regression testing, add the test name, ID and link from TestRail: N
Email or phone of affected tester (no customers): [email protected]
Issue reported by: Applause Internal Team
Device used: Redminote 10s android 13
App Component: Money Requests

Action Performed:

  1. Launch app
  2. Go to workspace settings > enable distance rate
  3. Change the rate to 0.0001
  4. Go to workspace chat
  5. Create a distance expense with following way points 65, pappammal koil, vaithikuppam, puducherry, India & 67, pappammal koil, vaithikuppam, puducherry, India
  6. Note in confirmation page and in expense preview ₹0.00 amount is shown
  7. Open the expense
  8. Tap the receipt
  9. Note amount zero is not shown and in receipt also no details about amount

Expected Result:

The confirmation page, expense preview, and receipt should consistently display amount ₹0.00 .

Actual Result:

In the confirmation page and expense preview, ₹0.00 is displayed.

After opening the expense and tapping the receipt, the amount is not shown, and the receipt lacks any details about the amount.

Workaround:

Unknown

Platforms:

  • Android: Standalone
  • Android: HybridApp
  • Android: mWeb Chrome
  • iOS: Standalone
  • iOS: HybridApp
  • iOS: mWeb Safari
  • MacOS: Chrome / Safari
  • MacOS: Desktop

Screenshots/Videos

Bug6770462_1741942910940.Screenrecorder-2025-03-14-14-18-57-910.mp4

View all open jobs on GitHub

Upwork Automation - Do Not Edit
  • Upwork Job URL: https://www.upwork.com/jobs/~021900601730914519131
  • Upwork Job ID: 1900601730914519131
  • Last Price Increase: 2025-03-14
Issue OwnerCurrent Issue Owner: @Ollyws
@jponikarchuk jponikarchuk added Bug Something is broken. Auto assigns a BugZero manager. Daily KSv2 labels Mar 14, 2025
Copy link

melvin-bot bot commented Mar 14, 2025

Triggered auto assignment to @lschurr (Bug), see https://stackoverflow.com/c/expensify/questions/14418 for more details. Please add this bug to a GH project, as outlined in the SO.

@ryntgh
Copy link

ryntgh commented Mar 14, 2025

🚨 Edited by proposal-police: This proposal was edited at 2025-03-17 07:26:41 UTC.

Proposal

Please re-state the problem that we are trying to solve in this issue.

Distance - Zero amount not displayed in receipt and expense details for distance expense

What is the root cause of that problem?

The component conditionally renders the transaction amount using a falsy check ({!!transactionAmount}), which evaluates to false when the amount is 0. This causes 0 (a valid value) not to be displayed.

{!!transactionAmount && <Text style={styles.eReceiptAmount}>{formattedTransactionAmount}</Text>}

Additionally, in MoneyRequestView, the amount formatting logic also uses a falsy check (transactionAmount ? ... : ''), which results in 0 being replaced with an empty string.

const formattedTransactionAmount = transactionAmount ? convertToDisplayString(transactionAmount, transactionCurrency) : '';
const formattedPerAttendeeAmount = transactionAmount ? convertToDisplayString(transactionAmount / (transactionAttendees?.length ?? 1), transactionCurrency) : '';

What changes do you think we should make in order to solve the problem?

We should update the conditional check to ensure that the amount is displayed even when it is 0. For example, we can change the condition to verify that the amount is not null or undefined:

{(transactionAmount !== null && transactionAmount !== undefined) && (
    <Text style={styles.eReceiptAmount}>{formattedTransactionAmount}</Text>
)}

Or, alternatively:

{(transactionAmount || transactionAmount === 0) && (
    <Text style={styles.eReceiptAmount}>{formattedTransactionAmount}</Text>
)}

For MoneyRequestView:

    const formattedTransactionAmount = transactionAmount !== null && transactionAmount !== undefined ? convertToDisplayString(transactionAmount, transactionCurrency) : '';
    const formattedPerAttendeeAmount = transactionAmount !== null && transactionAmount !== undefined ? convertToDisplayString(transactionAmount / (transactionAttendees?.length ?? 1), transactionCurrency) : '';

What specific scenarios should we cover in automated tests to prevent reintroducing this issue in the future?

N/A, minor UI bug

What alternative solutions did you explore? (Optional)

Image

Image

@lschurr lschurr added the External Added to denote the issue can be worked on by a contributor label Mar 14, 2025
@melvin-bot melvin-bot bot changed the title Distance - Zero amount not displayed in receipt and expense details for distance expense [$250] Distance - Zero amount not displayed in receipt and expense details for distance expense Mar 14, 2025
Copy link

melvin-bot bot commented Mar 14, 2025

Job added to Upwork: https://www.upwork.com/jobs/~021900601730914519131

@melvin-bot melvin-bot bot added the Help Wanted Apply this label when an issue is open to proposals by contributors label Mar 14, 2025
Copy link

melvin-bot bot commented Mar 14, 2025

Triggered auto assignment to Contributor-plus team member for initial proposal review - @Ollyws (External)

@nkdengineer
Copy link
Contributor

nkdengineer commented Mar 14, 2025

🚨 Edited by proposal-police: This proposal was edited at 2025-03-17 06:24:34 UTC.

Proposal

Please re-state the problem that we are trying to solve in this issue.

In the confirmation page and expense preview, ₹0.00 is displayed.

What is the root cause of that problem?

In the expense preview, we always display the formatted amount string without any condition

But in DistanceEReceipt, the amount is only displayed if transactionAmount isn't 0, undefined, null.

{!!transactionAmount && <Text style={styles.eReceiptAmount}>{formattedTransactionAmount}</Text>}

The same bug happens on MoneyRequestView,

const formattedTransactionAmount = transactionAmount ? convertToDisplayString(transactionAmount, transactionCurrency) : '';
const formattedPerAttendeeAmount = transactionAmount ? convertToDisplayString(transactionAmount / (transactionAttendees?.length ?? 1), transactionCurrency) : '';

What changes do you think we should make in order to solve the problem?

  1. We can remove this condition
{<Text style={styles.eReceiptAmount}>{formattedTransactionAmount}</Text>}

{!!transactionAmount && <Text style={styles.eReceiptAmount}>{formattedTransactionAmount}</Text>}

  1. For the MoneyRequestView, we need to check the distance request has a route or not before displaying the amount, because if the route is pending, the amount isn't calculated and it's 0 by default
const formattedTransactionAmount = (!!transactionAmount || (isDistanceRequest && hasRoute)) ? convertToDisplayString(transactionAmount, transactionCurrency) : '';
const formattedPerAttendeeAmount = (!!transactionAmount || (isDistanceRequest && hasRoute)) ? convertToDisplayString(transactionAmount / (transactionAttendees?.length ?? 1), transactionCurrency) : '';

const formattedTransactionAmount = transactionAmount ? convertToDisplayString(transactionAmount, transactionCurrency) : '';

Note: For the DistanceEReceipt we don't need to check the condition like this because the DistanceEReceipt is only displayed when the route exists, that means the amount is already calculated.

What specific scenarios should we cover in automated tests to prevent reintroducing this issue in the future?

This is an UI bug

What alternative solutions did you explore? (Optional)

Reminder: Please use plain English, be brief and avoid jargon. Feel free to use images, charts or pseudo-code if necessary. Do not post large multi-line diffs or write walls of text. Do not create PRs unless you have been hired for this job.

Copy link
Contributor

⚠️ Thanks for your proposal. Please update it to follow the proposal template, as proposals are only reviewed if they follow that format (note the mandatory sections).

@utkershrajvenshi
Copy link

utkershrajvenshi commented Mar 17, 2025

Proposal

Please re-state the problem that we are trying to solve in this issue.

In distance expenses, zero amount is not displayed in receipt and expense details

What is the root cause of that problem?

We are checking if transactionAmount is a valid, defined value in MoneyRequestView.tsx:

const formattedTransactionAmount = transactionAmount ? convertToDisplayString(transactionAmount, transactionCurrency) : '';
const formattedPerAttendeeAmount = transactionAmount ? convertToDisplayString(transactionAmount / (transactionAttendees?.length ?? 1), transactionCurrency) : '';

and in DistanceEReceipt.tsx:

{!!transactionAmount && <Text style={styles.eReceiptAmount}>{formattedTransactionAmount}</Text>}

The checks are failing for transactionAmount with value 0 due to being inferred as a falsy value.

What changes do you think we should make in order to solve the problem?

We can explicitly check if transactionAmount is undefined in these places:

const formattedTransactionAmount = transactionAmount !== undefined ? convertToDisplayString(transactionAmount, transactionCurrency) : '';
const formattedPerAttendeeAmount = transactionAmount !== undefined ? convertToDisplayString(transactionAmount / (transactionAttendees?.length ?? 1), transactionCurrency) : '';
{transactionAmount !== undefined && <Text style={styles.eReceiptAmount}>{formattedTransactionAmount}</Text>}

This allows cases where transactionAmount is 0 to pass the checks and render values correctly:

In MoneyRequestView In DistanceERecipt
Image Image

What specific scenarios should we cover in automated tests to prevent reintroducing this issue in the future?

N/A

What alternative solutions did you explore? (Optional)

@melvin-bot melvin-bot bot added the Overdue label Mar 17, 2025
@nkdengineer
Copy link
Contributor

Updated proposal.

@Ollyws
Copy link
Contributor

Ollyws commented Mar 17, 2025

This one is pretty straightforward and @ryntgh's is the first proposal that does the job so let's go with that.
🎀👀🎀 C+ reviewed

@melvin-bot melvin-bot bot removed the Overdue label Mar 17, 2025
Copy link

melvin-bot bot commented Mar 17, 2025

Triggered auto assignment to @rlinoz, see https://stackoverflow.com/c/expensify/questions/7972 for more details.

@nkdengineer
Copy link
Contributor

For the MoneyRequestView, we need to check the distance request has a route or not before displaying the amount, because if the route is pending, the amount isn't calculated and it's 0 by default

@Ollyws Can you check the point I mentioned for the case of MoneyRequestView

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Something is broken. Auto assigns a BugZero manager. Daily KSv2 External Added to denote the issue can be worked on by a contributor Help Wanted Apply this label when an issue is open to proposals by contributors
Projects
None yet
Development

No branches or pull requests

7 participants