-
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
Fix violation shows optimistically for a partial transaction #39034
Fix violation shows optimistically for a partial transaction #39034
Conversation
Reviewer Checklist
Screenshots/VideosMacOS: Chrome / Safari0-web-1.mp40-web-2.mp4MacOS: Desktop0-desktop-1.mp40-desktop-2.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.
Tested well and looks good!
): OnyxUpdate | null { | ||
const isPartialTransaction = TransactionUtils.isPartialMerchant(TransactionUtils.getMerchant(updatedTransaction)) && TransactionUtils.isAmountMissing(updatedTransaction); | ||
if (isPartialTransaction) { | ||
return null; |
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.
Can we move this logic under let newTransactionViolations = [...transactionViolations];
and return the following if the transaction is partial? I think if we do that we don't need any of the other changes and the logic is simpler
return {
onyxMethod: Onyx.METHOD.SET,
key: `${ONYXKEYS.COLLECTION.TRANSACTION_VIOLATIONS}${updatedTransaction.transactionID}`,
value: newTransactionViolations,
};
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.
That's nice. Updated. Btw, do you think we can just return an empty array instead? Is it possible a transaction already has a violation while it's still a partial transaction?
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.
It shouldn't, but the effect should be the same, 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.
If it's not possible then yes, the effect is the same.
tests/unit/ViolationUtilsTest.ts
Outdated
const partialTransaction = {...transaction, amount: 0, merchant: CONST.TRANSACTION.PARTIAL_TRANSACTION_MERCHANT}; | ||
transactionViolations = [ | ||
{name: 'duplicatedTransaction', type: 'violation'}, | ||
{name: 'receiptRequired', type: 'violation'}, |
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.
Let's use consts for this. I think we need to add one for duplicatedTransaction
{name: 'receiptRequired', type: 'violation'}, | |
{name: CONST.VIOLATIONS.RECEIPT_REQUIRED, type: 'violation'}, |
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 have updated the test to not have an existing violation for partial transaction anymore
Conflicts |
Conflicts solved (conflicted with an import) and updated the unit test to reflect the correct behavior. |
@cead22 looks like this was merged without a test passing. Please add a note explaining why this was done and remove the |
Not an emergency, we have a bug adding this label that we're working on fixing |
✋ 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.59-0 🚀
|
🚀 Deployed to production by https://github.com/Julesssss in version: 1.4.60-13 🚀
|
Details
We want to change the behavior so the violations are not added optimistically when it's a partial transaction.
Fixed Issues
$ #38131
PROPOSAL: #38131 (comment)
Tests
Same as QA Steps
Offline tests
Same as QA Steps
QA Steps
Prerequisites:
PR Author Checklist
### Fixed Issues
section aboveTests
sectionOffline steps
sectionQA steps
sectiontoggleReport
and notonIconClick
)myBool && <MyComponent />
.src/languages/*
files and using the translation methodSTYLE.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 and/or tagged@Expensify/design
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
Android: Native
Screen.Recording.2024-03-27.at.13.56.49.mov
Screen.Recording.2024-03-27.at.13.59.39.mov
Android: mWeb Chrome
Screen.Recording.2024-03-27.at.14.26.48.mov
Screen.Recording.2024-03-27.at.14.31.55.mov
iOS: Native
Screen.Recording.2024-03-27.at.13.57.39.mov
Screen.Recording.2024-03-27.at.14.00.40.mov
iOS: mWeb Safari
Screen.Recording.2024-03-27.at.13.48.50.mov
Screen.Recording.2024-03-27.at.13.52.12.mov
MacOS: Chrome / Safari
Screen.Recording.2024-03-27.at.13.10.27.mov
Screen.Recording.2024-03-27.at.13.12.10.mov
MacOS: Desktop
Screen.Recording.2024-03-27.at.13.11.12.mov
Screen.Recording.2024-03-27.at.13.14.18.mov