-
Notifications
You must be signed in to change notification settings - Fork 3k
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
Adds Client-side Violations when creating money requests #32528
Adds Client-side Violations when creating money requests #32528
Conversation
…m:infinitered/ExpensifyApp into cdanwards/violations/money-request-violations
…ards/violations/money-request-violations
…ards/violations/money-request-violations
…ards/violations/money-request-violations
@cead22 This is ready for review! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@mollfpr please review this and complete the reviewer checklist when you get a chance
}), | ||
// eslint-disable-next-line rulesdir/no-multiple-onyx-in-file | ||
withOnyx({ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why remove this? I think this is wrong, because having a separate withOnyx makes the keys in it "dependent" on the values of the previous withOnyx, right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wasn't aware of this! I'll ask in the open-source channel, but I'm happy to change this back.
policy: { | ||
key: ({report}) => `${ONYXKEYS.COLLECTION.POLICY}${report ? report.policyID : '0'}`, | ||
}, | ||
policyCategories: { | ||
key: ({policy}) => `${ONYXKEYS.COLLECTION.POLICY_CATEGORIES}${policy ? policy.id : '0'}`, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When/why can this be called without a policy?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So it looks that when this file is converted to TS that the policy
will be of the OnyxEntry
type which could return null so this was just to go ahead and account for that. Once it is converted it can easily just be replaced with optional chaining like policy?.id
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I asked about the multiple withOnyx
thing from the comment above on slack
So it looks that when this file is converted to TS that the
policy
will be of theOnyxEntry
type which could return null so this was just to go ahead and account for that
But is it possible that this is because these are no longer defined in a separate withOnyx
?
Co-authored-by: Carlos Alvarez <[email protected]>
Co-authored-by: Carlos Alvarez <[email protected]>
Co-authored-by: Carlos Alvarez <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Leave some suggestions based on the policy
keys.
@cdanwards I can't access the Slack link to see the instruction, could you put it here? Thanks!
@mollfpr no worries! Let me grab that slack conversation. |
Co-authored-by: Luthfi <[email protected]>
Co-authored-by: Luthfi <[email protected]>
Co-authored-by: Luthfi <[email protected]>
Co-authored-by: Luthfi <[email protected]>
@mollfpr can you please re-review, re-test this when you get a chance? |
This comment was marked as resolved.
This comment was marked as resolved.
…s/money-request-violations
…s/money-request-violations
@mollfpr This should be reviewable now! |
Reviewer Checklist
Screenshots/VideosAndroid: NativeAndroid: mWeb Chrome32528.mWeb-Chrome.-.1.mp432528.mWeb-Chrome.-.2.mp432528.mWeb-Chrome.-.3.mp432528.mWeb-Chrome.-.4.-.6.mp4iOS: Native32528.iOS.-.4.-.6.mp4iOS: mWeb Safari32528.mWeb-Safari.-.1.mp432528.mWeb-Safari.-.2.mp432528.mWeb-Safari.-.3.mp432528.mWeb-Safari.-.4.-.6.mp4MacOS: Chrome / Safari32528.Web.-.1.mp432528.Web.-.2.mp432528.Web.-.3.mp432528.Web.-.4.mp432528.Web.-.1.Offline.mp432528.Desktop.-.6.mp4MacOS: Desktop32528.Desktop.-.1.mp432528.Desktop.-.2.mp432528.Desktop.-.3.mp432528.Desktop.-.4.mp432528.Desktop.-.6.mp4 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
All yours @cead22
…s/money-request-violations
Seeing |
The Android videos were outdated, and I tried running the app on android but I was getting an error. @mollfpr ran this on native iOS (sim) after merging main into this branch (here) and things worked. I also tested on web and things worked, so I'm merging to avoid this getting more conflicts tomorrow |
✋ This PR was not deployed to staging yet because QA is ongoing. It will be automatically deployed to staging after the next production release. |
🚀 Deployed to staging by https://github.com/cead22 in version: 1.4.23-0 🚀
|
@cdanwards Could you help us with the steps 4,5 and 6 in "What to test" section? |
@kavimuru May I help you with the problem? |
@mollfpr where do we have to check "You should NOT see a corresponding transactionViolations_ object. |
@kavimuru The object is on the browser storage, so we can only verify it on the Web. You can see the below video on how to get there. Screen.Recording.2024-01-09.at.20.52.27.mp4 |
🚀 Deployed to production by https://github.com/thienlnam in version: 1.4.23-4 🚀
|
return [optimisticData, successData, failureData]; | ||
} | ||
|
||
const violationsOnyxData = ViolationsUtils.getViolationsOnyxData(transaction, [], policy.requiresTag, policyTags, policy.requiresCategory, policyCategories); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This PR caused a regression #38131 as we don't want to show those violations when a transaction is a "partial transaction", see also #38131 (comment)
So, we need to add a check for partial transactions when adding violations data.
Fixed Issues
$ #31092
PROPOSAL:
This is another addition to bringing the Violations functionality to New Expensify. This PR addresses building the required client side onyx data for violations when creating a money request.
Tests
General Tests
Setup:
Settings
>Categories
and verify thatPeople must categorize expenses
is enabled, and make sure there's at least one category on the policySettings
>Tags
and verify thatPeople must tag expenses
is enabled, and make sure there's at least one tag enabled on the policyTesting the code worked correctly
ONYXDB
->keyvaluepairs
within your browser storage tabtransactions_someID
. If you open chrome dev tools before making the money request, you can inspect the response which should have thetransactionID
transactionViolations_SameIDasTransaction
, with themissingCategory
andmissingTag
violations in the array (unless the test says otherwise)What to test
transactionViolations_
object.transactionViolations_
object.transactionViolations_
object.Offline tests
For each test that generates a
transactionViolations_
object, test it offline as well. The results should be the same.QA Steps
Same as tests, both online and offline
PR Author Checklist
### Fixed Issues
section aboveTests
sectionOffline steps
sectionQA steps
sectiontoggleReport
and notonIconClick
)myBool && <MyComponent />
.src/languages/*
files and using the translation methodWaiting for Copy
label for a copy review on the original GH to get the correct copy.STYLE.md
) were followedAvatar
, I verified the components usingAvatar
are working as expected)StyleUtils.getBackgroundAndBorderStyle(theme.componentBG)
)Avatar
is modified, I verified thatAvatar
is working as expected in all cases)Design
label so the design team can review the changes.ScrollView
component to make it scrollable when more elements are added to the page.main
branch was merged into this PR after a review, I tested again and verified the outcome was still expected according to theTest
steps.Screenshots/Videos
No visible changes are expected at this point; violations are not yet displayed in the app.
Android: Native
Android: mWeb Chrome
iOS: Native
iOS: mWeb Safari
MacOS: Chrome / Safari
MacOS: Desktop