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

Add violation message to MoneyRequestPreview #33969

Merged
merged 78 commits into from
Feb 17, 2024

Conversation

trevor-coleman
Copy link
Contributor

@trevor-coleman trevor-coleman commented Jan 4, 2024

Details

Adds a message to the MoneyRequestPreview that shows the violation or "Review Required"

No violation no-violation-message
With single violation with name <15 chars (shows violation) short-violation
With multiple violations or name >15 chars (shows "review required") multiple-violations-or-long-message

Fixed Issues

$ #32571

Tests

  • Verify that no errors appear in the JS console

Setup: Creating A Policy with Violations Test Cases

  1. Turn on the Violations beta (or set canUseViolations to true)

  2. Go to OldDot and open or create a Control policy

  3. Enable violations for the workspace in Settings > [Workspace] > Expenses

    1. Expense Violations: true
    2. Max Expense Amount: $10
  4. Make tags required for the policy

    1. Go to Settings > [Workspace] > Tags

    2. Enable "People must tag expenses"

    3. Add a tag
      5Enable the policy’s expense chat (reference link):

    4. Go to the policy page

    5. In the JS console with the policy open do:

      p = Policy.getCurrent();
      p.policy.isPolicyExpenseChatEnabled = "true";
      p.save();
    6. Invite a new user to the policy

    7. Sign into that new user account in New Dot

    8. Go through the money request flow, choosing the policy you just created and create the following money requests:

      Test Case Amount Tag
      No Violation $5 Yes
      Missing Tag (short message) $5 No
      Over Limit (long message) $20 Yes
  5. Check that the correct message is displayed

    1. Open the policy chat for the policy you created

    2. Touch the Report Preview for the report that contains your money requests

    3. The money requests should look as follows:

      Money Request Status Screenshot Expected Display
      No Violation no-violation-message Should look
      as

      in screenshot. No violation message displayed
      Missing Tag short-violation


      Should show "missing tag" message in light grey text at top
      Over Limit multiple-violations-or-long-message


      Should show "Review required in light grey text at top"

Offline tests

N/A - Should work as described above

QA Steps

Same as Testing steps above

  • Verify that no errors appear in the JS console

