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

[HOLD for payment 2024-07-17] [$250] Receipt required over undefined is shown in the violation message #43939

Closed
1 of 6 tasks
m-natarajan opened this issue Jun 18, 2024 · 21 comments
Assignees
Labels
Awaiting Payment Auto-added when associated PR is deployed to production Bug Something is broken. Auto assigns a BugZero manager. Daily KSv2 External Added to denote the issue can be worked on by a contributor

Comments

@m-natarajan
Copy link

m-natarajan commented Jun 18, 2024

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: 1.4.85-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: @puneetlath
Slack conversation: https://expensify.slack.com/archives/C049HHMV9SM/p1718718827355089

Action Performed:

Precondition : As a admin set up expense violation as " Receipt required amount" to "0" in OldDot control policy

  1. Invite an employee to the above policy
  2. As a employee submit a report without receipt
  3. As an admin open the report submitted

Expected Result:

Correct error message for the receipt required violation should appear

Actual Result:

"receipt required over undefined" message appears

Workaround:

unknown

Platforms:

Which of our officially supported platforms is this issue occurring on?

  • Android: Native
  • Android: mWeb Chrome
  • iOS: Native
  • iOS: mWeb Safari
  • MacOS: Chrome / Safari
  • MacOS: Desktop

Screenshots/Videos

Snip - (51) New Expensify - Google Chrome
image (6)
image (7)

View all open jobs on GitHub

Upwork Automation - Do Not Edit
  • Upwork Job URL: https://www.upwork.com/jobs/~01e9b622536ce232c5
  • Upwork Job ID: 1803138142417847354
  • Last Price Increase: 2024-06-18
  • Automatic offers:
    • ahmedGaber93 | Reviewer | 102810235
    • abzokhattab | Contributor | 102810237
Issue OwnerCurrent Issue Owner: @puneetlath
@m-natarajan m-natarajan added Daily KSv2 Bug Something is broken. Auto assigns a BugZero manager. labels Jun 18, 2024
Copy link

melvin-bot bot commented Jun 18, 2024

