Repository navigation
Show an Approve anyway confirmation for report violations #106274
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
base: main
Are you sure you want to change the base?
Changes from 3 commits
a4b5c79
c5fa640
05fa661
7a106c4
793e960
84ec42d
c13ec58
57a6c9d
cb83f22
4860181
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -13,6 +13,7 @@ import ListItemComposed from '@components/SelectionList/ListItemComposed'; | |||||||||||
| import type {ListItem} from '@components/SelectionList/types'; | ||||||||||||
| import Text from '@components/Text'; | ||||||||||||
|
|
||||||||||||
| import useConfirmApproveReportViolations from '@hooks/useConfirmApproveReportViolations'; | ||||||||||||
| import useConfirmModal from '@hooks/useConfirmModal'; | ||||||||||||
| import useConfirmSubmitReportViolations from '@hooks/useConfirmSubmitReportViolations'; | ||||||||||||
| import {useCurrencyListActions} from '@hooks/useCurrencyList'; | ||||||||||||
|
|
@@ -219,6 +220,12 @@ function ExpenseReportListItemInner<TItem extends ListItem>({ | |||||||||||
| const beginSearchActionPress = useSearchActionPress(); | ||||||||||||
| const {transactions: reportTransactions, violations: reportViolations} = useTransactionsAndViolationsForReport(reportItem.reportID); | ||||||||||||
| const liveReportTransactions = Object.values(reportTransactions); | ||||||||||||
| const confirmApproveReportViolations = useConfirmApproveReportViolations({ | ||||||||||||
| report: reportForViolations, | ||||||||||||
| policy: policyForViolations, | ||||||||||||
| transactions: liveReportTransactions, | ||||||||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The row and 'Approve anyway?' modal can be different. If a report hasn't been opened yet, its expenses only come from the Search results, not from what's loaded locally. The row still shows the violation, but the modal only checks the loaded expenses, finds none, and approves straight away with no warning.
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Make sense. @MelvinBot Merge main + fix
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🤖 Web test steps verification results: ❌ fail Merged latest
view run · no recording available |
||||||||||||
| violationsCollection: reportViolations, | ||||||||||||
| }); | ||||||||||||
| const confirmSubmitReportViolations = useConfirmSubmitReportViolations({ | ||||||||||||
| reportID: reportItem.reportID, | ||||||||||||
| report: reportForViolations, | ||||||||||||
|
|
@@ -276,6 +283,7 @@ function ExpenseReportListItemInner<TItem extends ListItem>({ | |||||||||||
| onDelegateAccessRestricted: showDelegateNoAccessModal, | ||||||||||||
| personalPolicyID, | ||||||||||||
| confirmSubmitReportViolations, | ||||||||||||
| confirmApproveReportViolations, | ||||||||||||
| ownerBillingGracePeriodEnd, | ||||||||||||
| openReportSubmitToPopover, | ||||||||||||
| onPendingCardTransactionsBlock: () => showPendingCardTransactionsBlockModal(showConfirmModal, translate, shouldShowMarkAsDoneCopy), | ||||||||||||
|
|
||||||||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,43 @@ | ||
| /** Confirms locally available violations before approval, preserving offline behavior. */ | ||
| import confirmApproveViolationsThenProceed from '@libs/Violations/confirmApproveViolationsThenProceed'; | ||
| import getReportApproveViolationSummary from '@libs/Violations/getReportApproveViolationSummary'; | ||
|
|
||
| import type {Policy, Report, Transaction, TransactionViolations} from '@src/types/onyx'; | ||
|
|
||
| import type {OnyxCollection, OnyxEntry} from 'react-native-onyx'; | ||
|
|
||
| import useConfirmModal from './useConfirmModal'; | ||
| import {useCurrencyListActions} from './useCurrencyList'; | ||
| import useCurrentUserPersonalDetails from './useCurrentUserPersonalDetails'; | ||
| import useLocalize from './useLocalize'; | ||
| import useTransactionsAndViolationsForReport from './useTransactionsAndViolationsForReport'; | ||
|
|
||
| type UseConfirmApproveReportViolationsParams = { | ||
| report: OnyxEntry<Report>; | ||
| policy: OnyxEntry<Policy>; | ||
| transactions?: Array<OnyxEntry<Transaction>>; | ||
| violationsCollection?: OnyxCollection<TransactionViolations>; | ||
| }; | ||
|
|
||
| function useConfirmApproveReportViolations({report, policy, transactions: transactionsOverride, violationsCollection: violationsOverride}: UseConfirmApproveReportViolationsParams) { | ||
| const {showConfirmModal} = useConfirmModal(); | ||
| const {translate, dateFnsLocale} = useLocalize(); | ||
| const {convertToDisplayString} = useCurrencyListActions(); | ||
| const {accountID, email} = useCurrentUserPersonalDetails(); | ||
| const {transactions: ownedTransactions, violations: ownedViolations} = useTransactionsAndViolationsForReport(transactionsOverride ? undefined : report?.reportID); | ||
|
|
||
| return (onProceed: () => void, full = true) => { | ||
| const summary = getReportApproveViolationSummary( | ||
| transactionsOverride ?? Object.values(ownedTransactions), | ||
| violationsOverride ?? ownedViolations, | ||
| report, | ||
| policy, | ||
| email ?? '', | ||
| accountID, | ||
| full, | ||
| ); | ||
| confirmApproveViolationsThenProceed({summary, showConfirmModal, translate, dateFnsLocale, convertToDisplayString, onProceed}); | ||
| }; | ||
| } | ||
|
|
||
| export default useConfirmApproveReportViolations; |
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.
Pass the user-visible, filtered violation collection to the confirmation instead of the raw Onyx entries. When a violation has been dismissed through
transaction.comment.dismissedViolations,getReportSubmitViolationSummary()only appliesshouldShowViolation()and therefore adds the dismissed violation to the modal, even thoughuseTransactionsAndViolationsForReport()normally removes it. This makes the report-header and Search approval buttons repeatedly warn about violations the user has already dismissed; the hold-menu and bulk-approval paths similarly pass raw collections and need the same filtering.Useful? React with 👍 / 👎.
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.
Make sense. @MelvinBot pls fix
This comment was marked as off-topic.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.