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-08-19] [$750] [Violations] Remove violations beta from front-end #44995

Closed
49 tasks
cead22 opened this issue Jul 8, 2024 · 32 comments
Closed
49 tasks
Assignees
Labels
Awaiting Payment Auto-added when associated PR is deployed to production Daily KSv2 External Added to denote the issue can be worked on by a contributor Improvement Item broken or needs improvement.

Comments

@cead22
Copy link
Contributor

cead22 commented Jul 8, 2024

If you haven’t already, check out our contributing guidelines for onboarding and email contributors@expensify.com to request to join our Slack channel!


Problem

Violations were implemented under a beta and we're ready to release this functionality to everyone

Solution

  • Remove all the code in the front end using the violations beta, and run a thorough set of manual tests to make sure everything is working as designed.
  • The proposal should outline all the places in the code we need to update
  • The proposed test script is below, and both online and offline tests should be done on every platform

(related https://github.com/Expensify/Expensify/issues/338701)


Tests

Pre-testing steps

  • Make sure emails sent to the testing email addresses go to an inbox you can access to validate your account(s)
  • Create a new workspace in new dot and go to the workspace settings
    • From the members tab, invite an additional user to the policy
    • From the More Features tab, enable categories and tags
    • From the Categories tab, add at least 2 categories, click settings, and switch on “Members must categorize all expenses”
    • From the Tags tab, add at least 2 tags, click settings, and switch on “Members must tag all expenses”

Important Notes

  • Only the violations related to tags and categories work while offline. That means if you have a missing tag or missing category violation, you’re offline, and you update the tag or category, the violation should disappear. Similarly, if you’re online, the violation should disappear right away.
    • For other violations, you’ll need to wait for the API to return a response and update the transaction violations.
  • Some tests ask to verify that the report preview looks correct. If you're on the case of a single-expense report, where we put a money request preview directly in the workspace chat (as oppposed to workspace chat having report previews, and reports having money request previews), you can add a second expense to the report and then verify the report preview, or omit the step and verify the money request preview
  • If you find any steps need to be updated, please let us know so we can update our testing script

Missing tag and missing category violations

Manual Request

  1. Press big plus sign > submit expense
  2. Select Manual tab (from Manual | Scan | Distance)
  3. Enter amount and press next
  4. Press the workspace from the pre-testing steps (press the row, not the split button in the row)
  5. Press the show more button if it’s there
    • Verify there’s a Required label on the Category row
    • Verify there’s a Required label on the tag row
  6. Enter a merchant
  7. Press the Request $X.XX button
  8. Repeat steps 1-7
    • Verify the report preview in the workspace chat has a red circle
  9. Press the report preview
    • Verify the money request previews in the iou report have a red circle
  10. Press the first money request preview
    • Verify you see the Missing Category red text under the category row
  11. Press the category row
  12. Press on a category
    • Verify you no longer see the Missing Category red text under the category row
  13. Press the Tag row
  14. Press on a tag
    • Verify you no longer see the Missing Tag red text under the category row
  15. Press on the IOU chat report link at the top
  16. Press on the second money request view
  17. Repeat steps 11-15
  18. Press on the IOU chat report link at the top
    • Verify the money request previews in the iou report no longer have a red circle
  19. Press on the policy expense chat report link at the top
    • Verify the report preview in the policy expense chat report no longer has a red circle
  20. 🛜 Repeats all these steps while offline

Scan Request

  1. Same as the Manual Request test above, replacing steps 2 and 3 with the following
  2. Select Scan tab (from Manual | Scan | Distance)
  3. Press choose file, select an image
  4. Press the workspace from the pre-testing steps (press the row, not the split button in the row)
    • Verify there’s a Required label on the Category row
    • Verify there’s a Required label on the tag row
  5. Press the Submit expense button
  6. Continue from the verification of step 8 above, and once done, repeat all these steps while offline 🛜

Distance Request

  1. Same as the Manual Request test above, replacing steps 2 and 3 with the following
  2. Select Distance tab (from Manual | Scan | Distance)
  3. Press Start and enter an address, eg 88 Kearny st. Then Press Finish and enter an address, eg, 1180 jackson st. And press Next
  4. Continue from step 4 above, and once done, repeat all these steps while offline 🛜

Category out of policy, tag out of policy violation, expense over limit, max age, over category limit, receipt required

Manual Request

  1. In old dot, in the workspace editor > expenses tab, set max expense age to 5, max expense amount to $10, receipt required amount to $5
  2. In the workspace editor > categories tab, set the max amount for one of the categories to $3
  3. On new dot, press big plus sign > submit expense
  4. Select Manual tab (from Manual | Scan | Distance)
  5. Enter $15 as the amount amount and press next
  6. Press the workspace from the pre-testing steps
  7. Press the show more button
  8. Press the Date row, and set the date to be more than 5 days ago
  9. Press the category row, select a category that doesn’t have a max amount
  10. Press the tag row, select a tag
  11. Enter a merchant
  12. Press the Submit $15 button
  13. If you have more than one expense
    • Confirm the report preview has a red circle
  14. Press the report preview
    • Confirm the money request preview has a red circle and shows “Review Required”
  15. Press the report preview or money request preview (depending on the number of expenses)
    • Verify you see Receipt required over $5 violation
    • Verify you see Amount over $10.00/person limit violation
    • Verify you see Date older than 5 days violation
  16. Press the category row, and select the category with max amount set to $3
    • Verify you see Receipt required over $3 category limit violation
  17. On a different tab, sign into old dot as an admin of the workspace where the money request was created
  18. Go to the policy editor, and disable the category and the tag you added to the money request
  19. Switch back to new dot, and refresh the page
    • Verify you see Category no longer valid violation
    • Verify you see Tag no longer valid violation
  20. Switch back to old dot, re-enable the category and tag you had disabled, remove the max amount from the category, and from the expenses tab, remove the values from the Max Expense Age (Days), Max Expense Amount and Receipt Required Amount fields
  21. Switch back to new dot, and refresh the page
    • Verify you don’t see Category out of policy violation
    • Verify you don’t see Tag out of policy violation
    • Verify you don’t see Amount over $10/person limit violation
    • Verify you don’t see Date older than 5 days violation
    • Verify you don’t see Receipt required over $5 violation
  22. Repeat steps 1-3 in old dot
  23. 🛜 Switch to new dot and go offline
  24. Repeat steps 1-14. The report preview, money request preview should be grayed out
  25. Go online, and repeat steps 15-21

Scan Request

  1. Same as the Manual Request test above, replacing steps 4 and 5 with the following
  2. Select Scan tab (from Manual | Scan | Distance)
  3. Press choose file, select an image
  4. Press the workspace from the pre-testing steps
    • Verify there’s a Required label on the Category row
    • Verify there’s a Required label on the tag row
  5. Press the Request button
  6. Continue from the verification of step 13 above, and once done, repeat all these steps while offline 🛜

Distance Request

  1. Same as the Manual Request test above, replacing steps 4 and 5 with the following
  2. Select Distance tab (from Manual | Scan | Distance)
  3. Press Start and enter an address, eg 88 Kearny st. Then Press Finish and enter an address, eg, 1180 jackson st. And press Next
  4. Continue from step 6 above, and once done, repeat all these steps while offline 🛜

Tag violations on workspace with Independent Tags (multi-level tags)

Manual Request

  1. In old dot, in the workspace editor > tags tab, switch on the Use multiple levels of tags toggle
  2. Click import from spreadsheet, and upload the file in this issue comment
  3. On new dot, press big plus sign > submit expense
  4. Select Manual tab (from Manual | Scan | Distance)
  5. Enter $15 as the amount amount and press next
  6. Press the workspace from the pre-testing steps (press the row, not the split button in the row)
  7. Press the merchant row and enter a merchant
  8. Press the Submit $15 button
  9. Confirm the report preview has a red circle
  10. Press the report preview
  11. If the report has more than 1 expense
    • Confirm the money request preview has a red circle and shows “Review Required”
  12. Press the money request preview
    • Verify you see Missing Region, Missing Project, and Missing Department violations
  13. Press the Region menu item, and select a region
    • Verify that the Missing Region violation disappears right away
  14. Repeat for Department and Project
  15. Press the Region menu item, and unselect the selected region
    • Verify that the Missing Region violation appears right away
  16. 🛜 Switch to new dot and go offline
  17. Repeat steps 1-16. The report preview, money request preview should be grayed out
  18. Go online, and confirm everything looks the same, except nothing is grayed out
  19. Submit a new expense on the same workspace, and select all the required fields so there are no violation on that expense
  20. Click on the link in the transaction thread header to go back to the expense report if you didn’t land there already
    • Verify the money request preview says Missing Region next to the a red circle

Tag violations on workspace with Dependent Tags (multi-level tags)

Manual Request

  1. In old dot, in the workspace editor > tags tab, switch on the Use multiple levels of tags and the People must tag expenses toggles
  2. Click import from spreadsheet, uncheck “Are these independent tags?”, and upload the file in this issue comment
  3. On new dot, press big plus sign > submit expense
  4. Select Manual tab (from Manual | Scan | Distance)
  5. Enter $15 as the amount amount and press next
  6. Press the workspace from the pre-testing steps (press the row, not the split button in the row)
  7. Press the merchant row and enter a merchant
    • Confirm the Required label shows on the State, Region, and City rows
  8. Press the Submit $15 button
  9. Confirm the report preview has a red circle
  10. Press the report preview
  11. If the report has more than 1 expense
    • Confirm the money request preview has a red circle and shows “Review Required”
  12. Press the money request preview
    • Verify you see Missing State, Missing Region, and Missing City violations
  13. Press the Region menu item, and select a region
    • Verify that the Missing Region violation disappears right away
    • Verify you see All tags required violations under State and City
  14. Select a State
    • Verify that the see All tags required violation disappears from under State
    • Verify you see All tags required violations under City
  15. Select a City
    • Verify that the see All tags required violations are gone
  16. De-select City
    • Verify that the All tags required violation appears under City
  17. 🛜 Switch to new dot and go offline
  18. Repeat steps 1-16. The report preview, money request preview should be grayed out
  19. Go online, and confirm everything looks the same, except nothing is grayed out
  20. Submit a new expense on the same workspace, and select all the required fields so there are no violation on that expense
  21. Click on the link in the transaction thread header to go back to the expense report if you didn’t land there already
    • Verify the money request preview for the first expense says Review Required next to the a red circle
      Switch off requirement for tags and categories
      For the next tests, stop requiring tags and categories so you can focus on receipt related violations
  • Go to the workspace settings for the workspace you’re using
    • From the Categories tab switch off “Members must categorize all expenses”
    • From the Tags tab switch off “Members must tag all expenses”

Receipt Audit Scan

  1. Press big plus sign > submit expense
  2. Select Scan tab (from Manual | Scan | Distance)
  3. Press choose file and upload the popbagel.pdf file in this issue comment
  4. Select the workspace to submit to
  5. Wait for it to scan, it should be quick since we have a parser for square receipts
    • Verify you see “Receipt * Verified √” above the receipt
    • Verify amount is set to $21.90, and date to 2020-01-23
  6. Update the amount to $25
    • Verify you see “Amount greater than scanned receipt” violation under the amount field
  7. Click the blue link in the report header
  8. If there aren’t any other expenses on the report you added the receipt to, submit another expense on the same workspace
  9. Navigate to the expense report
    • Verify you see "Cash * Review required 🔴" in the Request Preview

Receipt Audit Distance

  1. Press big plus sign > submit expense
  2. Select Distance tab (from Manual | Scan | Distance)
  3. Press Start and enter an address, eg 88 Kearny st. Then Press Finish and enter an address, eg, 1180 jackson st. And press Next
  4. Select the workspace to submit to
  5. Click Submit $XX button
  6. Update the amount to $7
    • Verify you see “Amount differs from calculated distance” violation under the amount field
  7. Click the blue link in the report header
  8. If there aren’t any other expenses on the report you added the receipt to, submit another expense on the same workspace
  9. Navigate to the expense report
    • Verify you see "Distance * Review required 🔴" in the Request Preview
      Receipt Audit Card (Amount greater than card transaction)
  10. Import a third party domain control card via OldDot
  11. Find the card transaction in the workspace chat corresponding to the assigned employee, or visit the Search page and find the transaction by date.
  12. Open the card expense
  13. Change the amount of the card transaction to an amount higher than the original charge
  14. Verify that you see “Amount greater than scanned receipt”
  15. Verify that you see “Receipt * Issue found 🔴” above the receipt
  16. Navigate back to the transaction/expense preview.
  17. Verify that you see “Review required 🔴" in the Request Preview

Receipt Audit - Receipt Not Verified

  1. Press big plus sign > submit expense
  2. Select Scan tab (from Manual | Scan | Distance)
  3. Press choose file and upload a bad receipt. You can take a screenshot of a blank space on your screen and upload that
  4. Select the workspace to submit to
  5. Wait for it to scan, it should fail
    • Verify you see “Receipt scanning failed. Enter details manually.” violation under the receipt
  6. Add an amount and a merchant
    • Verify all violations are gone

cc @JmillsExpensify


View all open jobs on GitHub

Upwork Automation - Do Not Edit
  • Upwork Job URL: https://www.upwork.com/jobs/~01e029ffdb5d51f383
  • Upwork Job ID: 1810382758841290536
  • Last Price Increase: 2024-07-08
  • Automatic offers:
    • ShridharGoel | Contributor | 103067321
Issue OwnerCurrent Issue Owner: @JmillsExpensify
@cead22 cead22 added External Added to denote the issue can be worked on by a contributor Daily KSv2 Improvement Item broken or needs improvement. labels Jul 8, 2024
@cead22 cead22 self-assigned this Jul 8, 2024
Copy link

melvin-bot bot commented Jul 8, 2024

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

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

melvin-bot bot commented Jul 8, 2024

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

@ShridharGoel
Copy link
Contributor

ShridharGoel commented Jul 8, 2024

Proposal

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

[Violations] Remove violations beta from front-end.

What is the root cause of that problem?

We need to remove violations code.

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

All the things are already mentioned in OP. Most important part seems to be testing.

canUseViolations is present in Permissions.ts. Check all the usages and remove them so that the dependency on this check is no longer present and everyone can access it. Then, this method would no longer be needed.

canUseViolations is present at 28 places in 12 files:

const {canUseViolations} = usePermissions(iouType);

const {canUseViolations} = usePermissions(iouType);

rightLabel={isCategoryRequired && canUseViolations ? translate('common.required') : ''}

rightLabel={isTagRequired && canUseViolations ? translate('common.required') : ''}

const {canUseViolations} = usePermissions();

canUseViolations={canUseViolations}

canUseViolations={canUseViolations}

const shouldDisplayViolations = canUseViolations && ReportUtils.shouldDisplayTransactionThreadViolations(fullReport, transactionViolations, parentReportAction);

canUseViolations: boolean | undefined;

const {canUseViolations, canUseP2PDistanceRequests} = usePermissions(isTrackExpense ? CONST.IOU.TYPE.TRACK : undefined);

!!canUseViolations && getViolationsForField(field, data, policyHasDependentTags, tagValue).length > 0,

[canUseViolations, getViolationsForField],

const shouldShowNotesViolations = !isReceiptBeingScanned && canUseViolations && ReportUtils.isPaidGroupPolicy(report);

const {canUseViolations} = usePermissions();

(canUseViolations && (ReportUtils.hasViolations(iouReportID, transactionViolations) || ReportUtils.hasWarningTypeViolations(iouReportID, transactionViolations))) ||

canUseViolations: true,

if (!Permissions.canUseViolations(betas)) {

function canUseViolations(betas: OnyxEntry<Beta[]>): boolean {

canUseViolations,

canUseViolations: (betas: Beta[]) => betas.includes(CONST.BETAS.VIOLATIONS),

if (Permissions.canUseViolations(betas)) {

if (Permissions.canUseViolations(betas)) {

if (Permissions.canUseViolations(betas)) {

Example:

This would be changed to:

optimisticData.push({
    onyxMethod: Onyx.METHOD.SET,
    key: `${ONYXKEYS.COLLECTION.TRANSACTION_VIOLATIONS}${transactionID}`,
    value: null,
});

This would be changed to:

rightLabel={isCategoryRequired ? translate('common.required') : ''}

@cead22
Copy link
Contributor Author

cead22 commented Jul 8, 2024

I'll update the solution in the issue description, but please include all the places in the code we need to update in your proposal

@JmillsExpensify JmillsExpensify self-assigned this Jul 8, 2024
@ShridharGoel
Copy link
Contributor

@cead22 Updated.

@cead22
Copy link
Contributor Author

cead22 commented Jul 9, 2024

@getusha any thoughts on that proposal?

@getusha
Copy link
Contributor

getusha commented Jul 9, 2024

The task looks pretty straightforward to me. the main part seems to be the testing. we can proceed with @ShridharGoel
I am assuming there aren't other beta futures like #43864 under violations beta
🎀 👀 🎀 C+ Reviewed.

Copy link

melvin-bot bot commented Jul 9, 2024

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

@cead22
Copy link
Contributor Author

cead22 commented Jul 10, 2024

Correct, we can leave that and other betas alone and focus on the violations one

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

melvin-bot bot commented Jul 10, 2024

📣 @ShridharGoel 🎉 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 📖

@ShridharGoel
Copy link
Contributor

Will open PR within a few days (once all test steps get completed).

@melvin-bot melvin-bot bot added the Overdue label Jul 15, 2024
@cead22
Copy link
Contributor Author

cead22 commented Jul 15, 2024

Thanks, let me know if I can help!

@melvin-bot melvin-bot bot removed the Overdue label Jul 15, 2024
@cead22
Copy link
Contributor Author

cead22 commented Jul 16, 2024

@ShridharGoel how is the PR coming along? anything I can do to help?

@ShridharGoel
Copy link
Contributor

@cead22 Will open the PR soon. I was travelling yesterday, it got a bit delayed.

@ShridharGoel
Copy link
Contributor

@cead22 The "Missing category" and "Missing tag" messages are not shown when a receipt is scanning. Is that expected?

@cead22
Copy link
Contributor Author

cead22 commented Jul 17, 2024

Yes

@melvin-bot melvin-bot bot added Reviewing Has a PR in review and removed Daily KSv2 labels Jul 19, 2024
@ShridharGoel
Copy link
Contributor

So should we update the testing steps?

@cead22
Copy link
Contributor Author

cead22 commented Jul 22, 2024

Yes probably. Which ones are failing?

@ShridharGoel
Copy link
Contributor

@cead22 Verify you see “Receipt * Issue found 🔴” above the receipt when changing amount.

@ShridharGoel
Copy link
Contributor

Import a third party domain control card via OldDot

Can you share some insights on how to do this?

@cead22
Copy link
Contributor Author

cead22 commented Jul 23, 2024

I will, let me make sure I can get the steps right. Is this the last thing blocking you from submitting the PR for review? If so, let's get started on the review and we can worry about that test later

@melvin-bot melvin-bot bot added Weekly KSv2 and removed Weekly KSv2 labels Jul 23, 2024
@ShridharGoel
Copy link
Contributor

@getusha I think the PR can be reviewed while I'm working on completing the videos for all platforms.

@ShridharGoel
Copy link
Contributor

Update: PR is awaiting review.

Copy link

melvin-bot bot commented Aug 12, 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 Aug 12, 2024
Copy link

melvin-bot bot commented Aug 12, 2024

The solution for this issue has been 🚀 deployed to production 🚀 in version 9.0.18-10 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-08-19. 🎊

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

@melvin-bot melvin-bot bot added Daily KSv2 and removed Weekly KSv2 labels Aug 18, 2024
@JmillsExpensify
Copy link

Payment summary:

Contributor: @ShridharGoel $750
Reviewer: @getusha $750

@getusha I vaguely remember that as part of this issue we'd add a series of new regression tests, is that right or did I misremember that part?

@cead22
Copy link
Contributor Author

cead22 commented Aug 20, 2024

@getusha I vaguely remember that as part of this issue we'd add a series of new regression tests, is that right or did I misremember that part?

They're the ones at the top of this issue, which should be the same as these ones shared in #qa

@JmillsExpensify
Copy link

Nice thanks for clarifying. Contributor is paid out via Upwork. @getusha Please submit a request via Newdot and we'll get that processed.

@mallenexpensify
Copy link
Contributor

Contributor: @ShridharGoel paid $750 via Upwork
Contributor+: @getusha owed $750 via NewDot

Do we want a test case for/from this issue specifically or is that being covered more holistically as part of a project?

@JmillsExpensify
Copy link

$750 approved for @getusha

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 Daily KSv2 External Added to denote the issue can be worked on by a contributor Improvement Item broken or needs improvement.
Projects
Status: Done
Development

No branches or pull requests

5 participants