[CP Staging]: Avoid hiding pay/approve buttons in case of held violations#53176
Conversation
|
@abdulrahuman5196 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] |
src/libs/ReportUtils.ts
Outdated
| */ | ||
| function hasNonHoldViolations(reportID: string, transactionViolations: OnyxCollection<TransactionViolation[]>, shouldShowInReview?: boolean): boolean { | ||
| const transactions = reportsTransactions[reportID] ?? []; | ||
| return transactions.some((transaction) => TransactionUtils.hasViolation(transaction.transactionID, transactionViolations, shouldShowInReview) && !TransactionUtils.isOnHold(transaction)); |
There was a problem hiding this comment.
I think it will cause a weird behavior when a transaction has violations, but if we put it on-hold, we can approve it.
Screen.Recording.2024-11-27.at.06.30.02.mov
There was a problem hiding this comment.
We may need to filter out hold transactions here if it has not only held transactions
const transactions = reportsTransactions[reportID] ?? [];
There was a problem hiding this comment.
good catch .. i have tackled this point in this commit 2ff9810
|
Hi @abdulrahuman5196. This DB comes from our PR so let me handle this PR as a regression bug. |
src/libs/actions/IOU.ts
Outdated
| const isArchivedReport = ReportUtils.isArchivedRoom(iouReport, reportNameValuePairs); | ||
| const allViolations = violations ?? allTransactionViolations; | ||
| const hasViolations = ReportUtils.hasViolations(iouReport?.reportID ?? '-1', allViolations); | ||
| const hasNonHeldViolations = ReportUtils.hasViolations(iouReport?.reportID ?? '-1', allViolations) && !ReportUtils.hasOnlyHeldExpenses(iouReport?.reportID ?? '-1'); |
There was a problem hiding this comment.
@abzokhattab I don't think it's a correct fix. A nonHeldExpense has violations but if there is a held expense, it will bypass and show the approve button.
There was a problem hiding this comment.
ops i thought that's what you meant by this comment #53176 (comment) ...
thinking about it ..
There was a problem hiding this comment.
What do you think about?
const transactions = reportsTransactions[reportID] ?? [];
const transactionViolationsFiltered = transactionViolations.filter(x => x.name !== VIOLATIONS.HOLD)
return transactions.some((transaction) => TransactionUtils.hasViolation(transaction.transactionID, transactionViolationsFiltered, shouldShowInReview));There was a problem hiding this comment.
or we can use previous implementation, but define another method TransactionUtils.hasNonHoldViolations and we filter hold violation in that method.
There was a problem hiding this comment.
i was thinking about the second approach ... I believe it would be better in case we need that functionality elsewhere in the future, as it would be more maintainable.
Screen.Recording.2024-11-27.at.14.35.03.mov
There was a problem hiding this comment.
There are a lot of unrelated changes. Can you revert them?
There was a problem hiding this comment.
Its just for reorganizing the exports to be alphabetically ordered ... its just cleaner and easier to read ... let me know if you still think we need to revert them
i dont see other unrelated changes
|
@abzokhattab please add a prefix "[CP Staging]" in the PR title if it's a DB fix. |
Reviewer Checklist
Screenshots/VideosAndroid: NativeScreen.Recording.2024-11-27.at.21.42.06.android.movAndroid: mWeb ChromeScreen.Recording.2024-11-27.at.21.47.17.android.chrome.moviOS: NativeScreen.Recording.2024-11-27.at.21.48.22.ios.moviOS: mWeb SafariScreen.Recording.2024-11-27.at.21.49.59.ios.safari.movMacOS: Chrome / SafariScreen.Recording.2024-11-27.at.21.32.58.web.movMacOS: DesktopScreen.Recording.2024-11-27.at.21.38.21.desktop.mov |
|
@abzokhattab can you add recording for Desktop too? Thanks |
src/libs/ReportUtils.ts
Outdated
| /** | ||
| * Checks to see if a report contains non-hold violations | ||
| */ | ||
| function hasNonHoldViolations(reportID: string, transactionViolations: OnyxCollection<TransactionViolation[]>, shouldShowInReview?: boolean): boolean { |
There was a problem hiding this comment.
NAB: technically you just care about one violation
| function hasNonHoldViolations(reportID: string, transactionViolations: OnyxCollection<TransactionViolation[]>, shouldShowInReview?: boolean): boolean { | |
| function hasNonHoldViolation(reportID: string, transactionViolations: OnyxCollection<TransactionViolation[]>, shouldShowInReview?: boolean): boolean { |
src/libs/actions/IOU.ts
Outdated
| const isArchivedReport = ReportUtils.isArchivedRoom(iouReport, reportNameValuePairs); | ||
| const allViolations = violations ?? allTransactionViolations; | ||
| const hasViolations = ReportUtils.hasViolations(iouReport?.reportID ?? '-1', allViolations); | ||
| const hasNonHeldViolations = ReportUtils.hasNonHoldViolations(iouReport?.reportID ?? '-1', allViolations); |
There was a problem hiding this comment.
Lets call it hold as in other places
| const hasNonHeldViolations = ReportUtils.hasNonHoldViolations(iouReport?.reportID ?? '-1', allViolations); | |
| const hasNonHoldViolations = ReportUtils.hasNonHoldViolations(iouReport?.reportID ?? '-1', allViolations); |
|
✋ This PR was not deployed to staging yet because QA is ongoing. It will be automatically deployed to staging after the next production release. |
…en-violations-are-held (cherry picked from commit 9014956) (CP triggered by mountiny)
|
🚀 Cherry-picked to staging by https://github.com/mountiny in version: 9.0.67-4 🚀
@Expensify/applauseleads please QA this PR and check it off on the deploy checklist if it passes. |
|
🚀 Deployed to production by https://github.com/mountiny in version: 9.0.67-9 🚀
|
|
🚀 Cherry-picked to staging by https://github.com/mountiny in version: 9.0.68-0 🚀
@Expensify/applauseleads please QA this PR and check it off on the deploy checklist if it passes. |
|
🚀 Deployed to production by https://github.com/mountiny in version: 9.0.68-7 🚀
|
Explanation of Change
Fixed Issues
$ #53166
PROPOSAL: #53166 (comment)
Tests
Offline tests
Same as tests
QA Steps
Same as tests
PR Author Checklist
### Fixed Issuessection aboveTestssectionOffline stepssectionQA stepssectiontoggleReportand notonIconClick)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-11-26.at.23.08.30.mov
Android: mWeb Chrome
Screen.Recording.2024-11-26.at.23.16.44.mov
iOS: Native
Screen.Recording.2024-11-26.at.23.07.14.mov
iOS: mWeb Safari
Screen.Recording.2024-11-26.at.23.08.18.mov
MacOS: Chrome / Safari
Screen.Recording.2024-11-26.at.22.41.34.mov
MacOS: Desktop