Triggered auto assignment to @puneetlath (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.

@puneetlath puneetlath added the External Added to denote the issue can be worked on by a contributor label Jun 18, 2024
@melvin-bot melvin-bot bot changed the title Receipt required over undefined is shown in the violation message [$250] Receipt required over undefined is shown in the violation message Jun 18, 2024
Copy link

melvin-bot bot commented Jun 18, 2024

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

@melvin-bot melvin-bot bot added the Help Wanted Apply this label when an issue is open to proposals by contributors label Jun 18, 2024
Copy link

melvin-bot bot commented Jun 18, 2024

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

@abzokhattab
Copy link
Contributor

abzokhattab commented Jun 18, 2024

Proposal

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

Receipt required over undefined is shown in the violation message

What is the root cause of that problem?

in the current case, the user submits a report without a receipt meaning the expected error should be Receipt required

Currently, when a user submits a report without a receipt, the expected error message should be "Receipt required." However, the translation logic solely checks if the params object exists but does not verify if formattedLimit is undefined.

receiptRequired: (params: ViolationsReceiptRequiredParams) => `Receipt required${params ? ` over ${params.formattedLimit}${params.category ? ' category limit' : ''}` : ''}`,

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

we need to change the param check to check the inner values of the params object since the params object will be always true as we are passing the object here:

        receiptRequired: ({formattedLimit, category}: ViolationsReceiptRequiredParams) =>
            `Receipt required${formattedLimit ?? category ? ` over${formattedLimit ? ` ${formattedLimit}` : ''}${category ? ` ${category} category limit` : ''}` : ''}`,

this is compliant with the translation guide here: #33969 (comment)

or alternatively, we can change the way this translation is called so that it passes a null value to the params object if both of the category and the formattedLimit are null

poc

image

@garatkarr
Copy link

I'm new here so not sure how the backend works yet but it seems to me this may be a backend issue. Onyx Pub/Sub sends the following when "Receipt Required Amount" is greater than 0:

{ "onyxMethod": "mergecollection", "key": "transactionViolations_", "value": { "transactionViolations_5942621983798817006": [ { "type": "violation", "name": "receiptRequired", "data": { "formattedLimit": "$0.01" } } ] } }

but when it is 0, data is null like in this example:
{ "onyxMethod": "mergecollection", "key": "transactionViolations_", "value": { "transactionViolations_5942621983798817006": [ { "type": "violation", "name": "receiptRequired", "data": null } ] } },

This is probably a backend issue with the common mistake of using something like if(dollarAmount) because a $0.00 amount is still a value and should not be treated as false. The backend code needs to perhaps check for not null and not undefined using === (strict equality)

@ahmedGaber93
Copy link
Contributor

reviewing

@ahmedGaber93
Copy link
Contributor

@abzokhattab Thanks for the proposal.

Your proposal looks good, but I think your code logic not cover all cases here #33969 (comment). Could you please update it?

Try this in your browser console.

const receiptRequired = (params) =>
          `Receipt required${params.category ?? params.formattedLimit ? ` over ${params.formattedLimit ?? ''}${params.category ? ' category limit' : ''}` : ''}`;


console.log(receiptRequired({}))
console.log(receiptRequired({ formattedLimit: '$500' }))
console.log(receiptRequired({ category: 'travel' }))
console.log(receiptRequired({ formattedLimit: '$500', category: 'travel' }))

@abzokhattab
Copy link
Contributor

okay i updated the proposal to produce exactly the same expected output image

@ahmedGaber93
Copy link
Contributor

We can move forward with @abzokhattab's proposal, It cover all cases here #33969 (comment)

🎀 👀 🎀 C+ reviewed

Copy link

melvin-bot bot commented Jun 20, 2024

Current assignee @puneetlath is eligible for the choreEngineerContributorManagement assigner, not assigning anyone new.

@melvin-bot melvin-bot bot removed the Help Wanted Apply this label when an issue is open to proposals by contributors label Jun 20, 2024
Copy link

melvin-bot bot commented Jun 20, 2024

📣 @ahmedGaber93 🎉 An offer has been automatically sent to your Upwork account for the Reviewer role 🎉 Thanks for contributing to the Expensify app!

Offer link
Upwork job

Copy link

melvin-bot bot commented Jun 20, 2024

📣 @abzokhattab 🎉 An offer has been automatically sent to your Upwork account for the Contributor role 🎉 Thanks for contributing to the Expensify app!

Offer link
Upwork job
Please accept the offer and leave a comment on the Github issue letting us know when we can expect a PR to be ready for review 🧑‍💻
Keep in mind: Code of Conduct | Contributing 📖

@melvin-bot melvin-bot bot added Reviewing Has a PR in review Weekly KSv2 and removed Daily KSv2 labels Jun 23, 2024
@abzokhattab
Copy link
Contributor

The PR is ready.

@melvin-bot melvin-bot bot added Weekly KSv2 Awaiting Payment Auto-added when associated PR is deployed to production and removed Weekly KSv2 labels Jul 10, 2024
@melvin-bot melvin-bot bot changed the title [$250] Receipt required over undefined is shown in the violation message [HOLD for payment 2024-07-17] [$250] Receipt required over undefined is shown in the violation message Jul 10, 2024
Copy link

melvin-bot bot commented Jul 10, 2024

Reviewing label has been removed, please complete the "BugZero Checklist".

@melvin-bot melvin-bot bot removed the Reviewing Has a PR in review label Jul 10, 2024
Copy link

melvin-bot bot commented Jul 10, 2024

The solution for this issue has been 🚀 deployed to production 🚀 in version 9.0.5-13 and is now subject to a 7-day regression period 📆. Here is the list of pull requests that resolve this issue:

If no regressions arise, payment will be issued on 2024-07-17. 🎊

For reference, here are some details about the assignees on this issue:

Copy link

melvin-bot bot commented Jul 10, 2024

BugZero Checklist: The PR fixing this issue has been merged! The following checklist (instructions) will need to be completed before the issue can be closed:

  • [@ahmedGaber93] The PR that introduced the bug has been identified. Link to the PR:
  • [@ahmedGaber93] The offending PR has been commented on, pointing out the bug it caused and why, so the author and reviewers can learn from the mistake. Link to comment:
  • [@ahmedGaber93] A discussion in #expensify-bugs has been started about whether any other steps should be taken (e.g. updating the PR review checklist) in order to catch this type of bug sooner. Link to discussion:
  • [@ahmedGaber93] Determine if we should create a regression test for this bug.
  • [@ahmedGaber93] If we decide to create a regression test for the bug, please propose the regression test steps to ensure the same bug will not reach production again.
  • [@puneetlath] Link the GH issue for creating/updating the regression test once above steps have been agreed upon:

@melvin-bot melvin-bot bot added Weekly KSv2 and removed Weekly KSv2 labels Jul 15, 2024
@melvin-bot melvin-bot bot changed the title [HOLD for payment 2024-07-17] [$250] Receipt required over undefined is shown in the violation message [HOLD for payment 2024-07-22] [HOLD for payment 2024-07-17] [$250] Receipt required over undefined is shown in the violation message Jul 15, 2024
Copy link

melvin-bot bot commented Jul 15, 2024

The solution for this issue has been 🚀 deployed to production 🚀 in version 9.0.6-8 and is now subject to a 7-day regression period 📆. Here is the list of pull requests that resolve this issue:

If no regressions arise, payment will be issued on 2024-07-22. 🎊

For reference, here are some details about the assignees on this issue:

Copy link

melvin-bot bot commented Jul 15, 2024

BugZero Checklist: The PR fixing this issue has been merged! The following checklist (instructions) will need to be completed before the issue can be closed:

  • [@ahmedGaber93] The PR that introduced the bug has been identified. Link to the PR:
  • [@ahmedGaber93] The offending PR has been commented on, pointing out the bug it caused and why, so the author and reviewers can learn from the mistake. Link to comment:
  • [@ahmedGaber93] A discussion in #expensify-bugs has been started about whether any other steps should be taken (e.g. updating the PR review checklist) in order to catch this type of bug sooner. Link to discussion:
  • [@ahmedGaber93] Determine if we should create a regression test for this bug.
  • [@ahmedGaber93] If we decide to create a regression test for the bug, please propose the regression test steps to ensure the same bug will not reach production again.
  • [@puneetlath] Link the GH issue for creating/updating the regression test once above steps have been agreed upon:

@melvin-bot melvin-bot bot added Daily KSv2 and removed Weekly KSv2 labels Jul 16, 2024
@puneetlath puneetlath changed the title [HOLD for payment 2024-07-22] [HOLD for payment 2024-07-17] [$250] Receipt required over undefined is shown in the violation message [HOLD for payment 2024-07-17] [$250] Receipt required over undefined is shown in the violation message Jul 16, 2024
@puneetlath
Copy link
Contributor

@ahmedGaber93 friendly reminder about the checklist.

@ahmedGaber93
Copy link
Contributor

BugZero Checklist: The PR fixing this issue has been merged! The following checklist (instructions) will need to be completed before the issue can be closed:

Regression Test Proposal

Precondition : As a admin set up expense violation as " Receipt required amount" to "0" in OldDot control policy

  1. Invite an employee to the above policy
  2. As a employee submit a report without receipt
  3. As an admin open the report submitted
  4. Validate that the correct translation is shown ("receipt required").

Do we agree 👍 or 👎

@puneetlath
Copy link
Contributor

Regression test issue: https://github.com/Expensify/Expensify/issues/413396

All paid. Thanks everyone!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Awaiting Payment Auto-added when associated PR is deployed to production Bug Something is broken. Auto assigns a BugZero manager. Daily KSv2 External Added to denote the issue can be worked on by a contributor
Projects
Archived in project
Development

No branches or pull requests

5 participants