PR Author Checklist

  • I linked the correct issue in the ### Fixed Issues section above
  • I wrote clear testing steps that cover the changes made in this PR
    • I added steps for local testing in the Tests section
    • I added steps for the expected offline behavior in the Offline steps section
    • I added steps for Staging and/or Production testing in the QA steps section
    • I added steps to cover failure scenarios (i.e. verify an input displays the correct error message if the entered data is not correct)
    • I turned off my network connection and tested it while offline to ensure it matches the expected behavior (i.e. verify the default avatar icon is displayed if app is offline)
    • I tested this PR with a High Traffic account against the staging or
      production API to ensure there are no regressions (e.g. long loading states that impact usability).
  • I included screenshots or videos for tests on all platforms
  • I ran the tests on all platforms & verified they passed on:
    • Android: Native
    • Android: mWeb Chrome
    • iOS: Native
    • iOS: mWeb Safari
    • MacOS: Chrome / Safari
    • MacOS: Desktop
  • I verified there are no console errors (if there's a console error not related to the PR, report it or open an issue for it to be fixed)
  • I followed proper code patterns (see Reviewing the code)
    • I verified that any callback methods that were added or modified are named for what the method does and never what callback they handle (i.e. toggleReport and not onIconClick)
    • I verified that the left part of a conditional rendering a React component is a boolean and NOT a string, e.g. myBool && <MyComponent />.
    • I verified that comments were added to code that is not self explanatory
    • I verified that any new or modified comments were clear, correct English, and explained "why" the code was doing something instead of only explaining "what" the code was doing.
    • I verified any copy / text shown in the product is localized by adding it to src/languages/* files and using
      the translation method
    • I verified all numbers, amounts, dates and phone numbers shown in the product are using
      the localization methods
    • I verified any copy / text that was added to the app is grammatically correct in English. It adheres to proper capitalization guidelines (note: only the first word of header/labels
      should be capitalized), and is approved by marketing by adding the Waiting for Copy label for a copy review on the original GH to get the correct copy.
    • I verified proper file naming conventions were followed for any new files or renamed files. All non-platform specific files are named after what they export and are not named "
      index.js". All platform-specific files are named for the platform the code supports as outlined in the README.
    • I verified the JSDocs style guidelines (in STYLE.md) were followed
  • If a new code pattern is added I verified it was agreed to be used by multiple Expensify engineers
  • I followed the guidelines as stated in the Review Guidelines
  • I tested other components that can be impacted by my changes (i.e. if the PR modifies a shared library or component like Avatar, I verified the components using Avatar are working
    as expected)
  • I verified all code is DRY (the PR doesn't include any logic written more than once, with the exception of tests)
  • I verified any variables that can be defined as constants (ie. in CONST.js or at the top of the file that uses the constant) are defined as such
  • I verified that if a function's arguments changed that all usages have also been updated correctly
  • If any new file was added I verified that:
    • The file has a description of what it does and/or why is needed at the top of the file if the code is not self explanatory
  • If a new CSS style is added I verified that:
    • A similar style doesn't already exist
    • The style can't be created with an existing StyleUtils function (
      i.e. StyleUtils.getBackgroundAndBorderStyle(theme.componentBG))
  • If the PR modifies code that runs when editing or sending messages, I tested and verified there is no unexpected behavior for all supported markdown - URLs, single line code, code
    blocks, quotes, headings, bold, strikethrough, and italic.
  • If the PR modifies a generic component, I tested and verified that those changes do not break usages of that component in the rest of the App (i.e. if a shared library or component
    like Avatar is modified, I verified that Avatar is working as expected in all cases)
  • If the PR modifies a component related to any of the existing Storybook stories, I tested and verified all stories for that component are still working as expected.
  • If the PR modifies a component or page that can be accessed by a direct deeplink, I verified that the code functions as expected when the deeplink is used - from a logged in and logged
    out account.
  • If the PR modifies the form input styles:
    • I verified that all the inputs inside a form are aligned with each other.
    • I added Design label so the design team can review the changes.
  • If a new page is added, I verified it's using the ScrollView component to make it scrollable when more elements are added to the page.
  • If the main branch was merged into this PR after a review, I tested again and verified the outcome was still expected according to the Test steps.

Screenshots/Videos

Android: Native
No violation With single violation with name <15 chars With multiple violations or name >15 chars
no-violation-message short-violation multiple-violations-or-long-message
Android: mWeb Chrome
Without violation With single violation With multiple violations
no-violation short-violation long-violation
iOS: Native
Without violation With single violation With multiple violations
no-violation-full short-violation-full with violation full
iOS: mWeb Safari
Without violation With single violation With multiple violations
no-violations short-violations long-violations
MacOS: Chrome / Safari
Without violation
no-violation
With single violation
short-violation
With multiple violations
long-violation
MacOS: Desktop
Without violation With short violation With long violation
no-violation violation-short violation-long

…o trevor-coleman/violations/32571-money-request-preview
…71-money-request-preview

Trevor coleman/violations/32571 money request preview
…-preview

# Conflicts:
#	src/libs/ReportUtils.ts
#	src/libs/SidebarUtils.ts
#	src/libs/TransactionUtils.ts
#	src/libs/ViolationsUtils.ts
#	src/types/onyx/index.ts
#	tests/perf-test/SidebarUtils.perf-test.ts
…o 32571-money-request-preview

# Conflicts:
#	tests/perf-test/SidebarUtils.perf-test.ts
@trevor-coleman trevor-coleman changed the title 32571 money request preview Add violation message to MoneyRequestPreview Jan 4, 2024
@trevor-coleman trevor-coleman marked this pull request as ready for review January 11, 2024 19:29
@trevor-coleman trevor-coleman requested a review from a team as a code owner January 11, 2024 19:29
@melvin-bot melvin-bot bot removed the request for review from a team January 11, 2024 19:29
Copy link

melvin-bot bot commented Jan 11, 2024

@parasharrajat 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]

@melvin-bot melvin-bot bot requested a review from parasharrajat January 11, 2024 19:29
@cead22 cead22 requested a review from akinwale February 15, 2024 19:53
@akinwale
Copy link
Contributor

@trevor-coleman I am not able to get the over-limit violation despite having the Control policy set up according to the instructions in the test steps.

Screenshot 2024-02-15 at 21 22 05

Screen.Recording.2024-02-15.at.21.33.11.mp4

@situchan
Copy link
Contributor

@akinwale your account should have violations beta permission set in backend

@trevor-coleman
Copy link
Contributor Author

Which account are you using? I think @cead22 needs to enable violations for it in the back end.

@akinwale
Copy link
Contributor

akinwale commented Feb 15, 2024

@trevor-coleman A couple of things I noticed from my testing (video included).

  1. For the over-limit violation, the error message and the red dot do not show up until I actually open IOU report and then navigate back to the expense report. Is this intended?
  2. When there are two violations (missing tag and over-limit), only the over-limit error is shown on the IOU report. I would assume that both errors should be visible here. Actually, looks like the missing tag error is not displayed on the IOU report at all, even if it's just the tag missing, so that's out of scope here.
33969-web.mp4

@trevor-coleman
Copy link
Contributor Author

trevor-coleman commented Feb 15, 2024

For the over-limit violation, the error message and the red dot do not show up until I actually open IOU report and then navigate back to the expense report. Is this intended?

This is a known issue outside the scope of this PR -- I believe it should be fixed when the optimistic update PR is merged.

When there are two violations (missing tag and over-limit), only the over-limit error is shown on the IOU report. I would assume that both errors should be visible here.

The spec for this is:

  1. For a single violation:
    • if the message is less than 15 characters, then show that violation message
    • if the message is more than 15 characters, then show a generic "Review Required" message
  2. For multiple violations always show "Review Required"

The only violation shorter than 15 characters (in English) is missingTag all the rest are longer, so this is the expected behaviour.

@akinwale
Copy link
Contributor

The spec for this is:

  1. For a single violation:

    • if the message is less than 15 characters, then show that violation message
    • if the message is more than 15 characters, then show a generic "Review Required" message
  2. For multiple violations always show "Review Required"

The only violation shorter than 15 characters (in English) is missingTag all the rest are longer, so this is the expected behaviour.

I understand this part (for the preview). I was referring to the actual report itself, which is open after clicking the preview, but I realise that is out of scope here.

Everything looks good!

@trevor-coleman
Copy link
Contributor Author

Awesome! Yeah the report itself is going to be fixed elsewhere -- right now it only updates when data is fetched from the server, but when the optimistiic updates stuff gets merged then we'll calculate them on the fly.

@akinwale
Copy link
Contributor

Reviewer Checklist

  • I have verified the author checklist is complete (all boxes are checked off).
  • I verified the correct issue is linked in the ### Fixed Issues section above
  • I verified testing steps are clear and they cover the changes made in this PR
    • I verified the steps for local testing are in the Tests section
    • I verified the steps for Staging and/or Production testing are in the QA steps section
    • I verified the steps cover any possible failure scenarios (i.e. verify an input displays the correct error message if the entered data is not correct)
    • I turned off my network connection and tested it while offline to ensure it matches the expected behavior (i.e. verify the default avatar icon is displayed if app is offline)
  • I checked that screenshots or videos are included for tests on all platforms
  • I included screenshots or videos for tests on all platforms
  • I verified tests pass on all platforms & I tested again on:
    • Android: Native
    • Android: mWeb Chrome
    • iOS: Native
    • iOS: mWeb Safari
    • MacOS: Chrome / Safari
    • MacOS: Desktop
  • If there are any errors in the console that are unrelated to this PR, I either fixed them (preferred) or linked to where I reported them in Slack
  • I verified proper code patterns were followed (see Reviewing the code)
    • I verified that any callback methods that were added or modified are named for what the method does and never what callback they handle (i.e. toggleReport and not onIconClick).
    • I verified that the left part of a conditional rendering a React component is a boolean and NOT a string, e.g. myBool && <MyComponent />.
    • I verified that comments were added to code that is not self explanatory
    • I verified that any new or modified comments were clear, correct English, and explained "why" the code was doing something instead of only explaining "what" the code was doing.
    • I verified any copy / text shown in the product is localized by adding it to src/languages/* files and using the translation method
    • I verified all numbers, amounts, dates and phone numbers shown in the product are using the localization methods
    • I verified any copy / text that was added to the app is grammatically correct in English. It adheres to proper capitalization guidelines (note: only the first word of header/labels should be capitalized), and is approved by marketing by adding the Waiting for Copy label for a copy review on the original GH to get the correct copy.
    • I verified proper file naming conventions were followed for any new files or renamed files. All non-platform specific files are named after what they export and are not named "index.js". All platform-specific files are named for the platform the code supports as outlined in the README.
    • I verified the JSDocs style guidelines (in STYLE.md) were followed
  • If a new code pattern is added I verified it was agreed to be used by multiple Expensify engineers
  • I verified that this PR follows the guidelines as stated in the Review Guidelines
  • I verified other components that can be impacted by these changes have been tested, and I retested again (i.e. if the PR modifies a shared library or component like Avatar, I verified the components using Avatar have been tested & I retested again)
  • I verified all code is DRY (the PR doesn't include any logic written more than once, with the exception of tests)
  • I verified any variables that can be defined as constants (ie. in CONST.js or at the top of the file that uses the constant) are defined as such
  • If a new component is created I verified that:
    • A similar component doesn't exist in the codebase
    • All props are defined accurately and each prop has a /** comment above it */
    • The file is named correctly
    • The component has a clear name that is non-ambiguous and the purpose of the component can be inferred from the name alone
    • The only data being stored in the state is data necessary for rendering and nothing else
    • For Class Components, any internal methods passed to components event handlers are bound to this properly so there are no scoping issues (i.e. for onClick={this.submit} the method this.submit should be bound to this in the constructor)
    • Any internal methods bound to this are necessary to be bound (i.e. avoid this.submit = this.submit.bind(this); if this.submit is never passed to a component event handler like onClick)
    • All JSX used for rendering exists in the render method
    • The component has the minimum amount of code necessary for its purpose, and it is broken down into smaller components in order to separate concerns and functions
  • If any new file was added I verified that:
    • The file has a description of what it does and/or why is needed at the top of the file if the code is not self explanatory
  • If a new CSS style is added I verified that:
    • A similar style doesn't already exist
    • The style can't be created with an existing StyleUtils function (i.e. StyleUtils.getBackgroundAndBorderStyle(theme.componentBG)
  • If the PR modifies code that runs when editing or sending messages, I tested and verified there is no unexpected behavior for all supported markdown - URLs, single line code, code blocks, quotes, headings, bold, strikethrough, and italic.
  • If the PR modifies a generic component, I tested and verified that those changes do not break usages of that component in the rest of the App (i.e. if a shared library or component like Avatar is modified, I verified that Avatar is working as expected in all cases)
  • If the PR modifies a component related to any of the existing Storybook stories, I tested and verified all stories for that component are still working as expected.
  • If the PR modifies a component or page that can be accessed by a direct deeplink, I verified that the code functions as expected when the deeplink is used - from a logged in and logged out account.
  • If the PR modifies the form input styles:
    • I verified that all the inputs inside a form are aligned with each other.
    • I added Design label so the design team can review the changes.
  • If a new page is added, I verified it's using the ScrollView component to make it scrollable when more elements are added to the page.
  • If the main branch was merged into this PR after a review, I tested again and verified the outcome was still expected according to the Test steps.
  • I have checked off every checkbox in the PR reviewer checklist, including those that don't apply to this PR.

Screenshots/Videos

Android: Native

33969-android-native

Android: mWeb Chrome

33969-android-chrome

iOS: Native

33969-ios-native

iOS: mWeb Safari

33969-ios-safari

MacOS: Chrome / Safari
33969-web.mp4
MacOS: Desktop

33969-desktop

Copy link
Contributor

@akinwale akinwale left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM.

@melvin-bot melvin-bot bot requested a review from cead22 February 15, 2024 21:21
@@ -2303,8 +2303,8 @@ export default {
overLimitAttendee: ({formattedLimit}: ViolationsOverLimitParams) => `Amount over ${formattedLimit}/person limit`,
perDayLimit: ({formattedLimit}: ViolationsPerDayLimitParams) => `Amount over daily ${formattedLimit}/person category limit`,
receiptNotSmartScanned: 'Receipt not verified. Please confirm accuracy.',
receiptRequired: ({formattedLimit, category}: ViolationsReceiptRequiredParams = {}) =>
`Receipt required${formattedLimit ? ` over ${formattedLimit}${category ? ' category limit' : ''}` : ''}`,
receiptRequired: (params: ViolationsReceiptRequiredParams) => `Receipt required${params ? ` over ${params.formattedLimit}${params.category ? ` category limit` : ''}` : ''}`,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a reason for this change? I see we didn't make the same change in the es.ts file, can we undo this?

Copy link
Contributor Author

@trevor-coleman trevor-coleman Feb 16, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We discussed it here: https://expensify.slack.com/archives/C01GTK53T8Q/p1704823942664409?thread_ts=1704302068.776969&cid=C01GTK53T8Q

I've updated them to be like this:

Params English Translation Spanish Translation
No params Receipt required Recibo obligatorio
{ formattedLimit: '$500' } Receipt required over $500 Recibo obligatorio para importes sobre $500
{ category: 'travel' } Receipt required over travel category limit Recibo obligatorio para importes sobre el límite de la categoría
{ formattedLimit: '$500', category: 'travel' } Receipt required over $500 travel category limit Recibo obligatorio para importes sobre $500 el límite de la categoría

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@trevor-coleman @cead22 Coming from this issue #44220 Can you confirm why we don't mention category name on the Spanish translation while we mention it on English translation? Are this intended? or we should fix it.
CC @abzokhattab

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We're not showing the category name in either case. We should say literally "category limit" or "límite de la categoría"

Copy link
Contributor

@ahmedGaber93 ahmedGaber93 Jun 25, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should say literally "category limit" or "límite de la categoría"

@cead22 is this mean the above table is not correct? because it showing the category name "travel" in English translation

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think so. To be honest, I don't remember noticing the "travel" in "travel category limit" in there

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The above line use params to check before showing word over which display over undefined if params = {formattedLimit: undefined, category: undefined} and we fixed it here #44220

src/libs/ErrorUtils.ts Outdated Show resolved Hide resolved
cead22
cead22 previously approved these changes Feb 16, 2024
Copy link
Contributor

@cead22 cead22 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tested on desktop web and desktop native and it worked fine

@cead22 cead22 merged commit d28f86f into Expensify:main Feb 17, 2024
16 checks passed
@OSBotify
Copy link
Contributor

✋ This PR was not deployed to staging yet because QA is ongoing. It will be automatically deployed to staging after the next production release.

@OSBotify
Copy link
Contributor

🚀 Deployed to staging by https://github.com/cead22 in version: 1.4.43-0 🚀

platform result
🤖 android 🤖 success ✅
🖥 desktop 🖥 success ✅
🍎 iOS 🍎 success ✅
🕸 web 🕸 success ✅

@OSBotify
Copy link
Contributor

🚀 Deployed to production by https://github.com/puneetlath in version: 1.4.43-20 🚀

platform result
🤖 android 🤖 success ✅
🖥 desktop 🖥 success ✅
🍎 iOS 🍎 success ✅
🕸 web 🕸 success ✅

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

10 participants