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 |
eh2077
left a comment
There was a problem hiding this comment.
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.
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.
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.
It shouldn't, but the effect should be the same, right?
There was a problem hiding this comment.
If it's not possible then yes, the effect is the same.
| 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.
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.
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 Issuessection aboveTestssectionOffline stepssectionQA stepssectiontoggleReportand notonIconClick)myBool && <MyComponent />.src/languages/*files and using the translation methodSTYLE.md) were followedAvatar, I verified the components usingAvatarare working as expected)StyleUtils.getBackgroundAndBorderStyle(theme.componentBG))Avataris modified, I verified thatAvataris working as expected in all cases)Designlabel and/or tagged@Expensify/designso the design team can review the changes.ScrollViewcomponent to make it scrollable when more elements are added to the page.mainbranch was merged into this PR after a review, I tested again and verified the outcome was still expected according to theTeststeps.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