From 9467b3a7f068b071f380ae36a3e39aeeb607b1e1 Mon Sep 17 00:00:00 2001 From: Krishna Gupta Date: Wed, 6 Mar 2024 13:35:59 +0530 Subject: [PATCH 01/34] feat: Receipt Audit Feature / Note type violations. Signed-off-by: Krishna Gupta --- src/components/ReceiptAudit.tsx | 33 +++++++++++++++++++ .../ReportActionItem/MoneyRequestView.tsx | 4 +++ src/styles/index.ts | 13 ++++++++ 3 files changed, 50 insertions(+) create mode 100644 src/components/ReceiptAudit.tsx diff --git a/src/components/ReceiptAudit.tsx b/src/components/ReceiptAudit.tsx new file mode 100644 index 000000000000..af8c063668e1 --- /dev/null +++ b/src/components/ReceiptAudit.tsx @@ -0,0 +1,33 @@ +import React from 'react'; +import {View} from 'react-native'; +import useTheme from '@hooks/useTheme'; +import useThemeStyles from '@hooks/useThemeStyles'; +import Icon from './Icon'; +import * as Expensicons from './Icon/Expensicons'; +import Text from './Text'; + +export default function ReceiptAudit({notes}: {notes: string[]}) { + const styles = useThemeStyles(); + const theme = useTheme(); + + return ( + + + + 0 ? Expensicons.Receipt : Expensicons.Checkmark} + fill={theme.white} + /> + + {notes.length > 0 ? `Receipt Audit : ${notes.length} Issue(s) Found` : 'Receipt Verified : No issues Found'} + + + + + {/* // If notes is a array of strings, map through it & show notes. */} + {notes.length > 0 && notes.map((message) => {message})} + + ); +} diff --git a/src/components/ReportActionItem/MoneyRequestView.tsx b/src/components/ReportActionItem/MoneyRequestView.tsx index 0bd18d8ee7ea..234aa4465d40 100644 --- a/src/components/ReportActionItem/MoneyRequestView.tsx +++ b/src/components/ReportActionItem/MoneyRequestView.tsx @@ -6,6 +6,7 @@ import ConfirmedRoute from '@components/ConfirmedRoute'; import * as Expensicons from '@components/Icon/Expensicons'; import MenuItemWithTopDescription from '@components/MenuItemWithTopDescription'; import OfflineWithFeedback from '@components/OfflineWithFeedback'; +import ReceiptAudit from '@components/ReceiptAudit'; import ReceiptEmptyState from '@components/ReceiptEmptyState'; import SpacerView from '@components/SpacerView'; import Switch from '@components/Switch'; @@ -285,6 +286,9 @@ function MoneyRequestView({ } /> )} + + + {canUseViolations && } borderWidth: 1, }, + receiptAuditTitleContainer: { + flexDirection: 'row', + gap: 4, + padding: 4, + paddingHorizontal: 8, + height: variables.inputHeightSmall, + borderRadius: variables.componentBorderRadiusSmall, + display: 'flex', + justifyContent: 'center', + alignItems: 'center', + backgroundColor: theme.border, + }, + mapViewContainer: { ...flex.flex1, minHeight: 300, From 8c400c3fae12d28f95ded76a52806e92ec54f740 Mon Sep 17 00:00:00 2001 From: Krishna Gupta Date: Wed, 6 Mar 2024 14:57:49 +0530 Subject: [PATCH 02/34] added translations. Signed-off-by: Krishna Gupta --- src/components/ReceiptAudit.tsx | 8 +++++--- src/components/ReportActionItem/MoneyRequestView.tsx | 5 ++++- src/languages/en.ts | 4 ++++ src/languages/es.ts | 4 ++++ 4 files changed, 17 insertions(+), 4 deletions(-) diff --git a/src/components/ReceiptAudit.tsx b/src/components/ReceiptAudit.tsx index af8c063668e1..7f11e9b9a1e4 100644 --- a/src/components/ReceiptAudit.tsx +++ b/src/components/ReceiptAudit.tsx @@ -1,5 +1,6 @@ import React from 'react'; import {View} from 'react-native'; +import useLocalize from '@hooks/useLocalize'; import useTheme from '@hooks/useTheme'; import useThemeStyles from '@hooks/useThemeStyles'; import Icon from './Icon'; @@ -9,7 +10,9 @@ import Text from './Text'; export default function ReceiptAudit({notes}: {notes: string[]}) { const styles = useThemeStyles(); const theme = useTheme(); + const {translate} = useLocalize(); + const issuesFoundText = notes.length > 0 ? translate('iou.receiptIssuesFound', notes.length) : translate('iou.receiptNoIssuesFound'); return ( @@ -20,10 +23,9 @@ export default function ReceiptAudit({notes}: {notes: string[]}) { src={notes.length > 0 ? Expensicons.Receipt : Expensicons.Checkmark} fill={theme.white} /> - - {notes.length > 0 ? `Receipt Audit : ${notes.length} Issue(s) Found` : 'Receipt Verified : No issues Found'} - + {notes.length > 0 ? translate('iou.receiptAudit') : translate('iou.receiptVerified')} + {issuesFoundText} {/* // If notes is a array of strings, map through it & show notes. */} diff --git a/src/components/ReportActionItem/MoneyRequestView.tsx b/src/components/ReportActionItem/MoneyRequestView.tsx index 234aa4465d40..639739780a73 100644 --- a/src/components/ReportActionItem/MoneyRequestView.tsx +++ b/src/components/ReportActionItem/MoneyRequestView.tsx @@ -287,7 +287,10 @@ function MoneyRequestView({ /> )} - + {canUseViolations && } diff --git a/src/languages/en.ts b/src/languages/en.ts index 0a52cca62ef5..f073e79335ea 100755 --- a/src/languages/en.ts +++ b/src/languages/en.ts @@ -601,6 +601,10 @@ export default { posted: 'Posted', deleteReceipt: 'Delete receipt', routePending: 'Route pending...', + receiptAudit: 'Receipt Audit', + receiptVerified: 'Receipt Verified', + receiptNoIssuesFound: 'No issues Found', + receiptIssuesFound: (count: number) => `${count} Issue(s) Found`, receiptScanning: 'Scan in progress…', receiptMissingDetails: 'Receipt missing details', receiptStatusTitle: 'Scanning…', diff --git a/src/languages/es.ts b/src/languages/es.ts index 013255c1e11e..b908300f4e46 100644 --- a/src/languages/es.ts +++ b/src/languages/es.ts @@ -594,6 +594,10 @@ export default { posted: 'Contabilizado', deleteReceipt: 'Eliminar recibo', routePending: 'Ruta pendiente...', + receiptAudit: 'Auditoría de recibos', + receiptVerified: 'Recibo verificado', + receiptNoIssuesFound: 'No se encontraron problemas', + receiptIssuesFound: (count: number) => `Se encontró ${count} problema(s)`, receiptScanning: 'Escaneo en curso…', receiptMissingDetails: 'Recibo con campos vacíos', receiptStatusTitle: 'Escaneando…', From 96744d5c4aa2622075e9a2febbe7d2c357eb740d Mon Sep 17 00:00:00 2001 From: Krishna Gupta Date: Wed, 6 Mar 2024 15:56:41 +0530 Subject: [PATCH 03/34] extract noticeViolations from transactionViolations. Signed-off-by: Krishna Gupta --- src/components/ReceiptAudit.tsx | 6 +++--- src/components/ReportActionItem/MoneyRequestView.tsx | 7 ++----- 2 files changed, 5 insertions(+), 8 deletions(-) diff --git a/src/components/ReceiptAudit.tsx b/src/components/ReceiptAudit.tsx index 7f11e9b9a1e4..f756ecd5dc7e 100644 --- a/src/components/ReceiptAudit.tsx +++ b/src/components/ReceiptAudit.tsx @@ -7,14 +7,14 @@ import Icon from './Icon'; import * as Expensicons from './Icon/Expensicons'; import Text from './Text'; -export default function ReceiptAudit({notes}: {notes: string[]}) { +export default function ReceiptAudit({notes = []}: {notes?: string[]}) { const styles = useThemeStyles(); const theme = useTheme(); const {translate} = useLocalize(); const issuesFoundText = notes.length > 0 ? translate('iou.receiptIssuesFound', notes.length) : translate('iou.receiptNoIssuesFound'); return ( - + {/* // If notes is a array of strings, map through it & show notes. */} - {notes.length > 0 && notes.map((message) => {message})} + {notes.length > 0 && notes.map((message) => {message})} ); } diff --git a/src/components/ReportActionItem/MoneyRequestView.tsx b/src/components/ReportActionItem/MoneyRequestView.tsx index 639739780a73..c4f067e35e89 100644 --- a/src/components/ReportActionItem/MoneyRequestView.tsx +++ b/src/components/ReportActionItem/MoneyRequestView.tsx @@ -147,6 +147,7 @@ function MoneyRequestView({ const {getViolationsForField} = useViolations(transactionViolations ?? []); const hasViolations = useCallback((field: ViolationField): boolean => !!canUseViolations && getViolationsForField(field).length > 0, [canUseViolations, getViolationsForField]); + const noticeViolations = transactionViolations?.filter((violation) => violation.type === 'notice').map((v) => ViolationsUtils.getViolationTranslation(v, translate)); let amountDescription = `${translate('iou.amount')}`; @@ -286,11 +287,7 @@ function MoneyRequestView({ } /> )} - - + {noticeViolations?.length && } {canUseViolations && } From 952a4dac2dff9293d91ce53a58467042262bb531 Mon Sep 17 00:00:00 2001 From: Krishna Gupta Date: Thu, 7 Mar 2024 11:50:47 +0530 Subject: [PATCH 04/34] Update the dot separator sub-state for the request preview. Signed-off-by: Krishna Gupta --- .../MoneyRequestPreviewContent.tsx | 3 +++ .../ReportActionItem/MoneyRequestView.tsx | 2 +- src/libs/TransactionUtils.ts | 13 +++++++++++++ 3 files changed, 17 insertions(+), 1 deletion(-) diff --git a/src/components/ReportActionItem/MoneyRequestPreview/MoneyRequestPreviewContent.tsx b/src/components/ReportActionItem/MoneyRequestPreview/MoneyRequestPreviewContent.tsx index 8577c9fa5f97..fb524c6b5cb2 100644 --- a/src/components/ReportActionItem/MoneyRequestPreview/MoneyRequestPreviewContent.tsx +++ b/src/components/ReportActionItem/MoneyRequestPreview/MoneyRequestPreviewContent.tsx @@ -87,6 +87,7 @@ function MoneyRequestPreviewContent({ const hasReceipt = TransactionUtils.hasReceipt(transaction); const isScanning = hasReceipt && TransactionUtils.isReceiptBeingScanned(transaction); const hasViolations = TransactionUtils.hasViolation(transaction?.transactionID ?? '', transactionViolations); + const hasNoteTypeViolations = TransactionUtils.hasNoteTypeViolation(transaction?.transactionID ?? '', transactionViolations); const hasFieldErrors = TransactionUtils.hasMissingSmartscanFields(transaction); const shouldShowRBR = hasViolations || hasFieldErrors; const isDistanceRequest = TransactionUtils.isDistanceRequest(transaction); @@ -159,6 +160,8 @@ function MoneyRequestPreviewContent({ const isTooLong = violations.filter((v) => v.type === 'violation').length > 1 || violationMessage.length > 15; message += ` • ${isTooLong ? translate('violations.reviewRequired') : violationMessage}`; } + } else if (hasNoteTypeViolations && transaction && !ReportUtils.isReportApproved(iouReport) && !ReportUtils.isSettled(iouReport?.reportID)) { + message += ` • ${translate('violations.reviewRequired')}`; } else if (ReportUtils.isPaidGroupPolicyExpenseReport(iouReport) && ReportUtils.isReportApproved(iouReport) && !ReportUtils.isSettled(iouReport?.reportID)) { message += ` • ${translate('iou.approved')}`; } else if (iouReport?.isWaitingOnBankAccount) { diff --git a/src/components/ReportActionItem/MoneyRequestView.tsx b/src/components/ReportActionItem/MoneyRequestView.tsx index c4f067e35e89..440f8afb73ee 100644 --- a/src/components/ReportActionItem/MoneyRequestView.tsx +++ b/src/components/ReportActionItem/MoneyRequestView.tsx @@ -147,7 +147,7 @@ function MoneyRequestView({ const {getViolationsForField} = useViolations(transactionViolations ?? []); const hasViolations = useCallback((field: ViolationField): boolean => !!canUseViolations && getViolationsForField(field).length > 0, [canUseViolations, getViolationsForField]); - const noticeViolations = transactionViolations?.filter((violation) => violation.type === 'notice').map((v) => ViolationsUtils.getViolationTranslation(v, translate)); + const noticeViolations = transactionViolations?.filter((violation) => violation.type === 'note').map((v) => ViolationsUtils.getViolationTranslation(v, translate)); let amountDescription = `${translate('iou.amount')}`; diff --git a/src/libs/TransactionUtils.ts b/src/libs/TransactionUtils.ts index 8a98fe0f2cdc..5dea541b2af2 100644 --- a/src/libs/TransactionUtils.ts +++ b/src/libs/TransactionUtils.ts @@ -593,6 +593,17 @@ function hasViolation(transactionID: string, transactionViolations: OnyxCollecti return Boolean(transactionViolations?.[ONYXKEYS.COLLECTION.TRANSACTION_VIOLATIONS + transactionID]?.some((violation: TransactionViolation) => violation.type === 'violation')); } +/** + * Checks if any violations for the provided transaction are of type 'note' + */ +function hasNoteTypeViolation(transactionID: string, transactionViolations: OnyxCollection): boolean { + return Boolean(transactionViolations?.[ONYXKEYS.COLLECTION.TRANSACTION_VIOLATIONS + transactionID]?.some((violation: TransactionViolation) => violation.type === 'note')); +} + +function getTransactionNoteViolations(transactionID: string, transactionViolations: OnyxCollection): TransactionViolation[] | null { + return transactionViolations?.[ONYXKEYS.COLLECTION.TRANSACTION_VIOLATIONS + transactionID]?.filter((violation: TransactionViolation) => violation.type === 'note') ?? null; +} + function getTransactionViolations(transactionID: string, transactionViolations: OnyxCollection): TransactionViolation[] | null { return transactionViolations?.[ONYXKEYS.COLLECTION.TRANSACTION_VIOLATIONS + transactionID] ?? null; } @@ -638,6 +649,7 @@ export { getTagArrayFromName, getTagForDisplay, getTransactionViolations, + getTransactionNoteViolations, getLinkedTransaction, getAllReportTransactions, hasReceipt, @@ -663,6 +675,7 @@ export { waypointHasValidAddress, getRecentTransactions, hasViolation, + hasNoteTypeViolation, }; export type {TransactionChanges}; From 8438383448a735e0d5dd871e10ae0e27f85fd9f4 Mon Sep 17 00:00:00 2001 From: Krishna Gupta Date: Thu, 7 Mar 2024 11:51:50 +0530 Subject: [PATCH 05/34] Remove redundant code. Signed-off-by: Krishna Gupta --- src/libs/TransactionUtils.ts | 5 ----- 1 file changed, 5 deletions(-) diff --git a/src/libs/TransactionUtils.ts b/src/libs/TransactionUtils.ts index 5dea541b2af2..bc2fcaa39290 100644 --- a/src/libs/TransactionUtils.ts +++ b/src/libs/TransactionUtils.ts @@ -600,10 +600,6 @@ function hasNoteTypeViolation(transactionID: string, transactionViolations: Onyx return Boolean(transactionViolations?.[ONYXKEYS.COLLECTION.TRANSACTION_VIOLATIONS + transactionID]?.some((violation: TransactionViolation) => violation.type === 'note')); } -function getTransactionNoteViolations(transactionID: string, transactionViolations: OnyxCollection): TransactionViolation[] | null { - return transactionViolations?.[ONYXKEYS.COLLECTION.TRANSACTION_VIOLATIONS + transactionID]?.filter((violation: TransactionViolation) => violation.type === 'note') ?? null; -} - function getTransactionViolations(transactionID: string, transactionViolations: OnyxCollection): TransactionViolation[] | null { return transactionViolations?.[ONYXKEYS.COLLECTION.TRANSACTION_VIOLATIONS + transactionID] ?? null; } @@ -649,7 +645,6 @@ export { getTagArrayFromName, getTagForDisplay, getTransactionViolations, - getTransactionNoteViolations, getLinkedTransaction, getAllReportTransactions, hasReceipt, From 7f975195bf133d3ef94d5b1123a53b5fd171a457 Mon Sep 17 00:00:00 2001 From: Krishna Gupta Date: Thu, 7 Mar 2024 11:56:22 +0530 Subject: [PATCH 06/34] minor fix. Signed-off-by: Krishna Gupta --- src/components/ReportActionItem/MoneyRequestView.tsx | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/components/ReportActionItem/MoneyRequestView.tsx b/src/components/ReportActionItem/MoneyRequestView.tsx index 440f8afb73ee..481bcb177569 100644 --- a/src/components/ReportActionItem/MoneyRequestView.tsx +++ b/src/components/ReportActionItem/MoneyRequestView.tsx @@ -147,7 +147,12 @@ function MoneyRequestView({ const {getViolationsForField} = useViolations(transactionViolations ?? []); const hasViolations = useCallback((field: ViolationField): boolean => !!canUseViolations && getViolationsForField(field).length > 0, [canUseViolations, getViolationsForField]); - const noticeViolations = transactionViolations?.filter((violation) => violation.type === 'note').map((v) => ViolationsUtils.getViolationTranslation(v, translate)); + const noticeViolations = [ + {name: 'missingComment', type: 'violation'}, + {name: 'modifiedDate', type: 'violation'}, + ] + ?.filter((violation) => violation.type === 'note') + .map((v) => ViolationsUtils.getViolationTranslation(v, translate)); let amountDescription = `${translate('iou.amount')}`; @@ -287,7 +292,7 @@ function MoneyRequestView({ } /> )} - {noticeViolations?.length && } + {canUseViolations && } From cebc960dcf6e17bc04f2c0ed7158c91e2b112a23 Mon Sep 17 00:00:00 2001 From: Krishna Gupta Date: Thu, 7 Mar 2024 12:20:13 +0530 Subject: [PATCH 07/34] minor fix. Signed-off-by: Krishna Gupta --- src/components/ReportActionItem/MoneyRequestView.tsx | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/src/components/ReportActionItem/MoneyRequestView.tsx b/src/components/ReportActionItem/MoneyRequestView.tsx index 481bcb177569..79639a62babe 100644 --- a/src/components/ReportActionItem/MoneyRequestView.tsx +++ b/src/components/ReportActionItem/MoneyRequestView.tsx @@ -147,12 +147,7 @@ function MoneyRequestView({ const {getViolationsForField} = useViolations(transactionViolations ?? []); const hasViolations = useCallback((field: ViolationField): boolean => !!canUseViolations && getViolationsForField(field).length > 0, [canUseViolations, getViolationsForField]); - const noticeViolations = [ - {name: 'missingComment', type: 'violation'}, - {name: 'modifiedDate', type: 'violation'}, - ] - ?.filter((violation) => violation.type === 'note') - .map((v) => ViolationsUtils.getViolationTranslation(v, translate)); + const noteTypeViolations = transactionViolations?.filter((violation) => violation.type === 'note').map((v) => ViolationsUtils.getViolationTranslation(v, translate)); let amountDescription = `${translate('iou.amount')}`; @@ -292,8 +287,7 @@ function MoneyRequestView({ } /> )} - - + {canUseViolations && } Date: Thu, 7 Mar 2024 15:25:49 +0530 Subject: [PATCH 08/34] hide ReceiptAudit when scan is in progress. Signed-off-by: Krishna Gupta --- src/components/ReportActionItem/MoneyRequestView.tsx | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/components/ReportActionItem/MoneyRequestView.tsx b/src/components/ReportActionItem/MoneyRequestView.tsx index 79639a62babe..415a2666512a 100644 --- a/src/components/ReportActionItem/MoneyRequestView.tsx +++ b/src/components/ReportActionItem/MoneyRequestView.tsx @@ -129,6 +129,7 @@ function MoneyRequestView({ const canEditDate = ReportUtils.canEditFieldOfMoneyRequest(parentReportAction, CONST.EDIT_REQUEST_FIELD.DATE); const canEditReceipt = ReportUtils.canEditFieldOfMoneyRequest(parentReportAction, CONST.EDIT_REQUEST_FIELD.RECEIPT); const canEditDistance = ReportUtils.canEditFieldOfMoneyRequest(parentReportAction, CONST.EDIT_REQUEST_FIELD.DISTANCE); + const isReceiptBeingScanned = TransactionUtils.hasReceipt(transaction) && !TransactionUtils.isReceiptBeingScanned(transaction); // A flag for verifying that the current report is a sub-report of a workspace chat // if the policy of the report is either Collect or Control, then this report must be tied to workspace chat @@ -287,7 +288,7 @@ function MoneyRequestView({ } /> )} - + {!isReceiptBeingScanned && canUseViolations && } {canUseViolations && } Date: Fri, 8 Mar 2024 16:53:21 +0530 Subject: [PATCH 09/34] minor updates. Signed-off-by: Krishna Gupta --- src/components/ReceiptAudit.tsx | 2 -- src/components/ReportActionItem/MoneyRequestView.tsx | 7 ++++--- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/src/components/ReceiptAudit.tsx b/src/components/ReceiptAudit.tsx index f756ecd5dc7e..5b91fe97ca0d 100644 --- a/src/components/ReceiptAudit.tsx +++ b/src/components/ReceiptAudit.tsx @@ -27,8 +27,6 @@ export default function ReceiptAudit({notes = []}: {notes?: string[]}) { {issuesFoundText} - - {/* // If notes is a array of strings, map through it & show notes. */} {notes.length > 0 && notes.map((message) => {message})} ); diff --git a/src/components/ReportActionItem/MoneyRequestView.tsx b/src/components/ReportActionItem/MoneyRequestView.tsx index 415a2666512a..ffe373aade00 100644 --- a/src/components/ReportActionItem/MoneyRequestView.tsx +++ b/src/components/ReportActionItem/MoneyRequestView.tsx @@ -129,7 +129,8 @@ function MoneyRequestView({ const canEditDate = ReportUtils.canEditFieldOfMoneyRequest(parentReportAction, CONST.EDIT_REQUEST_FIELD.DATE); const canEditReceipt = ReportUtils.canEditFieldOfMoneyRequest(parentReportAction, CONST.EDIT_REQUEST_FIELD.RECEIPT); const canEditDistance = ReportUtils.canEditFieldOfMoneyRequest(parentReportAction, CONST.EDIT_REQUEST_FIELD.DISTANCE); - const isReceiptBeingScanned = TransactionUtils.hasReceipt(transaction) && !TransactionUtils.isReceiptBeingScanned(transaction); + const hasReceipt = TransactionUtils.hasReceipt(transaction); + const isReceiptBeingScanned = hasReceipt && TransactionUtils.isReceiptBeingScanned(transaction); // A flag for verifying that the current report is a sub-report of a workspace chat // if the policy of the report is either Collect or Control, then this report must be tied to workspace chat @@ -149,6 +150,7 @@ function MoneyRequestView({ const {getViolationsForField} = useViolations(transactionViolations ?? []); const hasViolations = useCallback((field: ViolationField): boolean => !!canUseViolations && getViolationsForField(field).length > 0, [canUseViolations, getViolationsForField]); const noteTypeViolations = transactionViolations?.filter((violation) => violation.type === 'note').map((v) => ViolationsUtils.getViolationTranslation(v, translate)); + const shouldShowNotesViolations = !isReceiptBeingScanned && canUseViolations && hasReceipt; let amountDescription = `${translate('iou.amount')}`; @@ -190,7 +192,6 @@ function MoneyRequestView({ } } - const hasReceipt = TransactionUtils.hasReceipt(transaction); let receiptURIs; const hasErrors = canEdit && TransactionUtils.hasMissingSmartscanFields(transaction); if (hasReceipt) { @@ -288,7 +289,7 @@ function MoneyRequestView({ } /> )} - {!isReceiptBeingScanned && canUseViolations && } + {shouldShowNotesViolations && } {canUseViolations && } Date: Mon, 11 Mar 2024 11:50:00 +0530 Subject: [PATCH 10/34] Update MoneyRequestView.tsx --- src/components/ReportActionItem/MoneyRequestView.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/ReportActionItem/MoneyRequestView.tsx b/src/components/ReportActionItem/MoneyRequestView.tsx index 3569791d64d4..d79ff88a4f1e 100644 --- a/src/components/ReportActionItem/MoneyRequestView.tsx +++ b/src/components/ReportActionItem/MoneyRequestView.tsx @@ -147,7 +147,7 @@ function MoneyRequestView({ const shouldShowBillable = isPolicyExpenseChat && (!!transactionBillable || !(policy?.disabledFields?.defaultBillable ?? true)); const {getViolationsForField} = useViolations(transactionViolations ?? []); - const hasViolations = useCallback( + const hasViolations = useCallback( (field: ViolationField, data?: OnyxTypes.TransactionViolation['data']): boolean => !!canUseViolations && getViolationsForField(field, data).length > 0, [canUseViolations, getViolationsForField], ); From 48d1543f0ff3a75aea75eb2bb9f176671475c5dd Mon Sep 17 00:00:00 2001 From: Krishna Gupta Date: Tue, 12 Mar 2024 13:12:52 +0530 Subject: [PATCH 11/34] fix: translations. Signed-off-by: Krishna Gupta --- src/languages/en.ts | 2 +- src/languages/es.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/languages/en.ts b/src/languages/en.ts index 2c4f5d21f66f..7979981392fe 100755 --- a/src/languages/en.ts +++ b/src/languages/en.ts @@ -604,7 +604,7 @@ export default { receiptAudit: 'Receipt Audit', receiptVerified: 'Receipt Verified', receiptNoIssuesFound: 'No issues Found', - receiptIssuesFound: (count: number) => `${count} Issue(s) Found`, + receiptIssuesFound: (count: number) => `${count} ${count === 1 ? 'Issue' : 'Issues'} Found`, receiptScanning: 'Scan in progress…', receiptMissingDetails: 'Receipt missing details', receiptStatusTitle: 'Scanning…', diff --git a/src/languages/es.ts b/src/languages/es.ts index 2f6a064a3615..730d110a60a9 100644 --- a/src/languages/es.ts +++ b/src/languages/es.ts @@ -597,7 +597,7 @@ export default { receiptAudit: 'Auditoría de recibos', receiptVerified: 'Recibo verificado', receiptNoIssuesFound: 'No se encontraron problemas', - receiptIssuesFound: (count: number) => `Se encontró ${count} problema(s)`, + receiptIssuesFound: (count: number) => `Se encontró ${count} ${count === 1 ? 'problema' : 'problemas'}`, receiptScanning: 'Escaneo en curso…', receiptMissingDetails: 'Recibo con campos vacíos', receiptStatusTitle: 'Escaneando…', From 77165e73b114711e721e98d4b1c0ba6d74cd37d3 Mon Sep 17 00:00:00 2001 From: Krishna Gupta Date: Sun, 17 Mar 2024 18:23:23 +0530 Subject: [PATCH 12/34] minor fixes. Signed-off-by: Krishna Gupta --- src/components/ReportActionItem/MoneyRequestView.tsx | 2 +- src/languages/en.ts | 4 ++-- src/libs/TransactionUtils.ts | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/components/ReportActionItem/MoneyRequestView.tsx b/src/components/ReportActionItem/MoneyRequestView.tsx index d79ff88a4f1e..096ac8b69863 100644 --- a/src/components/ReportActionItem/MoneyRequestView.tsx +++ b/src/components/ReportActionItem/MoneyRequestView.tsx @@ -151,7 +151,7 @@ function MoneyRequestView({ (field: ViolationField, data?: OnyxTypes.TransactionViolation['data']): boolean => !!canUseViolations && getViolationsForField(field, data).length > 0, [canUseViolations, getViolationsForField], ); - const noteTypeViolations = transactionViolations?.filter((violation) => violation.type === 'note').map((v) => ViolationsUtils.getViolationTranslation(v, translate)); + const noteTypeViolations = transactionViolations?.filter((violation) => violation.type === 'notice').map((v) => ViolationsUtils.getViolationTranslation(v, translate)); const shouldShowNotesViolations = !isReceiptBeingScanned && canUseViolations && hasReceipt; let amountDescription = `${translate('iou.amount')}`; diff --git a/src/languages/en.ts b/src/languages/en.ts index 7979981392fe..cdefb85e0168 100755 --- a/src/languages/en.ts +++ b/src/languages/en.ts @@ -603,8 +603,8 @@ export default { routePending: 'Route pending...', receiptAudit: 'Receipt Audit', receiptVerified: 'Receipt Verified', - receiptNoIssuesFound: 'No issues Found', - receiptIssuesFound: (count: number) => `${count} ${count === 1 ? 'Issue' : 'Issues'} Found`, + receiptNoIssuesFound: 'No issues found', + receiptIssuesFound: (count: number) => `${count} ${count === 1 ? 'issue' : 'issues'} found`, receiptScanning: 'Scan in progress…', receiptMissingDetails: 'Receipt missing details', receiptStatusTitle: 'Scanning…', diff --git a/src/libs/TransactionUtils.ts b/src/libs/TransactionUtils.ts index bc2fcaa39290..86285aef06b3 100644 --- a/src/libs/TransactionUtils.ts +++ b/src/libs/TransactionUtils.ts @@ -597,7 +597,7 @@ function hasViolation(transactionID: string, transactionViolations: OnyxCollecti * Checks if any violations for the provided transaction are of type 'note' */ function hasNoteTypeViolation(transactionID: string, transactionViolations: OnyxCollection): boolean { - return Boolean(transactionViolations?.[ONYXKEYS.COLLECTION.TRANSACTION_VIOLATIONS + transactionID]?.some((violation: TransactionViolation) => violation.type === 'note')); + return Boolean(transactionViolations?.[ONYXKEYS.COLLECTION.TRANSACTION_VIOLATIONS + transactionID]?.some((violation: TransactionViolation) => violation.type === 'notice')); } function getTransactionViolations(transactionID: string, transactionViolations: OnyxCollection): TransactionViolation[] | null { From 25cc0fa936630e866bca9a470604632869890b2f Mon Sep 17 00:00:00 2001 From: Krishna Gupta Date: Wed, 20 Mar 2024 15:35:07 +0530 Subject: [PATCH 13/34] receipt audit design changes. Signed-off-by: Krishna Gupta --- src/components/ReceiptAudit.tsx | 33 +++++++++++-------- .../ReportActionItem/MoneyRequestView.tsx | 5 +-- 2 files changed, 22 insertions(+), 16 deletions(-) diff --git a/src/components/ReceiptAudit.tsx b/src/components/ReceiptAudit.tsx index 5b91fe97ca0d..0c387ff0ae79 100644 --- a/src/components/ReceiptAudit.tsx +++ b/src/components/ReceiptAudit.tsx @@ -7,27 +7,32 @@ import Icon from './Icon'; import * as Expensicons from './Icon/Expensicons'; import Text from './Text'; -export default function ReceiptAudit({notes = []}: {notes?: string[]}) { +function ReceiptAuditHeader({notes = []}: {notes?: string[]}) { const styles = useThemeStyles(); const theme = useTheme(); const {translate} = useLocalize(); const issuesFoundText = notes.length > 0 ? translate('iou.receiptIssuesFound', notes.length) : translate('iou.receiptNoIssuesFound'); return ( - - - - 0 ? Expensicons.Receipt : Expensicons.Checkmark} - fill={theme.white} - /> - {notes.length > 0 ? translate('iou.receiptAudit') : translate('iou.receiptVerified')} - - {issuesFoundText} + + + {translate('common.receipt')} + {` • ${issuesFoundText}`} + 0 ? Expensicons.DotIndicator : Expensicons.Checkmark} + fill={notes.length ? theme.danger : theme.success} + additionalStyles={styles.ml2} + /> - {notes.length > 0 && notes.map((message) => {message})} ); } + +function ReceiptAuditMessages({notes = []}: {notes?: string[]}) { + const styles = useThemeStyles(); + return {notes.length > 0 && notes.map((message) => {message})}; +} + +export {ReceiptAuditHeader, ReceiptAuditMessages}; diff --git a/src/components/ReportActionItem/MoneyRequestView.tsx b/src/components/ReportActionItem/MoneyRequestView.tsx index 096ac8b69863..47a193946083 100644 --- a/src/components/ReportActionItem/MoneyRequestView.tsx +++ b/src/components/ReportActionItem/MoneyRequestView.tsx @@ -6,7 +6,7 @@ import ConfirmedRoute from '@components/ConfirmedRoute'; import * as Expensicons from '@components/Icon/Expensicons'; import MenuItemWithTopDescription from '@components/MenuItemWithTopDescription'; import OfflineWithFeedback from '@components/OfflineWithFeedback'; -import ReceiptAudit from '@components/ReceiptAudit'; +import {ReceiptAuditHeader, ReceiptAuditMessages} from '@components/ReceiptAudit'; import ReceiptEmptyState from '@components/ReceiptEmptyState'; import SpacerView from '@components/SpacerView'; import Switch from '@components/Switch'; @@ -244,6 +244,7 @@ function MoneyRequestView({ + {shouldShowNotesViolations && } {/* eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing */} {(showMapAsImage || hasReceipt) && ( )} - {shouldShowNotesViolations && } + {shouldShowNotesViolations && } {canUseViolations && } Date: Fri, 22 Mar 2024 07:02:41 +0530 Subject: [PATCH 14/34] Receipt audit design updates. Signed-off-by: Krishna Gupta --- src/components/ReceiptAudit.tsx | 29 +++++++++++-------- .../ReportActionItem/MoneyRequestView.tsx | 10 +++++-- src/languages/en.ts | 6 ++-- src/languages/es.ts | 6 ++-- src/styles/index.ts | 13 --------- 5 files changed, 28 insertions(+), 36 deletions(-) diff --git a/src/components/ReceiptAudit.tsx b/src/components/ReceiptAudit.tsx index 0c387ff0ae79..3ec5e7f8e6de 100644 --- a/src/components/ReceiptAudit.tsx +++ b/src/components/ReceiptAudit.tsx @@ -7,24 +7,29 @@ import Icon from './Icon'; import * as Expensicons from './Icon/Expensicons'; import Text from './Text'; -function ReceiptAuditHeader({notes = []}: {notes?: string[]}) { +function ReceiptAuditHeader({notes = [], showAuditMessage = false}: {notes?: string[]; showAuditMessage?: boolean}) { const styles = useThemeStyles(); const theme = useTheme(); const {translate} = useLocalize(); - const issuesFoundText = notes.length > 0 ? translate('iou.receiptIssuesFound', notes.length) : translate('iou.receiptNoIssuesFound'); + const issuesFoundText = notes.length > 0 ? translate('iou.receiptIssuesFound', notes.length) : translate('common.verified'); return ( - + {translate('common.receipt')} - {` • ${issuesFoundText}`} - 0 ? Expensicons.DotIndicator : Expensicons.Checkmark} - fill={notes.length ? theme.danger : theme.success} - additionalStyles={styles.ml2} - /> + {showAuditMessage && ( + <> + {' • '} + {`${issuesFoundText}`} + 0 ? Expensicons.DotIndicator : Expensicons.Checkmark} + fill={notes.length ? theme.danger : theme.success} + additionalStyles={styles.ml1} + /> + + )} ); @@ -32,7 +37,7 @@ function ReceiptAuditHeader({notes = []}: {notes?: string[]}) { function ReceiptAuditMessages({notes = []}: {notes?: string[]}) { const styles = useThemeStyles(); - return {notes.length > 0 && notes.map((message) => {message})}; + return {notes.length > 0 && notes.map((message) => {message})}; } export {ReceiptAuditHeader, ReceiptAuditMessages}; diff --git a/src/components/ReportActionItem/MoneyRequestView.tsx b/src/components/ReportActionItem/MoneyRequestView.tsx index 47a193946083..7fd5fec6d2b9 100644 --- a/src/components/ReportActionItem/MoneyRequestView.tsx +++ b/src/components/ReportActionItem/MoneyRequestView.tsx @@ -244,8 +244,12 @@ function MoneyRequestView({ - {shouldShowNotesViolations && } - {/* eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing */} + {hasReceipt && ( + + )} {(showMapAsImage || hasReceipt) && ( )} {shouldShowNotesViolations && } - {canUseViolations && } + `${count} ${count === 1 ? 'issue' : 'issues'} found`, + receiptIssuesFound: (count: number) => `${count === 1 ? 'Issue' : 'Issues'} found`, receiptScanning: 'Scan in progress…', receiptMissingDetails: 'Receipt missing details', missingAmount: 'Missing amount', diff --git a/src/languages/es.ts b/src/languages/es.ts index 9097bf1b1370..9dbaa2eadd79 100644 --- a/src/languages/es.ts +++ b/src/languages/es.ts @@ -281,6 +281,7 @@ export default { nonBillable: 'No facturable', tag: 'Etiqueta', receipt: 'Recibo', + verified: `Verificado`, replace: 'Sustituir', distance: 'Distancia', mile: 'milla', @@ -595,10 +596,7 @@ export default { posted: 'Contabilizado', deleteReceipt: 'Eliminar recibo', routePending: 'Ruta pendiente...', - receiptAudit: 'Auditoría de recibos', - receiptVerified: 'Recibo verificado', - receiptNoIssuesFound: 'No se encontraron problemas', - receiptIssuesFound: (count: number) => `Se encontró ${count} ${count === 1 ? 'problema' : 'problemas'}`, + receiptIssuesFound: (count: number) => `${count === 1 ? 'Problema' : 'Problemas'}`, receiptScanning: 'Escaneo en curso…', receiptMissingDetails: 'Recibo con campos vacíos', missingAmount: 'Falta importe', diff --git a/src/styles/index.ts b/src/styles/index.ts index f25b349cba60..8a91291a0c71 100644 --- a/src/styles/index.ts +++ b/src/styles/index.ts @@ -4225,19 +4225,6 @@ const styles = (theme: ThemeColors) => borderWidth: 1, }, - receiptAuditTitleContainer: { - flexDirection: 'row', - gap: 4, - padding: 4, - paddingHorizontal: 8, - height: variables.inputHeightSmall, - borderRadius: variables.componentBorderRadiusSmall, - display: 'flex', - justifyContent: 'center', - alignItems: 'center', - backgroundColor: theme.border, - }, - mapViewContainer: { ...flex.flex1, minHeight: 300, From fd457cd933ade344d19b0a17d40b6cd47d9214e3 Mon Sep 17 00:00:00 2001 From: Krishna Gupta Date: Tue, 26 Mar 2024 03:35:19 +0530 Subject: [PATCH 15/34] show notes violation for only admins and approvers in a paid policy. Signed-off-by: Krishna Gupta --- .../ReportActionItem/MoneyRequestView.tsx | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/src/components/ReportActionItem/MoneyRequestView.tsx b/src/components/ReportActionItem/MoneyRequestView.tsx index 7fd5fec6d2b9..f17f635f3260 100644 --- a/src/components/ReportActionItem/MoneyRequestView.tsx +++ b/src/components/ReportActionItem/MoneyRequestView.tsx @@ -41,6 +41,9 @@ import type {TransactionPendingFieldsKey} from '@src/types/onyx/Transaction'; import ReportActionItemImage from './ReportActionItemImage'; type MoneyRequestViewTransactionOnyxProps = { + /** Session info for the currently logged in user. */ + session: OnyxEntry; + /** The transaction associated with the transactionThread */ transaction: OnyxEntry; @@ -85,6 +88,7 @@ function MoneyRequestView({ policyTagList, policy, transactionViolations, + session, }: MoneyRequestViewProps) { const theme = useTheme(); const styles = useThemeStyles(); @@ -131,6 +135,10 @@ function MoneyRequestView({ const hasReceipt = TransactionUtils.hasReceipt(transaction); const isReceiptBeingScanned = hasReceipt && TransactionUtils.isReceiptBeingScanned(transaction); + const isActionOwner = typeof parentReportAction?.actorAccountID === 'number' && typeof session?.accountID === 'number' && parentReportAction.actorAccountID === session?.accountID; + const isPolicyAdmin = policy?.role === CONST.POLICY.ROLE.ADMIN; + const isApprover = ReportUtils.isMoneyRequestReport(moneyRequestReport) && (session?.accountID ?? null) === moneyRequestReport?.managerID; + // A flag for verifying that the current report is a sub-report of a workspace chat // if the policy of the report is either Collect or Control, then this report must be tied to workspace chat const isPolicyExpenseChat = ReportUtils.isGroupPolicy(report); @@ -152,7 +160,7 @@ function MoneyRequestView({ [canUseViolations, getViolationsForField], ); const noteTypeViolations = transactionViolations?.filter((violation) => violation.type === 'notice').map((v) => ViolationsUtils.getViolationTranslation(v, translate)); - const shouldShowNotesViolations = !isReceiptBeingScanned && canUseViolations && hasReceipt; + const shouldShowNotesViolations = !isReceiptBeingScanned && canUseViolations && ReportUtils.isPaidGroupPolicy(report) && (isActionOwner || isPolicyAdmin || isApprover); let amountDescription = `${translate('iou.amount')}`; @@ -487,5 +495,8 @@ export default withOnyx Date: Fri, 29 Mar 2024 10:19:13 +0530 Subject: [PATCH 16/34] show notes violation to everyone. Signed-off-by: Krishna Gupta --- .../ReportActionItem/MoneyRequestView.tsx | 13 +------------ 1 file changed, 1 insertion(+), 12 deletions(-) diff --git a/src/components/ReportActionItem/MoneyRequestView.tsx b/src/components/ReportActionItem/MoneyRequestView.tsx index d3a3584e2ae4..ac7efd88fcfd 100644 --- a/src/components/ReportActionItem/MoneyRequestView.tsx +++ b/src/components/ReportActionItem/MoneyRequestView.tsx @@ -41,9 +41,6 @@ import type {TransactionPendingFieldsKey} from '@src/types/onyx/Transaction'; import ReportActionItemImage from './ReportActionItemImage'; type MoneyRequestViewTransactionOnyxProps = { - /** Session info for the currently logged in user. */ - session: OnyxEntry; - /** The transaction associated with the transactionThread */ transaction: OnyxEntry; @@ -88,7 +85,6 @@ function MoneyRequestView({ policyTagList, policy, transactionViolations, - session, }: MoneyRequestViewProps) { const theme = useTheme(); const styles = useThemeStyles(); @@ -135,10 +131,6 @@ function MoneyRequestView({ const hasReceipt = TransactionUtils.hasReceipt(transaction); const isReceiptBeingScanned = hasReceipt && TransactionUtils.isReceiptBeingScanned(transaction); - const isActionOwner = typeof parentReportAction?.actorAccountID === 'number' && typeof session?.accountID === 'number' && parentReportAction.actorAccountID === session?.accountID; - const isPolicyAdmin = policy?.role === CONST.POLICY.ROLE.ADMIN; - const isApprover = ReportUtils.isMoneyRequestReport(moneyRequestReport) && (session?.accountID ?? null) === moneyRequestReport?.managerID; - // A flag for verifying that the current report is a sub-report of a workspace chat // if the policy of the report is either Collect or Control, then this report must be tied to workspace chat const isPolicyExpenseChat = ReportUtils.isGroupPolicy(report); @@ -160,7 +152,7 @@ function MoneyRequestView({ [canUseViolations, getViolationsForField], ); const noteTypeViolations = transactionViolations?.filter((violation) => violation.type === 'notice').map((v) => ViolationsUtils.getViolationTranslation(v, translate)); - const shouldShowNotesViolations = !isReceiptBeingScanned && canUseViolations && ReportUtils.isPaidGroupPolicy(report) && (isActionOwner || isPolicyAdmin || isApprover); + const shouldShowNotesViolations = !isReceiptBeingScanned && canUseViolations && ReportUtils.isPaidGroupPolicy(report); let amountDescription = `${translate('iou.amount')}`; @@ -501,8 +493,5 @@ export default withOnyx Date: Fri, 29 Mar 2024 10:52:43 +0530 Subject: [PATCH 17/34] fix: violation messages styles. Signed-off-by: Krishna Gupta --- src/components/ViolationMessages.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/ViolationMessages.tsx b/src/components/ViolationMessages.tsx index 0cbcc1051537..e30ad251e0a2 100644 --- a/src/components/ViolationMessages.tsx +++ b/src/components/ViolationMessages.tsx @@ -15,7 +15,7 @@ export default function ViolationMessages({violations, isLast, containerStyle, t const violationMessages = useMemo(() => violations.map((violation) => [violation.name, ViolationsUtils.getViolationTranslation(violation, translate)]), [translate, violations]); return ( - + {violationMessages.map(([name, message]) => ( Date: Sun, 31 Mar 2024 11:37:51 +0530 Subject: [PATCH 18/34] Update MoneyRequestView.tsx --- src/components/ReportActionItem/MoneyRequestView.tsx | 1 - 1 file changed, 1 deletion(-) diff --git a/src/components/ReportActionItem/MoneyRequestView.tsx b/src/components/ReportActionItem/MoneyRequestView.tsx index 453e75df9b5a..eb918ed8facf 100644 --- a/src/components/ReportActionItem/MoneyRequestView.tsx +++ b/src/components/ReportActionItem/MoneyRequestView.tsx @@ -248,7 +248,6 @@ function MoneyRequestView({ {shouldShowAnimatedBackground && } - {hasReceipt && ( Date: Sun, 31 Mar 2024 11:42:16 +0530 Subject: [PATCH 19/34] remove ReceiptAuditHeader condition. Signed-off-by: Krishna Gupta --- src/components/ReportActionItem/MoneyRequestView.tsx | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/src/components/ReportActionItem/MoneyRequestView.tsx b/src/components/ReportActionItem/MoneyRequestView.tsx index eb918ed8facf..1adf9582d538 100644 --- a/src/components/ReportActionItem/MoneyRequestView.tsx +++ b/src/components/ReportActionItem/MoneyRequestView.tsx @@ -248,13 +248,10 @@ function MoneyRequestView({ {shouldShowAnimatedBackground && } - {hasReceipt && ( - - )} - + {/* eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing */} {(showMapAsImage || hasReceipt) && ( Date: Thu, 4 Apr 2024 10:48:22 +0530 Subject: [PATCH 20/34] fix: margins issue. Signed-off-by: Krishna Gupta --- src/components/ReceiptAudit.tsx | 7 +++---- src/styles/index.ts | 2 +- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/src/components/ReceiptAudit.tsx b/src/components/ReceiptAudit.tsx index 3ec5e7f8e6de..7100e1a60842 100644 --- a/src/components/ReceiptAudit.tsx +++ b/src/components/ReceiptAudit.tsx @@ -14,13 +14,12 @@ function ReceiptAuditHeader({notes = [], showAuditMessage = false}: {notes?: str const issuesFoundText = notes.length > 0 ? translate('iou.receiptIssuesFound', notes.length) : translate('common.verified'); return ( - + {translate('common.receipt')} {showAuditMessage && ( <> - {' • '} - {`${issuesFoundText}`} + {` • ${issuesFoundText}`} {notes.length > 0 && notes.map((message) => {message})}; + return {notes.length > 0 && notes.map((message) => {message})}; } export {ReceiptAuditHeader, ReceiptAuditMessages}; diff --git a/src/styles/index.ts b/src/styles/index.ts index a736bc537fa6..d9a5a6e46ac5 100644 --- a/src/styles/index.ts +++ b/src/styles/index.ts @@ -4231,7 +4231,7 @@ const styles = (theme: ThemeColors) => }, moneyRequestViewImage: { ...spacing.mh5, - ...spacing.mv3, + ...spacing.mv1, overflow: 'hidden', borderWidth: 2, borderColor: theme.cardBG, From 4225d83c3f49e4a09ac78c5ad5cf012fc1091bf4 Mon Sep 17 00:00:00 2001 From: Krishna Gupta Date: Tue, 9 Apr 2024 17:14:19 +0530 Subject: [PATCH 21/34] show red dot when review is required. Signed-off-by: Krishna Gupta --- .../MoneyRequestPreview/MoneyRequestPreviewContent.tsx | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/components/ReportActionItem/MoneyRequestPreview/MoneyRequestPreviewContent.tsx b/src/components/ReportActionItem/MoneyRequestPreview/MoneyRequestPreviewContent.tsx index 961dd93296f6..e92814027ae1 100644 --- a/src/components/ReportActionItem/MoneyRequestPreview/MoneyRequestPreviewContent.tsx +++ b/src/components/ReportActionItem/MoneyRequestPreview/MoneyRequestPreviewContent.tsx @@ -97,7 +97,10 @@ function MoneyRequestPreviewContent({ const isSettled = ReportUtils.isSettled(iouReport?.reportID); const isDeleted = action?.pendingAction === CONST.RED_BRICK_ROAD_PENDING_ACTION.DELETE; const shouldShowRBR = - hasViolations || hasFieldErrors || (!(isSettled && !isSettlementOrApprovalPartial) && !(ReportUtils.isReportApproved(iouReport) && !isSettlementOrApprovalPartial) && isOnHold); + hasNoteTypeViolations || + hasViolations || + hasFieldErrors || + (!(isSettled && !isSettlementOrApprovalPartial) && !(ReportUtils.isReportApproved(iouReport) && !isSettlementOrApprovalPartial) && isOnHold); /* Show the merchant for IOUs and expenses only if: From 78b79ccc004a4388d8d38908cd9b611b6330c63a Mon Sep 17 00:00:00 2001 From: Krishna Gupta Date: Sun, 14 Apr 2024 16:05:43 +0530 Subject: [PATCH 22/34] allow admin & approver to update receipt when iou request is open. Signed-off-by: Krishna Gupta --- src/libs/ReportUtils.ts | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/libs/ReportUtils.ts b/src/libs/ReportUtils.ts index b03abbcdf9bb..5df30c74d255 100644 --- a/src/libs/ReportUtils.ts +++ b/src/libs/ReportUtils.ts @@ -2428,7 +2428,7 @@ function getTransactionDetails(transaction: OnyxEntry, createdDateF * This is used in conjunction with canEditRestrictedField to control editing of specific fields like amount, currency, created, receipt, and distance. * On its own, it only controls allowing/disallowing navigating to the editing pages or showing/hiding the 'Edit' icon on report actions */ -function canEditMoneyRequest(reportAction: OnyxEntry): boolean { +function canEditMoneyRequest(reportAction: OnyxEntry, fieldToEdit?: ValueOf): boolean { const isDeleted = ReportActionsUtils.isDeletedAction(reportAction); if (isDeleted) { @@ -2466,6 +2466,10 @@ function canEditMoneyRequest(reportAction: OnyxEntry): boolean { const isAdmin = policy.role === CONST.POLICY.ROLE.ADMIN; const isManager = currentUserAccountID === moneyRequestReport?.managerID; + if ((isAdmin || isManager) && ((isOpenExpenseReport(moneyRequestReport) && fieldToEdit === CONST.EDIT_REQUEST_FIELD.RECEIPT) || isRequestor)) { + return true; + } + // Admin & managers can always edit coding fields such as tag, category, billable, etc. As long as the report has a state higher than OPEN. if ((isAdmin || isManager) && !isOpenExpenseReport(moneyRequestReport)) { return true; @@ -2489,7 +2493,7 @@ function canEditFieldOfMoneyRequest(reportAction: OnyxEntry, field CONST.EDIT_REQUEST_FIELD.DISTANCE, ]; - if (!canEditMoneyRequest(reportAction)) { + if (!canEditMoneyRequest(reportAction, fieldToEdit)) { return false; } @@ -2521,8 +2525,7 @@ function canEditFieldOfMoneyRequest(reportAction: OnyxEntry, field } if (fieldToEdit === CONST.EDIT_REQUEST_FIELD.RECEIPT) { - const isRequestor = currentUserAccountID === reportAction?.actorAccountID; - return !TransactionUtils.isReceiptBeingScanned(transaction) && !TransactionUtils.isDistanceRequest(transaction) && isRequestor; + return !TransactionUtils.isReceiptBeingScanned(transaction) && !TransactionUtils.isDistanceRequest(transaction); } return true; From 87270fbb8ef98c9465f8ff2c8ec7699378f1f42e Mon Sep 17 00:00:00 2001 From: Krishna Gupta Date: Sun, 14 Apr 2024 19:32:48 +0530 Subject: [PATCH 23/34] revert: allow admin & approver to update receipt when iou request is open. Signed-off-by: Krishna Gupta --- src/libs/ReportUtils.ts | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/src/libs/ReportUtils.ts b/src/libs/ReportUtils.ts index 5df30c74d255..b03abbcdf9bb 100644 --- a/src/libs/ReportUtils.ts +++ b/src/libs/ReportUtils.ts @@ -2428,7 +2428,7 @@ function getTransactionDetails(transaction: OnyxEntry, createdDateF * This is used in conjunction with canEditRestrictedField to control editing of specific fields like amount, currency, created, receipt, and distance. * On its own, it only controls allowing/disallowing navigating to the editing pages or showing/hiding the 'Edit' icon on report actions */ -function canEditMoneyRequest(reportAction: OnyxEntry, fieldToEdit?: ValueOf): boolean { +function canEditMoneyRequest(reportAction: OnyxEntry): boolean { const isDeleted = ReportActionsUtils.isDeletedAction(reportAction); if (isDeleted) { @@ -2466,10 +2466,6 @@ function canEditMoneyRequest(reportAction: OnyxEntry, fieldToEdit? const isAdmin = policy.role === CONST.POLICY.ROLE.ADMIN; const isManager = currentUserAccountID === moneyRequestReport?.managerID; - if ((isAdmin || isManager) && ((isOpenExpenseReport(moneyRequestReport) && fieldToEdit === CONST.EDIT_REQUEST_FIELD.RECEIPT) || isRequestor)) { - return true; - } - // Admin & managers can always edit coding fields such as tag, category, billable, etc. As long as the report has a state higher than OPEN. if ((isAdmin || isManager) && !isOpenExpenseReport(moneyRequestReport)) { return true; @@ -2493,7 +2489,7 @@ function canEditFieldOfMoneyRequest(reportAction: OnyxEntry, field CONST.EDIT_REQUEST_FIELD.DISTANCE, ]; - if (!canEditMoneyRequest(reportAction, fieldToEdit)) { + if (!canEditMoneyRequest(reportAction)) { return false; } @@ -2525,7 +2521,8 @@ function canEditFieldOfMoneyRequest(reportAction: OnyxEntry, field } if (fieldToEdit === CONST.EDIT_REQUEST_FIELD.RECEIPT) { - return !TransactionUtils.isReceiptBeingScanned(transaction) && !TransactionUtils.isDistanceRequest(transaction); + const isRequestor = currentUserAccountID === reportAction?.actorAccountID; + return !TransactionUtils.isReceiptBeingScanned(transaction) && !TransactionUtils.isDistanceRequest(transaction) && isRequestor; } return true; From cd917738465482115bf7eb2e738f3bd0c0dada5a Mon Sep 17 00:00:00 2001 From: Krishna Gupta Date: Fri, 19 Apr 2024 01:14:21 +0530 Subject: [PATCH 24/34] show empty receipt for admin & approver if not present. Signed-off-by: Krishna Gupta --- src/components/ReceiptEmptyState.tsx | 5 ++++- src/components/ReportActionItem/MoneyRequestView.tsx | 7 ++++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/src/components/ReceiptEmptyState.tsx b/src/components/ReceiptEmptyState.tsx index 9884e97a3fa0..abc025814096 100644 --- a/src/components/ReceiptEmptyState.tsx +++ b/src/components/ReceiptEmptyState.tsx @@ -12,10 +12,12 @@ type ReceiptEmptyStateProps = { /** Callback to be called on onPress */ onPress?: () => void; + + disabled?: boolean; }; // Returns an SVG icon indicating that the user should attach a receipt -function ReceiptEmptyState({hasError = false, onPress = () => {}}: ReceiptEmptyStateProps) { +function ReceiptEmptyState({hasError = false, onPress = () => {}, disabled = false}: ReceiptEmptyStateProps) { const styles = useThemeStyles(); const {translate} = useLocalize(); @@ -24,6 +26,7 @@ function ReceiptEmptyState({hasError = false, onPress = () => {}}: ReceiptEmptyS accessibilityRole="imagebutton" accessibilityLabel={translate('receipt.upload')} onPress={onPress} + disabled={disabled} style={[styles.alignItemsCenter, styles.justifyContentCenter, styles.moneyRequestViewImage, styles.moneyRequestAttachReceipt, hasError && styles.borderColorDanger]} > )} - {!hasReceipt && canEditReceipt && ( + {!hasReceipt && (canEditReceipt || isAdmin || isApprover) && ( Navigation.navigate( ROUTES.MONEY_REQUEST_STEP_SCAN.getRoute( From ca0650bdd9156a4896da21e1811e808284226eb9 Mon Sep 17 00:00:00 2001 From: Krishna Gupta Date: Fri, 19 Apr 2024 20:22:44 +0530 Subject: [PATCH 25/34] revert margin changes. Signed-off-by: Krishna Gupta --- src/components/ReceiptAudit.tsx | 4 ++-- src/styles/index.ts | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/components/ReceiptAudit.tsx b/src/components/ReceiptAudit.tsx index 7100e1a60842..73539656cd48 100644 --- a/src/components/ReceiptAudit.tsx +++ b/src/components/ReceiptAudit.tsx @@ -14,7 +14,7 @@ function ReceiptAuditHeader({notes = [], showAuditMessage = false}: {notes?: str const issuesFoundText = notes.length > 0 ? translate('iou.receiptIssuesFound', notes.length) : translate('common.verified'); return ( - + {translate('common.receipt')} {showAuditMessage && ( @@ -36,7 +36,7 @@ function ReceiptAuditHeader({notes = [], showAuditMessage = false}: {notes?: str function ReceiptAuditMessages({notes = []}: {notes?: string[]}) { const styles = useThemeStyles(); - return {notes.length > 0 && notes.map((message) => {message})}; + return {notes.length > 0 && notes.map((message) => {message})}; } export {ReceiptAuditHeader, ReceiptAuditMessages}; diff --git a/src/styles/index.ts b/src/styles/index.ts index 85229ffd3fc8..537038d9f2e1 100644 --- a/src/styles/index.ts +++ b/src/styles/index.ts @@ -4296,7 +4296,7 @@ const styles = (theme: ThemeColors) => }, moneyRequestViewImage: { ...spacing.mh5, - ...spacing.mv1, + ...spacing.mv3, overflow: 'hidden', borderWidth: 2, borderColor: theme.cardBG, From 1ae1c5b929bfda75b6e2bb57eecebbb99e922bd5 Mon Sep 17 00:00:00 2001 From: Krishna Gupta Date: Wed, 24 Apr 2024 00:30:24 +0530 Subject: [PATCH 26/34] show audit status only when receipt is scanned. Signed-off-by: Krishna Gupta --- src/components/ReportActionItem/MoneyRequestView.tsx | 3 ++- src/libs/TransactionUtils.ts | 5 +++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/src/components/ReportActionItem/MoneyRequestView.tsx b/src/components/ReportActionItem/MoneyRequestView.tsx index 00014707e5df..141cdcebf4b8 100644 --- a/src/components/ReportActionItem/MoneyRequestView.tsx +++ b/src/components/ReportActionItem/MoneyRequestView.tsx @@ -156,6 +156,7 @@ function MoneyRequestView({ const canEditDistance = ReportUtils.canEditFieldOfMoneyRequest(parentReportAction, CONST.EDIT_REQUEST_FIELD.DISTANCE); const hasReceipt = TransactionUtils.hasReceipt(transaction); const isReceiptBeingScanned = hasReceipt && TransactionUtils.isReceiptBeingScanned(transaction); + const isReceiptScanCompleted = hasReceipt && TransactionUtils.isReceiptScanCompleted(transaction); const isAdmin = policy?.role === 'admin'; const isApprover = ReportUtils.isMoneyRequestReport(moneyRequestReport) && (session?.accountID ?? null) === moneyRequestReport?.managerID; @@ -330,7 +331,7 @@ function MoneyRequestView({ {/* eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing */} {(showMapAsImage || hasReceipt) && ( diff --git a/src/libs/TransactionUtils.ts b/src/libs/TransactionUtils.ts index d6fec8d7344e..2ecb58dd4ba7 100644 --- a/src/libs/TransactionUtils.ts +++ b/src/libs/TransactionUtils.ts @@ -491,6 +491,10 @@ function isReceiptBeingScanned(transaction: OnyxEntry): boolean { return [CONST.IOU.RECEIPT_STATE.SCANREADY, CONST.IOU.RECEIPT_STATE.SCANNING].some((value) => value === transaction?.receipt?.state); } +function isReceiptScanCompleted(transaction: OnyxEntry): boolean { + return [CONST.IOU.RECEIPT_STATE.SCANCOMPLETE].some((value) => value === transaction?.receipt?.state); +} + /** * Check if the transaction has a non-smartscanning receipt and is missing required fields */ @@ -687,6 +691,7 @@ export { hasEReceipt, hasRoute, isReceiptBeingScanned, + isReceiptScanCompleted, getValidWaypoints, isDistanceRequest, isFetchingWaypointsFromServer, From 2c9ab1ea77929d20d8b28174fb2af0d7c73aef3c Mon Sep 17 00:00:00 2001 From: Krishna Gupta Date: Wed, 24 Apr 2024 16:18:35 +0530 Subject: [PATCH 27/34] fix: disabled receipt cursor style. Signed-off-by: Krishna Gupta --- src/components/ReceiptEmptyState.tsx | 1 + 1 file changed, 1 insertion(+) diff --git a/src/components/ReceiptEmptyState.tsx b/src/components/ReceiptEmptyState.tsx index abc025814096..71d64c7483f1 100644 --- a/src/components/ReceiptEmptyState.tsx +++ b/src/components/ReceiptEmptyState.tsx @@ -27,6 +27,7 @@ function ReceiptEmptyState({hasError = false, onPress = () => {}, disabled = fal accessibilityLabel={translate('receipt.upload')} onPress={onPress} disabled={disabled} + disabledStyle={styles.cursorDefault} style={[styles.alignItemsCenter, styles.justifyContentCenter, styles.moneyRequestViewImage, styles.moneyRequestAttachReceipt, hasError && styles.borderColorDanger]} > Date: Fri, 26 Apr 2024 02:14:59 +0530 Subject: [PATCH 28/34] fix: no space between audit message and notes violations. Signed-off-by: Krishna Gupta --- src/components/ReportActionItem/MoneyRequestView.tsx | 1 + 1 file changed, 1 insertion(+) diff --git a/src/components/ReportActionItem/MoneyRequestView.tsx b/src/components/ReportActionItem/MoneyRequestView.tsx index f0b0f3bef613..e0d324db845e 100644 --- a/src/components/ReportActionItem/MoneyRequestView.tsx +++ b/src/components/ReportActionItem/MoneyRequestView.tsx @@ -384,6 +384,7 @@ function MoneyRequestView({ } /> )} + {!(!hasReceipt && (canEditReceipt || isAdmin || isApprover)) && !(showMapAsImage || hasReceipt) && } {shouldShowNotesViolations && } From ace1043b94aed0714ae1946c6903b7b0993f8d19 Mon Sep 17 00:00:00 2001 From: Krishna Gupta Date: Fri, 26 Apr 2024 20:25:25 +0530 Subject: [PATCH 29/34] fix lint warning. Signed-off-by: Krishna Gupta --- src/components/ReportActionItem/MoneyRequestView.tsx | 1 + 1 file changed, 1 insertion(+) diff --git a/src/components/ReportActionItem/MoneyRequestView.tsx b/src/components/ReportActionItem/MoneyRequestView.tsx index e0d324db845e..d20b7be63092 100644 --- a/src/components/ReportActionItem/MoneyRequestView.tsx +++ b/src/components/ReportActionItem/MoneyRequestView.tsx @@ -384,6 +384,7 @@ function MoneyRequestView({ } /> )} + {/* eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing */} {!(!hasReceipt && (canEditReceipt || isAdmin || isApprover)) && !(showMapAsImage || hasReceipt) && } {shouldShowNotesViolations && } From cfbddf1396ad6002653a1cc495c479523c1a57f1 Mon Sep 17 00:00:00 2001 From: Krishna Gupta Date: Tue, 30 Apr 2024 01:23:59 +0530 Subject: [PATCH 30/34] minor updates according to suggestions. Signed-off-by: Krishna Gupta --- src/components/ReceiptAudit.tsx | 8 ++++---- .../MoneyRequestPreviewContent.tsx | 12 +++++------- src/components/ReportActionItem/MoneyRequestView.tsx | 10 +++++----- src/languages/en.ts | 3 +-- src/languages/es.ts | 3 +-- src/libs/TransactionUtils.ts | 10 +++++----- 6 files changed, 21 insertions(+), 25 deletions(-) diff --git a/src/components/ReceiptAudit.tsx b/src/components/ReceiptAudit.tsx index 73539656cd48..3d0435d41930 100644 --- a/src/components/ReceiptAudit.tsx +++ b/src/components/ReceiptAudit.tsx @@ -7,19 +7,19 @@ import Icon from './Icon'; import * as Expensicons from './Icon/Expensicons'; import Text from './Text'; -function ReceiptAuditHeader({notes = [], showAuditMessage = false}: {notes?: string[]; showAuditMessage?: boolean}) { +function ReceiptAuditHeader({notes = [], shouldShowAuditMessage = false}: {notes?: string[]; shouldShowAuditMessage?: boolean}) { const styles = useThemeStyles(); const theme = useTheme(); const {translate} = useLocalize(); - const issuesFoundText = notes.length > 0 ? translate('iou.receiptIssuesFound', notes.length) : translate('common.verified'); + const auditText = notes.length > 0 ? translate('iou.receiptIssuesFound', notes.length) : translate('common.verified'); return ( {translate('common.receipt')} - {showAuditMessage && ( + {shouldShowAuditMessage && ( <> - {` • ${issuesFoundText}`} + {` • ${auditText}`} !!canUseViolations && getViolationsForField(field, data).length > 0, [canUseViolations, getViolationsForField], ); - const noteTypeViolations = transactionViolations?.filter((violation) => violation.type === 'notice').map((v) => ViolationsUtils.getViolationTranslation(v, translate)); + const noticeTypeViolations = transactionViolations?.filter((violation) => violation.type === 'notice').map((v) => ViolationsUtils.getViolationTranslation(v, translate)); const shouldShowNotesViolations = !isReceiptBeingScanned && canUseViolations && ReportUtils.isPaidGroupPolicy(report); let amountDescription = `${translate('iou.amount')}`; @@ -333,8 +333,8 @@ function MoneyRequestView({ {shouldShowAnimatedBackground && } {/* eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing */} {(showMapAsImage || hasReceipt) && ( @@ -386,7 +386,7 @@ function MoneyRequestView({ )} {/* eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing */} {!(!hasReceipt && (canEditReceipt || isAdmin || isApprover)) && !(showMapAsImage || hasReceipt) && } - {shouldShowNotesViolations && } + {shouldShowNotesViolations && } `${count === 1 ? 'Issue' : 'Issues'} found`, - routePending: 'Pending...', fieldPending: 'Pending...', defaultRate: 'Default rate', receiptScanning: 'Scan in progress…', diff --git a/src/languages/es.ts b/src/languages/es.ts index 772aa3f9fa31..28acc79fa2f9 100644 --- a/src/languages/es.ts +++ b/src/languages/es.ts @@ -287,7 +287,7 @@ export default { nonBillable: 'No facturable', tag: 'Etiqueta', receipt: 'Recibo', - verified: `Verificado`, + verified: 'Verificado', replace: 'Sustituir', distance: 'Distancia', mile: 'milla', @@ -628,7 +628,6 @@ export default { posted: 'Contabilizado', deleteReceipt: 'Eliminar recibo', receiptIssuesFound: (count: number) => `${count === 1 ? 'Problema' : 'Problemas'}`, - routePending: 'Pendiente...', fieldPending: 'Pendiente...', defaultRate: 'Tasa predeterminada', receiptScanning: 'Escaneo en curso…', diff --git a/src/libs/TransactionUtils.ts b/src/libs/TransactionUtils.ts index 2ecb58dd4ba7..8059e6e3318c 100644 --- a/src/libs/TransactionUtils.ts +++ b/src/libs/TransactionUtils.ts @@ -491,7 +491,7 @@ function isReceiptBeingScanned(transaction: OnyxEntry): boolean { return [CONST.IOU.RECEIPT_STATE.SCANREADY, CONST.IOU.RECEIPT_STATE.SCANNING].some((value) => value === transaction?.receipt?.state); } -function isReceiptScanCompleted(transaction: OnyxEntry): boolean { +function didRceiptScanSucceed(transaction: OnyxEntry): boolean { return [CONST.IOU.RECEIPT_STATE.SCANCOMPLETE].some((value) => value === transaction?.receipt?.state); } @@ -600,9 +600,9 @@ function hasViolation(transactionID: string, transactionViolations: OnyxCollecti } /** - * Checks if any violations for the provided transaction are of type 'note' + * Checks if any violations for the provided transaction are of type 'notice' */ -function hasNoteTypeViolation(transactionID: string, transactionViolations: OnyxCollection): boolean { +function hasNoticeTypeViolation(transactionID: string, transactionViolations: OnyxCollection): boolean { return Boolean(transactionViolations?.[ONYXKEYS.COLLECTION.TRANSACTION_VIOLATIONS + transactionID]?.some((violation: TransactionViolation) => violation.type === 'notice')); } @@ -691,7 +691,7 @@ export { hasEReceipt, hasRoute, isReceiptBeingScanned, - isReceiptScanCompleted, + didRceiptScanSucceed, getValidWaypoints, isDistanceRequest, isFetchingWaypointsFromServer, @@ -711,7 +711,7 @@ export { waypointHasValidAddress, getRecentTransactions, hasViolation, - hasNoteTypeViolation, + hasNoticeTypeViolation, isCustomUnitRateIDForP2P, getRateID, }; From a0a2fc3ca95f77871813a88ec15ae5ab378912d7 Mon Sep 17 00:00:00 2001 From: Krishna Gupta Date: Tue, 30 Apr 2024 01:55:21 +0530 Subject: [PATCH 31/34] second commit: minor updates according to suggestions. Signed-off-by: Krishna Gupta --- src/components/ReceiptAudit.tsx | 2 +- src/components/ReportActionItem/MoneyRequestView.tsx | 4 ++-- src/languages/es.ts | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/components/ReceiptAudit.tsx b/src/components/ReceiptAudit.tsx index 3d0435d41930..8ce9863e32ee 100644 --- a/src/components/ReceiptAudit.tsx +++ b/src/components/ReceiptAudit.tsx @@ -7,7 +7,7 @@ import Icon from './Icon'; import * as Expensicons from './Icon/Expensicons'; import Text from './Text'; -function ReceiptAuditHeader({notes = [], shouldShowAuditMessage = false}: {notes?: string[]; shouldShowAuditMessage?: boolean}) { +function ReceiptAuditHeader({notes, shouldShowAuditMessage}: {notes: string[]; shouldShowAuditMessage: boolean}) { const styles = useThemeStyles(); const theme = useTheme(); const {translate} = useLocalize(); diff --git a/src/components/ReportActionItem/MoneyRequestView.tsx b/src/components/ReportActionItem/MoneyRequestView.tsx index 4376ced21604..5494262680d5 100644 --- a/src/components/ReportActionItem/MoneyRequestView.tsx +++ b/src/components/ReportActionItem/MoneyRequestView.tsx @@ -187,7 +187,7 @@ function MoneyRequestView({ (field: ViolationField, data?: OnyxTypes.TransactionViolation['data']): boolean => !!canUseViolations && getViolationsForField(field, data).length > 0, [canUseViolations, getViolationsForField], ); - const noticeTypeViolations = transactionViolations?.filter((violation) => violation.type === 'notice').map((v) => ViolationsUtils.getViolationTranslation(v, translate)); + const noticeTypeViolations = transactionViolations?.filter((violation) => violation.type === 'notice').map((v) => ViolationsUtils.getViolationTranslation(v, translate)) ?? []; const shouldShowNotesViolations = !isReceiptBeingScanned && canUseViolations && ReportUtils.isPaidGroupPolicy(report); let amountDescription = `${translate('iou.amount')}`; @@ -334,7 +334,7 @@ function MoneyRequestView({ {/* eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing */} {(showMapAsImage || hasReceipt) && ( diff --git a/src/languages/es.ts b/src/languages/es.ts index 28acc79fa2f9..33c3f3d9aba3 100644 --- a/src/languages/es.ts +++ b/src/languages/es.ts @@ -627,7 +627,7 @@ export default { canceled: 'Canceló', posted: 'Contabilizado', deleteReceipt: 'Eliminar recibo', - receiptIssuesFound: (count: number) => `${count === 1 ? 'Problema' : 'Problemas'}`, + receiptIssuesFound: (count: number) => `${count === 1 ? 'Problema' : 'Problemas'} encontrado`, fieldPending: 'Pendiente...', defaultRate: 'Tasa predeterminada', receiptScanning: 'Escaneo en curso…', From 9fbf78e82eeae5345d45889219dcde194bbf3842 Mon Sep 17 00:00:00 2001 From: Krishna Gupta Date: Tue, 30 Apr 2024 02:08:25 +0530 Subject: [PATCH 32/34] third commit: minor updates according to suggestions. Signed-off-by: Krishna Gupta --- src/components/ReportActionItem/MoneyRequestView.tsx | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/components/ReportActionItem/MoneyRequestView.tsx b/src/components/ReportActionItem/MoneyRequestView.tsx index 5494262680d5..7a88ef7172e4 100644 --- a/src/components/ReportActionItem/MoneyRequestView.tsx +++ b/src/components/ReportActionItem/MoneyRequestView.tsx @@ -328,6 +328,9 @@ function MoneyRequestView({ ); + const shouldShowReceiptEmptyState = !hasReceipt && (canEditReceipt || isAdmin || isApprover); + const shouldShowMapOrReceipt = showMapAsImage ?? hasReceipt; + return ( {shouldShowAnimatedBackground && } @@ -337,7 +340,7 @@ function MoneyRequestView({ shouldShowAuditMessage={Boolean(shouldShowNotesViolations && didRceiptScanSucceed)} /> {/* eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing */} - {(showMapAsImage || hasReceipt) && ( + {shouldShowMapOrReceipt && ( )} - {!hasReceipt && (canEditReceipt || isAdmin || isApprover) && ( + {shouldShowReceiptEmptyState && ( )} {/* eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing */} - {!(!hasReceipt && (canEditReceipt || isAdmin || isApprover)) && !(showMapAsImage || hasReceipt) && } + {!shouldShowReceiptEmptyState && !shouldShowMapOrReceipt && } {shouldShowNotesViolations && } From e117ef520000a22f6cb53d32369efd599601d768 Mon Sep 17 00:00:00 2001 From: Krishna Gupta Date: Tue, 30 Apr 2024 02:38:35 +0530 Subject: [PATCH 33/34] fourth commit: minor updates according to suggestions. Signed-off-by: Krishna Gupta --- src/components/ReportActionItem/MoneyRequestView.tsx | 3 ++- src/languages/es.ts | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/components/ReportActionItem/MoneyRequestView.tsx b/src/components/ReportActionItem/MoneyRequestView.tsx index 01118fd766ba..36f5d7219dfa 100644 --- a/src/components/ReportActionItem/MoneyRequestView.tsx +++ b/src/components/ReportActionItem/MoneyRequestView.tsx @@ -334,7 +334,8 @@ function MoneyRequestView({ ); const shouldShowReceiptEmptyState = !hasReceipt && (canEditReceipt || isAdmin || isApprover); - const shouldShowMapOrReceipt = showMapAsImage ?? hasReceipt; + /* eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing */ + const shouldShowMapOrReceipt = showMapAsImage || hasReceipt; return ( diff --git a/src/languages/es.ts b/src/languages/es.ts index e30f5ecd8553..f132fe15027a 100644 --- a/src/languages/es.ts +++ b/src/languages/es.ts @@ -629,7 +629,7 @@ export default { canceled: 'Canceló', posted: 'Contabilizado', deleteReceipt: 'Eliminar recibo', - receiptIssuesFound: (count: number) => `${count === 1 ? 'Problema' : 'Problemas'} encontrado`, + receiptIssuesFound: (count: number) => `${count === 1 ? 'Problema encontrado' : 'Problemas encontrados'}`, fieldPending: 'Pendiente...', defaultRate: 'Tasa predeterminada', receiptScanning: 'Escaneo en curso…', From 22e6fcbb9a1a65897c9d2d40222a528fb6bb4cc4 Mon Sep 17 00:00:00 2001 From: Krishna Gupta Date: Tue, 30 Apr 2024 04:53:57 +0530 Subject: [PATCH 34/34] 5th commit: minor updates according to suggestions. Signed-off-by: Krishna Gupta --- src/components/MoneyRequestHeader.tsx | 2 +- src/components/ReceiptAudit.tsx | 2 +- .../ReportActionItem/MoneyRequestView.tsx | 15 ++++++--------- 3 files changed, 8 insertions(+), 11 deletions(-) diff --git a/src/components/MoneyRequestHeader.tsx b/src/components/MoneyRequestHeader.tsx index 5db2839654a0..6f5c54325d88 100644 --- a/src/components/MoneyRequestHeader.tsx +++ b/src/components/MoneyRequestHeader.tsx @@ -78,7 +78,7 @@ function MoneyRequestHeader({ // Only the requestor can take delete the expense, admins can only edit it. const isActionOwner = typeof parentReportAction?.actorAccountID === 'number' && typeof session?.accountID === 'number' && parentReportAction.actorAccountID === session?.accountID; const isPolicyAdmin = policy?.role === CONST.POLICY.ROLE.ADMIN; - const isApprover = ReportUtils.isMoneyRequestReport(moneyRequestReport) && (session?.accountID ?? null) === moneyRequestReport?.managerID; + const isApprover = ReportUtils.isMoneyRequestReport(moneyRequestReport) && moneyRequestReport?.managerID !== null && session?.accountID === moneyRequestReport?.managerID; const deleteTransaction = useCallback(() => { if (parentReportAction) { diff --git a/src/components/ReceiptAudit.tsx b/src/components/ReceiptAudit.tsx index 8ce9863e32ee..ac1b36c6bf32 100644 --- a/src/components/ReceiptAudit.tsx +++ b/src/components/ReceiptAudit.tsx @@ -23,7 +23,7 @@ function ReceiptAuditHeader({notes, shouldShowAuditMessage}: {notes: string[]; s 0 ? Expensicons.DotIndicator : Expensicons.Checkmark} + src={notes.length ? Expensicons.DotIndicator : Expensicons.Checkmark} fill={notes.length ? theme.danger : theme.success} additionalStyles={styles.ml1} /> diff --git a/src/components/ReportActionItem/MoneyRequestView.tsx b/src/components/ReportActionItem/MoneyRequestView.tsx index 36f5d7219dfa..a26c368ae170 100644 --- a/src/components/ReportActionItem/MoneyRequestView.tsx +++ b/src/components/ReportActionItem/MoneyRequestView.tsx @@ -128,7 +128,7 @@ function MoneyRequestView({ const isEmptyMerchant = transactionMerchant === '' || transactionMerchant === CONST.TRANSACTION.PARTIAL_TRANSACTION_MERCHANT; const isDistanceRequest = TransactionUtils.isDistanceRequest(transaction); const formattedTransactionAmount = transactionAmount ? CurrencyUtils.convertToDisplayString(transactionAmount, transactionCurrency) : ''; - const hasPendingWaypoints = transaction?.pendingFields?.waypoints; + const hasPendingWaypoints = Boolean(transaction?.pendingFields?.waypoints); const showMapAsImage = isDistanceRequest && hasPendingWaypoints; const formattedOriginalAmount = transactionOriginalAmount && transactionOriginalCurrency && CurrencyUtils.convertToDisplayString(transactionOriginalAmount, transactionOriginalCurrency); const isCardTransaction = TransactionUtils.isCardTransaction(transaction); @@ -161,7 +161,7 @@ function MoneyRequestView({ const canEditDistance = ReportUtils.canEditFieldOfMoneyRequest(parentReportAction, CONST.EDIT_REQUEST_FIELD.DISTANCE) && !isTrackExpense; const isAdmin = policy?.role === 'admin'; - const isApprover = ReportUtils.isMoneyRequestReport(moneyRequestReport) && (session?.accountID ?? null) === moneyRequestReport?.managerID; + const isApprover = ReportUtils.isMoneyRequestReport(moneyRequestReport) && moneyRequestReport?.managerID !== null && session?.accountID === moneyRequestReport?.managerID; // A flag for verifying that the current report is a sub-report of a workspace chat // if the policy of the report is either Collect or Control, then this report must be tied to workspace chat const isPolicyExpenseChat = ReportUtils.isGroupPolicy(report); @@ -187,8 +187,6 @@ function MoneyRequestView({ (field: ViolationField, data?: OnyxTypes.TransactionViolation['data']): boolean => !!canUseViolations && getViolationsForField(field, data).length > 0, [canUseViolations, getViolationsForField], ); - const noticeTypeViolations = transactionViolations?.filter((violation) => violation.type === 'notice').map((v) => ViolationsUtils.getViolationTranslation(v, translate)) ?? []; - const shouldShowNotesViolations = !isReceiptBeingScanned && canUseViolations && ReportUtils.isPaidGroupPolicy(report); let amountDescription = `${translate('iou.amount')}`; @@ -333,9 +331,10 @@ function MoneyRequestView({ ); - const shouldShowReceiptEmptyState = !hasReceipt && (canEditReceipt || isAdmin || isApprover); - /* eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing */ const shouldShowMapOrReceipt = showMapAsImage || hasReceipt; + const shouldShowReceiptEmptyState = !hasReceipt && (canEditReceipt || isAdmin || isApprover); + const noticeTypeViolations = transactionViolations?.filter((violation) => violation.type === 'notice').map((v) => ViolationsUtils.getViolationTranslation(v, translate)) ?? []; + const shouldShowNotesViolations = !isReceiptBeingScanned && canUseViolations && ReportUtils.isPaidGroupPolicy(report); return ( @@ -345,7 +344,6 @@ function MoneyRequestView({ notes={noticeTypeViolations} shouldShowAuditMessage={Boolean(shouldShowNotesViolations && didRceiptScanSucceed)} /> - {/* eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing */} {shouldShowMapOrReceipt && ( )} - {/* eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing */} {!shouldShowReceiptEmptyState && !shouldShowMapOrReceipt && } {shouldShowNotesViolations && } - + {canUseViolations && }