From cc29bf95a8a08f7aff37b164525cd2e562065530 Mon Sep 17 00:00:00 2001 From: allgandaf Date: Wed, 30 Sep 2026 10:12:53 +0530 Subject: [PATCH 01/73] add bulk action onyx key and type --- src/CONST/index.ts | 7 +++++++ src/ONYXKEYS.ts | 2 ++ src/types/onyx/BulkAction.ts | 29 +++++++++++++++++++++++++++++ src/types/onyx/index.ts | 2 ++ 4 files changed, 40 insertions(+) create mode 100644 src/types/onyx/BulkAction.ts diff --git a/src/CONST/index.ts b/src/CONST/index.ts index e3658b132257..66a416364edf 100644 --- a/src/CONST/index.ts +++ b/src/CONST/index.ts @@ -604,6 +604,13 @@ const CONST = { RECEIPTS: 'receipts', }, }, + BULK_ACTION: { + STATE: { + RUNNING: 'running', + DONE: 'done', + FAILED: 'failed', + }, + }, SECURE_DOWNLOAD_TYPE: { CSV_EXPORT: 'csvexport', diff --git a/src/ONYXKEYS.ts b/src/ONYXKEYS.ts index 65112e36a7cc..f09a442f69dc 100755 --- a/src/ONYXKEYS.ts +++ b/src/ONYXKEYS.ts @@ -902,6 +902,7 @@ const ONYXKEYS = { DOMAIN: 'domain_', DOWNLOAD: 'download_', EXPORT_DOWNLOAD: 'nvp_exportDownload_', + BULK_ACTION: 'nvp_bulkAction_', POLICY: 'policy_', POLICY_DRAFTS: 'policyDrafts_', POLICY_JOIN_MEMBER: 'policyJoinMember_', @@ -1523,6 +1524,7 @@ type OnyxCollectionValuesMapping = { [ONYXKEYS.COLLECTION.DOMAIN]: OnyxTypes.Domain; [ONYXKEYS.COLLECTION.DOWNLOAD]: OnyxTypes.Download; [ONYXKEYS.COLLECTION.EXPORT_DOWNLOAD]: OnyxTypes.ExportDownload; + [ONYXKEYS.COLLECTION.BULK_ACTION]: OnyxTypes.BulkAction; [ONYXKEYS.COLLECTION.POLICY]: OnyxTypes.Policy; [ONYXKEYS.COLLECTION.POLICY_DRAFTS]: OnyxTypes.Policy; [ONYXKEYS.COLLECTION.RULE]: OnyxTypes.Rule; diff --git a/src/types/onyx/BulkAction.ts b/src/types/onyx/BulkAction.ts new file mode 100644 index 000000000000..745fe159c54d --- /dev/null +++ b/src/types/onyx/BulkAction.ts @@ -0,0 +1,29 @@ +import type CONST from '@src/CONST'; + +import type {ValueOf} from 'type-fest'; + +/** Possible states of a bulk action */ +type BulkActionState = ValueOf; + +/** Bulk actions from Search "Select all" that run on the backend */ +type BulkActionType = typeof CONST.SEARCH.BULK_ACTION_TYPES.APPROVE | typeof CONST.SEARCH.BULK_ACTION_TYPES.SUBMIT | typeof CONST.SEARCH.BULK_ACTION_TYPES.PAY; + +/** Model of a bulk action started from Search "Select all" */ +type BulkAction = { + state: BulkActionState; + + /** Which action is running on the matching reports */ + action: BulkActionType; + + /** Number of reports the action ran on, set once it is done */ + total?: number; + + /** Reports the action couldn't be done on, set once it is done */ + failedReportIDs?: string[]; + + /** Whether Concierge should message the result instead of showing it here */ + shouldSendFromConcierge?: boolean; +}; + +export default BulkAction; +export type {BulkActionType}; diff --git a/src/types/onyx/index.ts b/src/types/onyx/index.ts index fed8a4d0d576..45dbcd5f7f07 100644 --- a/src/types/onyx/index.ts +++ b/src/types/onyx/index.ts @@ -23,6 +23,7 @@ import type BillingGraceEndPeriod from './BillingGraceEndPeriod'; import type BillingReceiptDetails from './BillingReceiptDetails'; import type BillingStatus from './BillingStatus'; import type BlockedFromConcierge from './BlockedFromConcierge'; +import type BulkAction from './BulkAction'; import type CancellationDetails from './CancellationDetails'; import type Card from './Card'; import type {CardList, IssueNewCard, ProvisioningCardData, WorkspaceCardsList} from './Card'; @@ -258,6 +259,7 @@ export type { Domain, Download, ExportDownload, + BulkAction, DuplicateWorkspace, CopyPolicySettingsNVP, CopyPolicySettings, From 69c52be8aea672cb312757fbea70ec990a33d3bb Mon Sep 17 00:00:00 2001 From: allgandaf Date: Wed, 30 Sep 2026 10:12:54 +0530 Subject: [PATCH 02/73] add concierge and clear commands for bulk actions --- .../API/parameters/ClearBulkActionParams.ts | 5 + ...endBulkActionSummaryFromConciergeParams.ts | 5 + src/libs/API/parameters/index.ts | 2 + src/libs/API/types.ts | 4 + src/libs/actions/BulkAction.ts | 93 +++++++++++++++++++ 5 files changed, 109 insertions(+) create mode 100644 src/libs/API/parameters/ClearBulkActionParams.ts create mode 100644 src/libs/API/parameters/SendBulkActionSummaryFromConciergeParams.ts create mode 100644 src/libs/actions/BulkAction.ts diff --git a/src/libs/API/parameters/ClearBulkActionParams.ts b/src/libs/API/parameters/ClearBulkActionParams.ts new file mode 100644 index 000000000000..0686398c72d9 --- /dev/null +++ b/src/libs/API/parameters/ClearBulkActionParams.ts @@ -0,0 +1,5 @@ +type ClearBulkActionParams = { + bulkActionID: string; +}; + +export default ClearBulkActionParams; diff --git a/src/libs/API/parameters/SendBulkActionSummaryFromConciergeParams.ts b/src/libs/API/parameters/SendBulkActionSummaryFromConciergeParams.ts new file mode 100644 index 000000000000..547c3584cd47 --- /dev/null +++ b/src/libs/API/parameters/SendBulkActionSummaryFromConciergeParams.ts @@ -0,0 +1,5 @@ +type SendBulkActionSummaryFromConciergeParams = { + bulkActionID: string; +}; + +export default SendBulkActionSummaryFromConciergeParams; diff --git a/src/libs/API/parameters/index.ts b/src/libs/API/parameters/index.ts index 9bdcfb093ba1..306f45d02d0d 100644 --- a/src/libs/API/parameters/index.ts +++ b/src/libs/API/parameters/index.ts @@ -660,6 +660,8 @@ export type {default as DeleteAgentParams} from './DeleteAgentParams'; export type {default as ResendValidateCodeParams} from './ResendValidateCodeParams'; export type {default as SendExportFileFromConciergeParams} from './SendExportFileFromConciergeParams'; export type {default as ClearExportDownloadParams} from './ClearExportDownloadParams'; +export type {default as SendBulkActionSummaryFromConciergeParams} from './SendBulkActionSummaryFromConciergeParams'; +export type {default as ClearBulkActionParams} from './ClearBulkActionParams'; export type {default as UpgradeSubmitParams} from './UpgradeSubmitParams'; export type {default as UploadOFXParams} from './UploadOFXParams'; export type {default as UploadUserKYBDocsParams} from './UploadUserKYBDocsParams'; diff --git a/src/libs/API/types.ts b/src/libs/API/types.ts index f97a40fa8a63..cc6d8eebf708 100644 --- a/src/libs/API/types.ts +++ b/src/libs/API/types.ts @@ -734,6 +734,8 @@ const WRITE_COMMANDS = { DELETE_AGENT: 'DeleteAgent', SEND_EXPORT_FILE_FROM_CONCIERGE: 'SendExportFileFromConcierge', CLEAR_EXPORT_DOWNLOAD: 'ClearExportDownload', + SEND_BULK_ACTION_SUMMARY_FROM_CONCIERGE: 'SendBulkActionSummaryFromConcierge', + CLEAR_BULK_ACTION: 'ClearBulkAction', UPGRADE_SUBMIT: 'UpgradeSubmit', UPLOAD_USER_KYB_DOCS: 'UploadUserKYBDocs', JOIN_REPORT_VIA_SECURE_LINK: 'JoinReportViaSecureLink', @@ -1496,6 +1498,8 @@ type WriteCommandParameters = { [WRITE_COMMANDS.DELETE_AGENT]: Parameters.DeleteAgentParams; [WRITE_COMMANDS.SEND_EXPORT_FILE_FROM_CONCIERGE]: Parameters.SendExportFileFromConciergeParams; [WRITE_COMMANDS.CLEAR_EXPORT_DOWNLOAD]: Parameters.ClearExportDownloadParams; + [WRITE_COMMANDS.SEND_BULK_ACTION_SUMMARY_FROM_CONCIERGE]: Parameters.SendBulkActionSummaryFromConciergeParams; + [WRITE_COMMANDS.CLEAR_BULK_ACTION]: Parameters.ClearBulkActionParams; }; const READ_COMMANDS = { diff --git a/src/libs/actions/BulkAction.ts b/src/libs/actions/BulkAction.ts new file mode 100644 index 000000000000..950008224428 --- /dev/null +++ b/src/libs/actions/BulkAction.ts @@ -0,0 +1,93 @@ +import {write} from '@libs/API'; +import {WRITE_COMMANDS} from '@libs/API/types'; +import {rand64} from '@libs/NumberUtils'; + +import CONST from '@src/CONST'; +import ONYXKEYS from '@src/ONYXKEYS'; +import type BulkAction from '@src/types/onyx/BulkAction'; +import type {BulkActionType} from '@src/types/onyx/BulkAction'; +import type {AnyOnyxUpdate} from '@src/types/onyx/Request'; + +import type {OnyxEntry} from 'react-native-onyx'; + +import Onyx from 'react-native-onyx'; + +// bulkActionIDs this tab started during the current page load, so a bulk action started in another tab +// doesn't pop the modal open here until this tab reloads. +const locallyInitiatedBulkActionIDs = new Set(); + +function wasBulkActionInitiatedLocally(bulkActionID: string): boolean { + return locallyInitiatedBulkActionIDs.has(bulkActionID); +} + +/** Starts a bulk action record that the backend moves to done once the action ran on every matching report */ +function buildBulkActionOnyxData(action: BulkActionType) { + const bulkActionID = rand64(); + locallyInitiatedBulkActionIDs.add(bulkActionID); + const onyxKey = `${ONYXKEYS.COLLECTION.BULK_ACTION}${bulkActionID}` as const; + + const optimisticData: AnyOnyxUpdate[] = [ + { + onyxMethod: Onyx.METHOD.SET, + key: onyxKey, + value: {state: CONST.BULK_ACTION.STATE.RUNNING, action}, + }, + ]; + + const failureData: AnyOnyxUpdate[] = [ + { + onyxMethod: Onyx.METHOD.SET, + key: onyxKey, + value: {state: CONST.BULK_ACTION.STATE.FAILED, action}, + }, + ]; + + return {bulkActionID, onyxData: {optimisticData, failureData}}; +} + +function sendBulkActionSummaryFromConcierge(bulkActionID: string, bulkAction: OnyxEntry) { + const onyxKey = `${ONYXKEYS.COLLECTION.BULK_ACTION}${bulkActionID}` as const; + + const optimisticData: AnyOnyxUpdate[] = [ + { + onyxMethod: Onyx.METHOD.MERGE, + key: onyxKey, + value: {shouldSendFromConcierge: true}, + }, + ]; + + const failureData: AnyOnyxUpdate[] = [ + { + onyxMethod: Onyx.METHOD.MERGE, + key: onyxKey, + value: {shouldSendFromConcierge: bulkAction?.shouldSendFromConcierge ?? null}, + }, + ]; + + write(WRITE_COMMANDS.SEND_BULK_ACTION_SUMMARY_FROM_CONCIERGE, {bulkActionID}, {optimisticData, failureData}); +} + +function clearBulkAction(bulkActionID: string, bulkAction: OnyxEntry) { + locallyInitiatedBulkActionIDs.delete(bulkActionID); + const onyxKey = `${ONYXKEYS.COLLECTION.BULK_ACTION}${bulkActionID}` as const; + + const optimisticData: AnyOnyxUpdate[] = [ + { + onyxMethod: Onyx.METHOD.SET, + key: onyxKey, + value: null, + }, + ]; + + const failureData: AnyOnyxUpdate[] = [ + { + onyxMethod: Onyx.METHOD.SET, + key: onyxKey, + value: bulkAction ?? null, + }, + ]; + + write(WRITE_COMMANDS.CLEAR_BULK_ACTION, {bulkActionID}, {optimisticData, failureData}); +} + +export {buildBulkActionOnyxData, sendBulkActionSummaryFromConcierge, clearBulkAction, wasBulkActionInitiatedLocally}; From 7a9b338d4a19f96311e628ae826d352d35b1c63a Mon Sep 17 00:00:00 2001 From: allgandaf Date: Wed, 30 Sep 2026 10:12:55 +0530 Subject: [PATCH 03/73] add bulk action copy --- src/languages/en.ts | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/src/languages/en.ts b/src/languages/en.ts index e6238285d594..63e424c1425f 100644 --- a/src/languages/en.ts +++ b/src/languages/en.ts @@ -11566,6 +11566,25 @@ const translations = { `${count} of ${total} reports exported. If it didn't automatically download, use the button below. See which reports failed in Concierge.`, close: 'Close', }, + bulkAction: { + approvingTitle: 'Approving reports...', + submittingTitle: 'Submitting reports...', + payingTitle: 'Marking reports as paid...', + runningBody: "This can take a few minutes. You can wait here, or Concierge can message you when it's done.", + sendFromConcierge: "Message me when it's done", + conciergeTitle: 'You bet!', + conciergeBody: "Concierge will message you when it's done.", + goToConcierge: 'Go to Concierge', + approvedTitle: ({count, total}: {count: number; total: number}) => `Approved ${count} of ${total} ${total === 1 ? 'report' : 'reports'}`, + submittedTitle: ({count, total}: {count: number; total: number}) => `Submitted ${count} of ${total} ${total === 1 ? 'report' : 'reports'}`, + paidTitle: ({count, total}: {count: number; total: number}) => `Marked ${count} of ${total} ${total === 1 ? 'report' : 'reports'} as paid`, + noReportsTitle: 'No matching reports', + noReportsBody: 'None of the reports you selected needed this action.', + failedReportsBody: ({count}: {count: number}) => (count === 1 ? "1 report couldn't be updated." : `${count} reports couldn't be updated.`), + viewFailedReports: 'View reports', + failedTitle: 'Something went wrong', + failedBody: 'This action could not be started. Please try again later.', + }, domain: { notVerified: 'Not verified', retry: 'Retry', From f968d940c3df8027e95d2186782886991c8c327a Mon Sep 17 00:00:00 2001 From: allgandaf Date: Wed, 30 Sep 2026 10:12:55 +0530 Subject: [PATCH 04/73] translate bulk action copy --- src/languages/de.ts | 19 +++++++++++++++++++ src/languages/el.ts | 19 +++++++++++++++++++ src/languages/es.ts | 19 +++++++++++++++++++ src/languages/fr.ts | 19 +++++++++++++++++++ src/languages/it.ts | 19 +++++++++++++++++++ src/languages/ja.ts | 19 +++++++++++++++++++ src/languages/nl.ts | 19 +++++++++++++++++++ src/languages/pl.ts | 19 +++++++++++++++++++ src/languages/pt-BR.ts | 19 +++++++++++++++++++ src/languages/zh-hans.ts | 19 +++++++++++++++++++ 10 files changed, 190 insertions(+) diff --git a/src/languages/de.ts b/src/languages/de.ts index 8c81ffbc2324..9627a4c684c2 100644 --- a/src/languages/de.ts +++ b/src/languages/de.ts @@ -11597,5 +11597,24 @@ Hier ist ein *Testbeleg*, um dir zu zeigen, wie es funktioniert:`, description: `Erstellen Sie benutzerdefinierte Agenten, die Ausgaben anhand Ihrer Regeln prüfen, genehmigen und weiterleiten. Mehr erfahren.`, }, }, + bulkAction: { + approvingTitle: 'Berichte werden genehmigt …', + submittingTitle: 'Berichte werden eingereicht …', + payingTitle: 'Berichte werden als bezahlt markiert …', + runningBody: 'Dies kann einige Minuten dauern. Sie können hier warten, oder Concierge kann Ihnen eine Nachricht senden, wenn es fertig ist.', + sendFromConcierge: 'Schreiben Sie mir eine Nachricht, wenn es erledigt ist', + conciergeTitle: 'Auf jeden Fall!', + conciergeBody: 'Concierge wird Ihnen eine Nachricht senden, sobald es fertig ist.', + goToConcierge: 'Zu Concierge', + approvedTitle: ({count, total}: {count: number; total: number}) => `${count} von ${total} ${total === 1 ? 'Bericht' : 'Berichte'} genehmigt`, + submittedTitle: ({count, total}: {count: number; total: number}) => `${count} von ${total} ${total === 1 ? 'Bericht' : 'Berichte'} eingereicht`, + paidTitle: ({count, total}: {count: number; total: number}) => `${count} von ${total} ${total === 1 ? 'Bericht' : 'Berichte'} als bezahlt markiert`, + noReportsTitle: 'Keine übereinstimmenden Berichte', + noReportsBody: 'Keiner der von Ihnen ausgewählten Berichte benötigte diese Aktion.', + failedReportsBody: ({count}: {count: number}) => (count === 1 ? '1 Bericht konnte nicht aktualisiert werden.' : `${count} Berichte konnten nicht aktualisiert werden.`), + viewFailedReports: 'Berichte anzeigen', + failedTitle: 'Es ist ein Fehler aufgetreten', + failedBody: 'Diese Aktion konnte nicht gestartet werden. Bitte versuchen Sie es später noch einmal.', + }, }; export default translations; diff --git a/src/languages/el.ts b/src/languages/el.ts index 6f4635c59470..9183941789cd 100644 --- a/src/languages/el.ts +++ b/src/languages/el.ts @@ -11840,5 +11840,24 @@ ${reportName}`, employeePays: 'Ο εργαζόμενος πληρώνει', errorMessage: 'Δεν ήταν δυνατή η αλλαγή της προτίμησης χρέωσης μετατροπής νομίσματος. Παρακαλούμε δοκιμάστε ξανά ή επικοινωνήστε με την υποστήριξη.', }, + bulkAction: { + approvingTitle: 'Γίνεται έγκριση αναφορών...', + submittingTitle: 'Υποβολή αναφορών...', + payingTitle: 'Σημειώνονται οι αναφορές ως πληρωμένες...', + runningBody: 'Αυτό μπορεί να πάρει μερικά λεπτά. Μπορείτε να περιμένετε εδώ ή ο Concierge μπορεί να σας στείλει μήνυμα όταν ολοκληρωθεί.', + sendFromConcierge: 'Στείλτε μου μήνυμα όταν τελειώσει', + conciergeTitle: 'Βεβαίως!', + conciergeBody: 'Ο Concierge θα σας στείλει μήνυμα όταν ολοκληρωθεί.', + goToConcierge: 'Μετάβαση στο Concierge', + approvedTitle: ({count, total}: {count: number; total: number}) => `Εγκρίθηκαν ${count} από ${total} ${total === 1 ? 'αναφορά' : 'αναφορές'}`, + submittedTitle: ({count, total}: {count: number; total: number}) => `Υποβλήθηκαν ${count} από ${total} ${total === 1 ? 'αναφορά' : 'αναφορές'}`, + paidTitle: ({count, total}: {count: number; total: number}) => `Σημειώθηκαν ως πληρωμένα τα ${count} από ${total} ${total === 1 ? 'αναφορά' : 'αναφορές'}`, + noReportsTitle: 'Δεν υπάρχουν αντιστοιχίες αναφορών', + noReportsBody: 'Κανένα από τα αναφορικά που επιλέξατε δεν χρειαζόταν αυτή την ενέργεια.', + failedReportsBody: ({count}: {count: number}) => (count === 1 ? '1 αναφορά δεν μπόρεσε να ενημερωθεί.' : `${count} αναφορές δεν ήταν δυνατό να ενημερωθούν.`), + viewFailedReports: 'Προβολή αναφορών', + failedTitle: 'Κάτι πήγε στραβά', + failedBody: 'Αυτή η ενέργεια δεν μπόρεσε να ξεκινήσει. Παρακαλούμε δοκιμάστε ξανά αργότερα.', + }, }; export default translations; diff --git a/src/languages/es.ts b/src/languages/es.ts index 080f2174e63f..7d59ed0c8d57 100644 --- a/src/languages/es.ts +++ b/src/languages/es.ts @@ -11868,5 +11868,24 @@ ${reportName}`, description: `Crea agentes personalizados para revisar, aprobar y asignar gastos según las reglas que configures. Más información.`, }, }, + bulkAction: { + approvingTitle: 'Aprobando informes...', + submittingTitle: 'Enviando informes...', + payingTitle: 'Marcando informes como pagados...', + runningBody: 'Esto puede tardar unos minutos. Puedes esperar aquí o Concierge puede enviarte un mensaje cuando haya terminado.', + sendFromConcierge: 'Envíame un mensaje cuando esté listo', + conciergeTitle: '¡Por supuesto!', + conciergeBody: 'Concierge te enviará un mensaje cuando haya terminado.', + goToConcierge: 'Ir a Concierge', + approvedTitle: ({count, total}: {count: number; total: number}) => `Aprobados ${count} de ${total} ${total === 1 ? 'informe' : 'informes'}`, + submittedTitle: ({count, total}: {count: number; total: number}) => `Enviado ${count} de ${total} ${total === 1 ? 'informe' : 'informes'}`, + paidTitle: ({count, total}: {count: number; total: number}) => `Marcados ${count} de ${total} ${total === 1 ? 'informe' : 'informes'} como pagados`, + noReportsTitle: 'No hay informes coincidentes', + noReportsBody: 'Ninguno de los informes que seleccionaste necesitaba esta acción.', + failedReportsBody: ({count}: {count: number}) => (count === 1 ? 'No se pudo actualizar 1 informe.' : `No se pudieron actualizar ${count} informes.`), + viewFailedReports: 'Ver informes', + failedTitle: 'Algo salió mal', + failedBody: 'No se pudo iniciar esta acción. Por favor, inténtalo de nuevo más tarde.', + }, }; export default translations; diff --git a/src/languages/fr.ts b/src/languages/fr.ts index b5bcd63e4b41..8834c1a64762 100644 --- a/src/languages/fr.ts +++ b/src/languages/fr.ts @@ -11626,5 +11626,24 @@ Voici un *reçu test* pour vous montrer comment ça fonctionne :`, description: `Créez des agents personnalisés pour examiner, approuver et acheminer les dépenses selon les règles que vous définissez. En savoir plus.`, }, }, + bulkAction: { + approvingTitle: 'Approbation des notes de frais...', + submittingTitle: 'Soumission des notes de frais...', + payingTitle: 'Marquage des notes de frais comme payées...', + runningBody: 'Cela peut prendre quelques minutes. Vous pouvez attendre ici ou Concierge peut vous envoyer un message lorsque ce sera terminé.', + sendFromConcierge: 'Envoie-moi un message quand ce sera fait', + conciergeTitle: 'Bien sûr !', + conciergeBody: 'Concierge vous enverra un message lorsque ce sera terminé.', + goToConcierge: 'Aller à Concierge', + approvedTitle: ({count, total}: {count: number; total: number}) => `Approuvé ${count} sur ${total} ${total === 1 ? 'note de frais' : 'notes de frais'}`, + submittedTitle: ({count, total}: {count: number; total: number}) => `Soumis ${count} sur ${total} ${total === 1 ? 'note de frais' : 'notes de frais'}`, + paidTitle: ({count, total}: {count: number; total: number}) => `Marqué ${count} sur ${total} ${total === 1 ? 'note de frais' : 'notes de frais'} comme payé`, + noReportsTitle: 'Aucune note de frais correspondante', + noReportsBody: 'Aucune des notes de frais que vous avez sélectionnées n’avait besoin de cette action.', + failedReportsBody: ({count}: {count: number}) => (count === 1 ? "1 note de frais n'a pas pu être mise à jour." : `${count} notes de frais n'ont pas pu être mises à jour.`), + viewFailedReports: 'Afficher les notes de frais', + failedTitle: 'Un problème est survenu', + failedBody: 'Cette action n’a pas pu être démarrée. Veuillez réessayer plus tard.', + }, }; export default translations; diff --git a/src/languages/it.ts b/src/languages/it.ts index 56fe331ecfa1..bc705a3df160 100644 --- a/src/languages/it.ts +++ b/src/languages/it.ts @@ -11550,5 +11550,24 @@ Ecco una *ricevuta di prova* per mostrarti come funziona:`, description: `Crea agenti personalizzati per verificare, approvare e instradare le spese in base alle regole che imposti. Scopri di più.`, }, }, + bulkAction: { + approvingTitle: 'Approvazione dei report in corso...', + submittingTitle: 'Invio dei report in corso...', + payingTitle: 'Contrassegno i report come pagati...', + runningBody: 'Questo può richiedere alcuni minuti. Puoi aspettare qui oppure Concierge può mandarti un messaggio quando è tutto pronto.', + sendFromConcierge: 'Scrivimi quando hai finito', + conciergeTitle: 'Ci puoi contare!', + conciergeBody: 'Concierge ti manderà un messaggio quando avrà finito.', + goToConcierge: 'Vai a Concierge', + approvedTitle: ({count, total}: {count: number; total: number}) => `Approvati ${count} su ${total} ${total === 1 ? 'rapporto' : 'report'}`, + submittedTitle: ({count, total}: {count: number; total: number}) => `Inviate ${count} di ${total} ${total === 1 ? 'rapporto' : 'report'}`, + paidTitle: ({count, total}: {count: number; total: number}) => `Contrassegnate ${count} di ${total} ${total === 1 ? 'rapporto' : 'report'} come pagate`, + noReportsTitle: 'Nessun report corrispondente', + noReportsBody: 'Nessuno dei report che hai selezionato richiedeva questa azione.', + failedReportsBody: ({count}: {count: number}) => (count === 1 ? '1 report non può essere aggiornato.' : `${count} report non hanno potuto essere aggiornati.`), + viewFailedReports: 'Visualizza report', + failedTitle: 'Qualcosa è andato storto', + failedBody: 'Questa azione non può essere avviata. Riprova più tardi.', + }, }; export default translations; diff --git a/src/languages/ja.ts b/src/languages/ja.ts index 7850d66531b1..e7fbf23017a4 100644 --- a/src/languages/ja.ts +++ b/src/languages/ja.ts @@ -11380,5 +11380,24 @@ ${reportName}`, description: `設定したルールに基づいて経費を確認、承認、振り分けるカスタムエージェントを作成できます。さらに詳しく。`, }, }, + bulkAction: { + approvingTitle: 'レポートを承認しています…', + submittingTitle: 'レポートを送信しています…', + payingTitle: 'レポートを支払済みにしています…', + runningBody: '数分かかる場合があります。ここでお待ちいただくか、完了したときに Concierge からメッセージを受け取ることもできます。', + sendFromConcierge: '完了したらメッセージを送ってください', + conciergeTitle: 'もちろんです!', + conciergeBody: '完了したら Concierge からメッセージが届きます。', + goToConcierge: 'Concierge に移動', + approvedTitle: ({count, total}: {count: number; total: number}) => `${total} ${total === 1 ? 'レポート' : 'レポート'} のうち ${count} 件を承認しました`, + submittedTitle: ({count, total}: {count: number; total: number}) => `${total} 件中 ${count} 件を提出済み ${total === 1 ? 'レポート' : 'レポート'}`, + paidTitle: ({count, total}: {count: number; total: number}) => `${total} 件中 ${count} 件の ${total === 1 ? 'レポート' : 'レポート'} を支払済みにしました`, + noReportsTitle: '一致するレポートはありません', + noReportsBody: '選択したレポートには、いずれもこの操作は必要ありませんでした。', + failedReportsBody: ({count}: {count: number}) => (count === 1 ? '1件のレポートを更新できませんでした。' : `${count} 件のレポートを更新できませんでした。`), + viewFailedReports: 'レポートを表示', + failedTitle: '問題が発生しました', + failedBody: 'この操作を開始できませんでした。後でもう一度お試しください。', + }, }; export default translations; diff --git a/src/languages/nl.ts b/src/languages/nl.ts index 6bb1673c11a2..c7e1b19a579e 100644 --- a/src/languages/nl.ts +++ b/src/languages/nl.ts @@ -11515,5 +11515,24 @@ Hier is een *proefbon* om je te laten zien hoe het werkt:`, description: `Maak aangepaste agents om uitgaven te beoordelen, goed te keuren en door te sturen op basis van regels die jij instelt. Meer informatie.`, }, }, + bulkAction: { + approvingTitle: 'Rapporten goedkeuren...', + submittingTitle: 'Rapporten worden ingediend...', + payingTitle: 'Rapporten markeren als betaald...', + runningBody: 'Dit kan een paar minuten duren. Je kunt hier wachten, of Concierge kan je een bericht sturen als het klaar is.', + sendFromConcierge: 'Stuur me een bericht als het klaar is', + conciergeTitle: 'Zeker weten!', + conciergeBody: 'Concierge stuurt je een bericht zodra het klaar is.', + goToConcierge: 'Ga naar Concierge', + approvedTitle: ({count, total}: {count: number; total: number}) => `${count} van ${total} ${total === 1 ? 'rapport' : 'rapporten'} goedgekeurd`, + submittedTitle: ({count, total}: {count: number; total: number}) => `Ingediend ${count} van ${total} ${total === 1 ? 'rapport' : 'rapporten'}`, + paidTitle: ({count, total}: {count: number; total: number}) => `${count} van ${total} ${total === 1 ? 'rapport' : 'rapporten'} als betaald gemarkeerd`, + noReportsTitle: 'Geen overeenkomende rapporten', + noReportsBody: 'Geen van de rapporten die je hebt geselecteerd had deze actie nodig.', + failedReportsBody: ({count}: {count: number}) => (count === 1 ? '1 rapport kon niet worden bijgewerkt.' : `${count} rapporten konden niet worden bijgewerkt.`), + viewFailedReports: 'Rapporten bekijken', + failedTitle: 'Er is iets misgegaan', + failedBody: 'Deze actie kon niet worden gestart. Probeer het later opnieuw.', + }, }; export default translations; diff --git a/src/languages/pl.ts b/src/languages/pl.ts index fcc5823641ae..746d443b7d8a 100644 --- a/src/languages/pl.ts +++ b/src/languages/pl.ts @@ -11530,5 +11530,24 @@ Oto *paragon testowy*, żeby pokazać Ci, jak to działa:`, description: `Twórz niestandardowych agentów do przeglądania, zatwierdzania i kierowania wydatków na podstawie ustalonych przez siebie zasad. Dowiedz się więcej.`, }, }, + bulkAction: { + approvingTitle: 'Zatwierdzanie raportów...', + submittingTitle: 'Wysyłanie raportów...', + payingTitle: 'Oznaczanie raportów jako opłacone...', + runningBody: 'To może potrwać kilka minut. Możesz poczekać tutaj albo Concierge napisze do ciebie, kiedy będzie gotowe.', + sendFromConcierge: 'Napisz do mnie, kiedy będzie gotowe', + conciergeTitle: 'No jasne!', + conciergeBody: 'Gdy Concierge skończy, wyśle ci wiadomość.', + goToConcierge: 'Przejdź do Concierge', + approvedTitle: ({count, total}: {count: number; total: number}) => `Zatwierdzono ${count} z ${total} ${total === 1 ? 'raport' : 'raporty'}`, + submittedTitle: ({count, total}: {count: number; total: number}) => `Przesłano ${count} z ${total} ${total === 1 ? 'raport' : 'raporty'}`, + paidTitle: ({count, total}: {count: number; total: number}) => `Oznaczono ${count} z ${total} ${total === 1 ? 'raport' : 'raporty'} jako opłacone`, + noReportsTitle: 'Brak pasujących raportów', + noReportsBody: 'Żaden z wybranych raportów nie wymagał tej akcji.', + failedReportsBody: ({count}: {count: number}) => (count === 1 ? 'Nie udało się zaktualizować 1 raportu.' : `Nie udało się zaktualizować ${count} raportów.`), + viewFailedReports: 'Wyświetl raporty', + failedTitle: 'Coś poszło nie tak', + failedBody: 'Nie udało się rozpocząć tej akcji. Spróbuj ponownie później.', + }, }; export default translations; diff --git a/src/languages/pt-BR.ts b/src/languages/pt-BR.ts index b5ee0d2ded75..bee86850c1cb 100644 --- a/src/languages/pt-BR.ts +++ b/src/languages/pt-BR.ts @@ -11507,5 +11507,24 @@ Aqui está um *comprovante de teste* para mostrar como funciona:`, description: `Crie agentes personalizados para revisar, aprovar e direcionar despesas com base nas regras que você definir. Saiba mais.`, }, }, + bulkAction: { + approvingTitle: 'Aprovando relatórios...', + submittingTitle: 'Enviando relatórios...', + payingTitle: 'Marcando relatórios como pagos...', + runningBody: 'Isso pode levar alguns minutos. Você pode esperar aqui ou o Concierge pode te mandar uma mensagem quando terminar.', + sendFromConcierge: 'Me avise quando terminar', + conciergeTitle: 'Pode apostar!', + conciergeBody: 'O Concierge vai te enviar uma mensagem quando terminar.', + goToConcierge: 'Ir para o Concierge', + approvedTitle: ({count, total}: {count: number; total: number}) => `Aprovado(s) ${count} de ${total} ${total === 1 ? 'relatório' : 'relatórios'}`, + submittedTitle: ({count, total}: {count: number; total: number}) => `Enviado(s) ${count} de ${total} ${total === 1 ? 'relatório' : 'relatórios'}`, + paidTitle: ({count, total}: {count: number; total: number}) => `Marcado(s) ${count} de ${total} ${total === 1 ? 'relatório' : 'relatórios'} como pago(s)`, + noReportsTitle: 'Nenhum relatório correspondente', + noReportsBody: 'Nenhum dos relatórios que você selecionou precisava dessa ação.', + failedReportsBody: ({count}: {count: number}) => (count === 1 ? '1 relatório não pôde ser atualizado.' : `${count} relatórios não puderam ser atualizados.`), + viewFailedReports: 'Ver relatórios', + failedTitle: 'Algo deu errado', + failedBody: 'Não foi possível iniciar esta ação. Tente novamente mais tarde.', + }, }; export default translations; diff --git a/src/languages/zh-hans.ts b/src/languages/zh-hans.ts index d7ca18f91645..257fe1494549 100644 --- a/src/languages/zh-hans.ts +++ b/src/languages/zh-hans.ts @@ -11082,5 +11082,24 @@ ${reportName}`, description: `创建自定义代理,根据你设置的规则审核、批准和分配报销。了解更多。`, }, }, + bulkAction: { + approvingTitle: '正在批准报表…', + submittingTitle: '正在提交报销报告…', + payingTitle: '正在将报表标记为已支付…', + runningBody: '这可能需要几分钟。你可以在这里等待,或者等完成后由 Concierge 给你发送消息。', + sendFromConcierge: '完成后给我发消息', + conciergeTitle: '当然!', + conciergeBody: '完成后,Concierge 会给你发送消息。', + goToConcierge: '前往 Concierge', + approvedTitle: ({count, total}: {count: number; total: number}) => `已批准 ${total} 条中的 ${count} 条 ${total === 1 ? '报表' : '报表'}`, + submittedTitle: ({count, total}: {count: number; total: number}) => `已提交 ${total} ${total === 1 ? '报表' : '报表'} 中的 ${count}`, + paidTitle: ({count, total}: {count: number; total: number}) => `已将 ${total} 个 ${total === 1 ? '报表' : '报表'} 中的 ${count} 个标记为已支付`, + noReportsTitle: '没有匹配的报表', + noReportsBody: '您选择的报告中没有任何一份需要执行此操作。', + failedReportsBody: ({count}: {count: number}) => (count === 1 ? '1 份报表无法更新。' : `${count} 份报表无法更新。`), + viewFailedReports: '查看报表', + failedTitle: '出现问题', + failedBody: '无法开始此操作。请稍后重试。', + }, }; export default translations; From 6c3e8d127423901f96de81bff065b2e0cee4cc5a Mon Sep 17 00:00:00 2001 From: allgandaf Date: Wed, 30 Sep 2026 10:12:56 +0530 Subject: [PATCH 05/73] add bulk action status modal --- src/components/BulkActionStatusManager.tsx | 73 +++++++ src/components/BulkActionStatusModal.tsx | 185 ++++++++++++++++++ .../Navigation/AppNavigator/AuthScreens.tsx | 2 + 3 files changed, 260 insertions(+) create mode 100644 src/components/BulkActionStatusManager.tsx create mode 100644 src/components/BulkActionStatusModal.tsx diff --git a/src/components/BulkActionStatusManager.tsx b/src/components/BulkActionStatusManager.tsx new file mode 100644 index 000000000000..3538de3140dd --- /dev/null +++ b/src/components/BulkActionStatusManager.tsx @@ -0,0 +1,73 @@ +import useOnyx from '@hooks/useOnyx'; + +import {clearBulkAction, wasBulkActionInitiatedLocally} from '@libs/actions/BulkAction'; + +import CONST from '@src/CONST'; +import ONYXKEYS from '@src/ONYXKEYS'; + +import React, {useState} from 'react'; + +import BulkActionStatusModal from './BulkActionStatusModal'; + +/** Shows the status modal for a bulk action started from Search "Select all", and brings it back after a reload. */ +function BulkActionStatusManager() { + const [bulkActions, bulkActionsMetadata] = useOnyx(ONYXKEYS.COLLECTION.BULK_ACTION); + const [openBulkActionID, setOpenBulkActionID] = useState(); + + // A record that already existed when this tab loaded resurfaces after a reload. One started in another tab + // after that doesn't pop open here until this tab reloads. + const [recordKeysAtLoad, setRecordKeysAtLoad] = useState | undefined>(undefined); + if (recordKeysAtLoad === undefined && bulkActionsMetadata.status === 'loaded') { + setRecordKeysAtLoad(new Set(Object.keys(bulkActions ?? {}))); + } + + const [surfaceableKey] = + Object.entries(bulkActions ?? {}).find(([key, bulkAction]) => { + // Concierge messages the result, so there is nothing to show here. + if (!bulkAction || bulkAction.shouldSendFromConcierge) { + return false; + } + return !!recordKeysAtLoad?.has(key) || wasBulkActionInitiatedLocally(key.replace(ONYXKEYS.COLLECTION.BULK_ACTION, '')); + }) ?? []; + const surfaceableBulkActionID = surfaceableKey?.replace(ONYXKEYS.COLLECTION.BULK_ACTION, ''); + + // Keep the modal open through the switch to shouldSendFromConcierge, and close it once the record is gone. + if (!openBulkActionID && surfaceableBulkActionID) { + setOpenBulkActionID(surfaceableBulkActionID); + } + if (openBulkActionID && !bulkActions?.[`${ONYXKEYS.COLLECTION.BULK_ACTION}${openBulkActionID}`]) { + setOpenBulkActionID(undefined); + } + + if (!openBulkActionID) { + return null; + } + + const bulkAction = bulkActions?.[`${ONYXKEYS.COLLECTION.BULK_ACTION}${openBulkActionID}`]; + if (!bulkAction) { + return null; + } + + const handleClose = () => { + if (bulkAction.shouldSendFromConcierge) { + setOpenBulkActionID(undefined); + return; + } + if (bulkAction.state === CONST.BULK_ACTION.STATE.RUNNING) { + return; + } + clearBulkAction(openBulkActionID, bulkAction); + setOpenBulkActionID(undefined); + }; + + return ( + + ); +} + +export default BulkActionStatusManager; diff --git a/src/components/BulkActionStatusModal.tsx b/src/components/BulkActionStatusModal.tsx new file mode 100644 index 000000000000..74e054e850cf --- /dev/null +++ b/src/components/BulkActionStatusModal.tsx @@ -0,0 +1,185 @@ +import useBottomSafeSafeAreaPaddingStyle from '@hooks/useBottomSafeSafeAreaPaddingStyle'; +import useLocalize from '@hooks/useLocalize'; +import useOnyx from '@hooks/useOnyx'; +import useOpenConciergeAnywhere from '@hooks/useOpenConciergeAnywhere'; +import usePreviousDefined from '@hooks/usePreviousDefined'; +import useResponsiveLayout from '@hooks/useResponsiveLayout'; +import useThemeStyles from '@hooks/useThemeStyles'; + +import Navigation from '@libs/Navigation/Navigation'; +import {buildSearchQueryJSON, buildSearchQueryString} from '@libs/SearchQueryUtils'; + +import {sendBulkActionSummaryFromConcierge} from '@userActions/BulkAction'; +import {close} from '@userActions/Modal'; + +import CONST from '@src/CONST'; +import ONYXKEYS from '@src/ONYXKEYS'; +import ROUTES from '@src/ROUTES'; + +import React from 'react'; +import {View} from 'react-native'; + +import ActivityIndicator from './ActivityIndicator'; +import Button from './Button'; +import Modal from './Modal'; +import Text from './Text'; + +type BulkActionStatusModalProps = { + /** The bulk action ID to subscribe to */ + bulkActionID: string; + + isVisible: boolean; + + /** Callback when the modal is closed */ + onClose: () => void; +}; + +function BulkActionStatusModal({bulkActionID, isVisible, onClose}: BulkActionStatusModalProps) { + const styles = useThemeStyles(); + const {translate} = useLocalize(); + // isSmallScreenWidth is needed here because the modal type depends on actual screen width, not layout mode + // eslint-disable-next-line rulesdir/prefer-shouldUseNarrowLayout-instead-of-isSmallScreenWidth + const {isSmallScreenWidth} = useResponsiveLayout(); + const {openConciergeAnywhere} = useOpenConciergeAnywhere(); + const bottomSafeAreaPaddingStyle = useBottomSafeSafeAreaPaddingStyle({addBottomSafeAreaPadding: isSmallScreenWidth, addOfflineIndicatorBottomSafeAreaPadding: false, style: styles.m5}); + + const [bulkAction] = useOnyx(`${ONYXKEYS.COLLECTION.BULK_ACTION}${bulkActionID}`); + const displayedBulkAction = usePreviousDefined(bulkAction); + if (!bulkAction && !!displayedBulkAction) { + return null; + } + + const state = displayedBulkAction?.state; + const action = displayedBulkAction?.action; + const shouldSendFromConcierge = !!displayedBulkAction?.shouldSendFromConcierge; + const total = displayedBulkAction?.total ?? 0; + const failedReportIDs = displayedBulkAction?.failedReportIDs ?? []; + const isRunning = state === CONST.BULK_ACTION.STATE.RUNNING && !shouldSendFromConcierge; + const isConcierge = shouldSendFromConcierge && state !== CONST.BULK_ACTION.STATE.DONE; + + const handleViewFailedReports = () => { + const queryJSON = buildSearchQueryJSON(`type:${CONST.SEARCH.DATA_TYPES.EXPENSE_REPORT} ${CONST.SEARCH.SYNTAX_FILTER_KEYS.REPORT_ID}:${failedReportIDs.join(',')}`); + onClose(); + if (!queryJSON) { + return; + } + close(() => Navigation.navigate(ROUTES.SEARCH_ROOT.getRoute({query: buildSearchQueryString(queryJSON)}))); + }; + + const renderContent = () => { + if (isRunning) { + let runningTitle = translate('bulkAction.payingTitle'); + if (action === CONST.SEARCH.BULK_ACTION_TYPES.APPROVE) { + runningTitle = translate('bulkAction.approvingTitle'); + } else if (action === CONST.SEARCH.BULK_ACTION_TYPES.SUBMIT) { + runningTitle = translate('bulkAction.submittingTitle'); + } + return ( + <> + + {runningTitle} + + + {translate('bulkAction.runningBody')} + + + ); + } + + if (isConcierge) { + return ( + <> + {translate('bulkAction.conciergeTitle')} + {translate('bulkAction.conciergeBody')} + + + + ); + } + + if (state === CONST.BULK_ACTION.STATE.DONE) { + const count = total - failedReportIDs.length; + let doneTitle = translate('bulkAction.paidTitle', {count, total}); + if (total === 0) { + doneTitle = translate('bulkAction.noReportsTitle'); + } else if (action === CONST.SEARCH.BULK_ACTION_TYPES.APPROVE) { + doneTitle = translate('bulkAction.approvedTitle', {count, total}); + } else if (action === CONST.SEARCH.BULK_ACTION_TYPES.SUBMIT) { + doneTitle = translate('bulkAction.submittedTitle', {count, total}); + } + return ( + <> + {doneTitle} + {total === 0 && {translate('bulkAction.noReportsBody')}} + {failedReportIDs.length > 0 && ( + <> + {translate('bulkAction.failedReportsBody', {count: failedReportIDs.length})} + + + )} + + + ); + } + + if (state === CONST.BULK_ACTION.STATE.FAILED) { + return ( + <> + {translate('bulkAction.failedTitle')} + {translate('bulkAction.failedBody')} + + + ); + } + + return null; + }; + + return ( + {} : onClose} + onBackdropPress={isRunning ? () => {} : undefined} + shouldTreatModalAsCovering + type={isSmallScreenWidth ? CONST.MODAL.MODAL_TYPE.BOTTOM_DOCKED : CONST.MODAL.MODAL_TYPE.CONFIRM} + innerContainerStyle={styles.pv0} + enableEdgeToEdgeBottomSafeAreaPadding + > + {renderContent()} + + ); +} + +export default BulkActionStatusModal; diff --git a/src/libs/Navigation/AppNavigator/AuthScreens.tsx b/src/libs/Navigation/AppNavigator/AuthScreens.tsx index eb615e3639bf..689c245aefe2 100644 --- a/src/libs/Navigation/AppNavigator/AuthScreens.tsx +++ b/src/libs/Navigation/AppNavigator/AuthScreens.tsx @@ -1,3 +1,4 @@ +import BulkActionStatusManager from '@components/BulkActionStatusManager'; import ComposeProviders from '@components/ComposeProviders'; import DelegateNoAccessModalProvider from '@components/DelegateNoAccessModalProvider'; import EnableGlobalReimbursementsPayModal from '@components/EnableGlobalReimbursementsPayModal'; @@ -173,6 +174,7 @@ function AuthScreens() { + Date: Wed, 30 Sep 2026 10:12:56 +0530 Subject: [PATCH 06/73] show the bulk action modal for select all pay --- src/hooks/useSearchBulkActions.ts | 1 - src/libs/API/parameters/QueueBulkPayReportsParams.ts | 3 +++ src/libs/actions/Search.ts | 4 +++- 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/hooks/useSearchBulkActions.ts b/src/hooks/useSearchBulkActions.ts index 8e0a5a054c2f..c64d5a09a075 100644 --- a/src/hooks/useSearchBulkActions.ts +++ b/src/hooks/useSearchBulkActions.ts @@ -1513,7 +1513,6 @@ function useSearchBulkActions({queryJSON}: UseSearchBulkActionsParams) { } const serializedQuery = allMatchingQuery ? serializeQueryJSONForBackend(allMatchingQuery) : JSON.stringify(allMatchingQuery); queueBulkPayReports(serializedQuery); - playSound(SOUNDS.SUCCESS); clearSelectedTransactions(); return; } diff --git a/src/libs/API/parameters/QueueBulkPayReportsParams.ts b/src/libs/API/parameters/QueueBulkPayReportsParams.ts index 845b2d6a67fd..10a0dbfb5216 100644 --- a/src/libs/API/parameters/QueueBulkPayReportsParams.ts +++ b/src/libs/API/parameters/QueueBulkPayReportsParams.ts @@ -3,6 +3,9 @@ import type {SearchQueryString} from '@components/Search/types'; type QueueBulkPayReportsParams = { /** Serialized search query describing every report to pay, so the backend can page through all matches instead of relying on a client-side list */ jsonQuery: SearchQueryString; + + /** ID of the bulk action record the backend updates as the payments finish */ + bulkActionID: string; }; export default QueueBulkPayReportsParams; diff --git a/src/libs/actions/Search.ts b/src/libs/actions/Search.ts index 430b67dc5938..2b6ce89f325a 100644 --- a/src/libs/actions/Search.ts +++ b/src/libs/actions/Search.ts @@ -111,6 +111,7 @@ import Onyx from 'react-native-onyx'; import type {RejectMoneyRequestData} from './IOU/RejectMoneyRequest'; import type AdditionalPayOnyxData from './IOU/types/AdditionalPayOnyxData'; +import {buildBulkActionOnyxData} from './BulkAction'; import {markExportInitiatedLocally} from './Export'; import {payMoneyRequest} from './IOU/PayMoneyRequest'; import {prepareRejectMoneyRequestData, rejectMoneyRequest} from './IOU/RejectMoneyRequest'; @@ -2148,7 +2149,8 @@ function queueExportSearchWithTemplate( * so this covers reports beyond the currently loaded page(s) when "Select all" is checked in Search. */ function queueBulkPayReports(jsonQuery: string) { - write(WRITE_COMMANDS.QUEUE_BULK_PAY_REPORTS, {jsonQuery}); + const {bulkActionID, onyxData} = buildBulkActionOnyxData(CONST.SEARCH.BULK_ACTION_TYPES.PAY); + write(WRITE_COMMANDS.QUEUE_BULK_PAY_REPORTS, {jsonQuery, bulkActionID}, onyxData); } /** Export templates pre-grouped for the Export menus: each group is sorted alphabetically and rendered with a divider between groups */ From e31631db6daf90b2455cb61d6bf3c1c753fc241d Mon Sep 17 00:00:00 2001 From: allgandaf Date: Wed, 30 Sep 2026 10:13:17 +0530 Subject: [PATCH 07/73] fix bulk action translations --- src/languages/de.ts | 2 +- src/languages/el.ts | 4 ++-- src/languages/es.ts | 2 +- src/languages/fr.ts | 2 +- src/languages/it.ts | 8 ++++---- src/languages/ja.ts | 6 +++--- src/languages/nl.ts | 2 +- src/languages/pl.ts | 6 +++--- src/languages/zh-hans.ts | 10 +++++----- 9 files changed, 21 insertions(+), 21 deletions(-) diff --git a/src/languages/de.ts b/src/languages/de.ts index 9627a4c684c2..b56e22eafc0c 100644 --- a/src/languages/de.ts +++ b/src/languages/de.ts @@ -11602,7 +11602,7 @@ Hier ist ein *Testbeleg*, um dir zu zeigen, wie es funktioniert:`, submittingTitle: 'Berichte werden eingereicht …', payingTitle: 'Berichte werden als bezahlt markiert …', runningBody: 'Dies kann einige Minuten dauern. Sie können hier warten, oder Concierge kann Ihnen eine Nachricht senden, wenn es fertig ist.', - sendFromConcierge: 'Schreiben Sie mir eine Nachricht, wenn es erledigt ist', + sendFromConcierge: 'Mir eine Nachricht senden, wenn es fertig ist', conciergeTitle: 'Auf jeden Fall!', conciergeBody: 'Concierge wird Ihnen eine Nachricht senden, sobald es fertig ist.', goToConcierge: 'Zu Concierge', diff --git a/src/languages/el.ts b/src/languages/el.ts index 9183941789cd..499859d5b021 100644 --- a/src/languages/el.ts +++ b/src/languages/el.ts @@ -11851,9 +11851,9 @@ ${reportName}`, goToConcierge: 'Μετάβαση στο Concierge', approvedTitle: ({count, total}: {count: number; total: number}) => `Εγκρίθηκαν ${count} από ${total} ${total === 1 ? 'αναφορά' : 'αναφορές'}`, submittedTitle: ({count, total}: {count: number; total: number}) => `Υποβλήθηκαν ${count} από ${total} ${total === 1 ? 'αναφορά' : 'αναφορές'}`, - paidTitle: ({count, total}: {count: number; total: number}) => `Σημειώθηκαν ως πληρωμένα τα ${count} από ${total} ${total === 1 ? 'αναφορά' : 'αναφορές'}`, + paidTitle: ({count, total}: {count: number; total: number}) => `Σημειώθηκαν ως πληρωμένες ${count} από ${total} ${total === 1 ? 'αναφορά' : 'αναφορές'}`, noReportsTitle: 'Δεν υπάρχουν αντιστοιχίες αναφορών', - noReportsBody: 'Κανένα από τα αναφορικά που επιλέξατε δεν χρειαζόταν αυτή την ενέργεια.', + noReportsBody: 'Καμία από τις αναφορές που επιλέξατε δεν χρειαζόταν αυτή την ενέργεια.', failedReportsBody: ({count}: {count: number}) => (count === 1 ? '1 αναφορά δεν μπόρεσε να ενημερωθεί.' : `${count} αναφορές δεν ήταν δυνατό να ενημερωθούν.`), viewFailedReports: 'Προβολή αναφορών', failedTitle: 'Κάτι πήγε στραβά', diff --git a/src/languages/es.ts b/src/languages/es.ts index 7d59ed0c8d57..25580373059b 100644 --- a/src/languages/es.ts +++ b/src/languages/es.ts @@ -11878,7 +11878,7 @@ ${reportName}`, conciergeBody: 'Concierge te enviará un mensaje cuando haya terminado.', goToConcierge: 'Ir a Concierge', approvedTitle: ({count, total}: {count: number; total: number}) => `Aprobados ${count} de ${total} ${total === 1 ? 'informe' : 'informes'}`, - submittedTitle: ({count, total}: {count: number; total: number}) => `Enviado ${count} de ${total} ${total === 1 ? 'informe' : 'informes'}`, + submittedTitle: ({count, total}: {count: number; total: number}) => `Enviados ${count} de ${total} ${total === 1 ? 'informe' : 'informes'}`, paidTitle: ({count, total}: {count: number; total: number}) => `Marcados ${count} de ${total} ${total === 1 ? 'informe' : 'informes'} como pagados`, noReportsTitle: 'No hay informes coincidentes', noReportsBody: 'Ninguno de los informes que seleccionaste necesitaba esta acción.', diff --git a/src/languages/fr.ts b/src/languages/fr.ts index 8834c1a64762..bbd1d8bb590f 100644 --- a/src/languages/fr.ts +++ b/src/languages/fr.ts @@ -11631,7 +11631,7 @@ Voici un *reçu test* pour vous montrer comment ça fonctionne :`, submittingTitle: 'Soumission des notes de frais...', payingTitle: 'Marquage des notes de frais comme payées...', runningBody: 'Cela peut prendre quelques minutes. Vous pouvez attendre ici ou Concierge peut vous envoyer un message lorsque ce sera terminé.', - sendFromConcierge: 'Envoie-moi un message quand ce sera fait', + sendFromConcierge: 'Envoyez-moi un message quand ce sera fait', conciergeTitle: 'Bien sûr !', conciergeBody: 'Concierge vous enverra un message lorsque ce sera terminé.', goToConcierge: 'Aller à Concierge', diff --git a/src/languages/it.ts b/src/languages/it.ts index bc705a3df160..3c5e01471b62 100644 --- a/src/languages/it.ts +++ b/src/languages/it.ts @@ -11553,15 +11553,15 @@ Ecco una *ricevuta di prova* per mostrarti come funziona:`, bulkAction: { approvingTitle: 'Approvazione dei report in corso...', submittingTitle: 'Invio dei report in corso...', - payingTitle: 'Contrassegno i report come pagati...', + payingTitle: 'Contrassegno dei report come pagati in corso...', runningBody: 'Questo può richiedere alcuni minuti. Puoi aspettare qui oppure Concierge può mandarti un messaggio quando è tutto pronto.', sendFromConcierge: 'Scrivimi quando hai finito', conciergeTitle: 'Ci puoi contare!', conciergeBody: 'Concierge ti manderà un messaggio quando avrà finito.', goToConcierge: 'Vai a Concierge', - approvedTitle: ({count, total}: {count: number; total: number}) => `Approvati ${count} su ${total} ${total === 1 ? 'rapporto' : 'report'}`, - submittedTitle: ({count, total}: {count: number; total: number}) => `Inviate ${count} di ${total} ${total === 1 ? 'rapporto' : 'report'}`, - paidTitle: ({count, total}: {count: number; total: number}) => `Contrassegnate ${count} di ${total} ${total === 1 ? 'rapporto' : 'report'} come pagate`, + approvedTitle: ({count, total}: {count: number; total: number}) => `Approvati ${count} su ${total} report`, + submittedTitle: ({count, total}: {count: number; total: number}) => `Inviati ${count} su ${total} report`, + paidTitle: ({count, total}: {count: number; total: number}) => `Contrassegnati ${count} su ${total} report come pagati`, noReportsTitle: 'Nessun report corrispondente', noReportsBody: 'Nessuno dei report che hai selezionato richiedeva questa azione.', failedReportsBody: ({count}: {count: number}) => (count === 1 ? '1 report non può essere aggiornato.' : `${count} report non hanno potuto essere aggiornati.`), diff --git a/src/languages/ja.ts b/src/languages/ja.ts index e7fbf23017a4..f56613cc053a 100644 --- a/src/languages/ja.ts +++ b/src/languages/ja.ts @@ -11389,9 +11389,9 @@ ${reportName}`, conciergeTitle: 'もちろんです!', conciergeBody: '完了したら Concierge からメッセージが届きます。', goToConcierge: 'Concierge に移動', - approvedTitle: ({count, total}: {count: number; total: number}) => `${total} ${total === 1 ? 'レポート' : 'レポート'} のうち ${count} 件を承認しました`, - submittedTitle: ({count, total}: {count: number; total: number}) => `${total} 件中 ${count} 件を提出済み ${total === 1 ? 'レポート' : 'レポート'}`, - paidTitle: ({count, total}: {count: number; total: number}) => `${total} 件中 ${count} 件の ${total === 1 ? 'レポート' : 'レポート'} を支払済みにしました`, + approvedTitle: ({count, total}: {count: number; total: number}) => `${total} 件中 ${count} 件のレポートを承認しました`, + submittedTitle: ({count, total}: {count: number; total: number}) => `${total} 件中 ${count} 件のレポートを提出しました`, + paidTitle: ({count, total}: {count: number; total: number}) => `${total} 件中 ${count} 件のレポートを支払済みにしました`, noReportsTitle: '一致するレポートはありません', noReportsBody: '選択したレポートには、いずれもこの操作は必要ありませんでした。', failedReportsBody: ({count}: {count: number}) => (count === 1 ? '1件のレポートを更新できませんでした。' : `${count} 件のレポートを更新できませんでした。`), diff --git a/src/languages/nl.ts b/src/languages/nl.ts index c7e1b19a579e..968e54bfe503 100644 --- a/src/languages/nl.ts +++ b/src/languages/nl.ts @@ -11525,7 +11525,7 @@ Hier is een *proefbon* om je te laten zien hoe het werkt:`, conciergeBody: 'Concierge stuurt je een bericht zodra het klaar is.', goToConcierge: 'Ga naar Concierge', approvedTitle: ({count, total}: {count: number; total: number}) => `${count} van ${total} ${total === 1 ? 'rapport' : 'rapporten'} goedgekeurd`, - submittedTitle: ({count, total}: {count: number; total: number}) => `Ingediend ${count} van ${total} ${total === 1 ? 'rapport' : 'rapporten'}`, + submittedTitle: ({count, total}: {count: number; total: number}) => `${count} van ${total} ${total === 1 ? 'rapport' : 'rapporten'} ingediend`, paidTitle: ({count, total}: {count: number; total: number}) => `${count} van ${total} ${total === 1 ? 'rapport' : 'rapporten'} als betaald gemarkeerd`, noReportsTitle: 'Geen overeenkomende rapporten', noReportsBody: 'Geen van de rapporten die je hebt geselecteerd had deze actie nodig.', diff --git a/src/languages/pl.ts b/src/languages/pl.ts index 746d443b7d8a..2304266c670b 100644 --- a/src/languages/pl.ts +++ b/src/languages/pl.ts @@ -11539,9 +11539,9 @@ Oto *paragon testowy*, żeby pokazać Ci, jak to działa:`, conciergeTitle: 'No jasne!', conciergeBody: 'Gdy Concierge skończy, wyśle ci wiadomość.', goToConcierge: 'Przejdź do Concierge', - approvedTitle: ({count, total}: {count: number; total: number}) => `Zatwierdzono ${count} z ${total} ${total === 1 ? 'raport' : 'raporty'}`, - submittedTitle: ({count, total}: {count: number; total: number}) => `Przesłano ${count} z ${total} ${total === 1 ? 'raport' : 'raporty'}`, - paidTitle: ({count, total}: {count: number; total: number}) => `Oznaczono ${count} z ${total} ${total === 1 ? 'raport' : 'raporty'} jako opłacone`, + approvedTitle: ({count, total}: {count: number; total: number}) => `Zatwierdzono ${count} z ${total} ${total === 1 ? 'raportu' : 'raportów'}`, + submittedTitle: ({count, total}: {count: number; total: number}) => `Przesłano ${count} z ${total} ${total === 1 ? 'raportu' : 'raportów'}`, + paidTitle: ({count, total}: {count: number; total: number}) => `Oznaczono ${count} z ${total} ${total === 1 ? 'raportu' : 'raportów'} jako opłacone`, noReportsTitle: 'Brak pasujących raportów', noReportsBody: 'Żaden z wybranych raportów nie wymagał tej akcji.', failedReportsBody: ({count}: {count: number}) => (count === 1 ? 'Nie udało się zaktualizować 1 raportu.' : `Nie udało się zaktualizować ${count} raportów.`), diff --git a/src/languages/zh-hans.ts b/src/languages/zh-hans.ts index 257fe1494549..2e7730fe997e 100644 --- a/src/languages/zh-hans.ts +++ b/src/languages/zh-hans.ts @@ -11084,18 +11084,18 @@ ${reportName}`, }, bulkAction: { approvingTitle: '正在批准报表…', - submittingTitle: '正在提交报销报告…', + submittingTitle: '正在提交报表…', payingTitle: '正在将报表标记为已支付…', runningBody: '这可能需要几分钟。你可以在这里等待,或者等完成后由 Concierge 给你发送消息。', sendFromConcierge: '完成后给我发消息', conciergeTitle: '当然!', conciergeBody: '完成后,Concierge 会给你发送消息。', goToConcierge: '前往 Concierge', - approvedTitle: ({count, total}: {count: number; total: number}) => `已批准 ${total} 条中的 ${count} 条 ${total === 1 ? '报表' : '报表'}`, - submittedTitle: ({count, total}: {count: number; total: number}) => `已提交 ${total} ${total === 1 ? '报表' : '报表'} 中的 ${count}`, - paidTitle: ({count, total}: {count: number; total: number}) => `已将 ${total} 个 ${total === 1 ? '报表' : '报表'} 中的 ${count} 个标记为已支付`, + approvedTitle: ({count, total}: {count: number; total: number}) => `已批准 ${total} 份报表中的 ${count} 份`, + submittedTitle: ({count, total}: {count: number; total: number}) => `已提交 ${total} 份报表中的 ${count} 份`, + paidTitle: ({count, total}: {count: number; total: number}) => `已将 ${total} 份报表中的 ${count} 份标记为已支付`, noReportsTitle: '没有匹配的报表', - noReportsBody: '您选择的报告中没有任何一份需要执行此操作。', + noReportsBody: '您选择的报表都不需要执行此操作。', failedReportsBody: ({count}: {count: number}) => (count === 1 ? '1 份报表无法更新。' : `${count} 份报表无法更新。`), viewFailedReports: '查看报表', failedTitle: '出现问题', From d55d1db2d31bf478af4c66cd61e63d426fcc63af Mon Sep 17 00:00:00 2001 From: allgandaf Date: Wed, 30 Sep 2026 10:13:47 +0530 Subject: [PATCH 08/73] approve every report matching select all through the backend --- src/hooks/useSearchBulkActions.ts | 43 +++++++--- .../QueueBulkApproveReportsParams.ts | 8 ++ src/libs/API/parameters/index.ts | 1 + src/libs/API/types.ts | 2 + src/libs/actions/Search.ts | 9 +++ tests/unit/hooks/useSearchBulkActionsTest.ts | 81 ++++++++++++++++++- 6 files changed, 133 insertions(+), 11 deletions(-) create mode 100644 src/libs/API/parameters/QueueBulkApproveReportsParams.ts diff --git a/src/hooks/useSearchBulkActions.ts b/src/hooks/useSearchBulkActions.ts index c64d5a09a075..ebedfd53830f 100644 --- a/src/hooks/useSearchBulkActions.ts +++ b/src/hooks/useSearchBulkActions.ts @@ -34,6 +34,7 @@ import { getSearchPayOnyxData, getTotalFormattedAmount, isCurrencySupportWalletBulkPay, + queueBulkApproveReports, queueBulkPayReports, queueExportSearchItemsToCSV, queueExportSearchWithTemplate, @@ -1240,6 +1241,15 @@ function useSearchBulkActions({queryJSON}: UseSearchBulkActionsParams) { return; } + // "Select all" can cover more reports than are loaded, so hand the search query to the backend to approve every match. + if (areAllMatchingItemsSelected) { + const serializedQuery = queryJSON ? serializeQueryJSONForBackend(queryJSON) : JSON.stringify(queryJSON); + queueBulkApproveReports(serializedQuery); + playSound(SOUNDS.SUCCESS); + clearSelectedTransactions(); + return; + } + const reportIDList = !selectedReports.length ? Object.values(selectedTransactions).map((transaction) => transaction.reportID) : (selectedReports?.filter((report) => !!report).map((report) => report.reportID) ?? []); @@ -1303,6 +1313,8 @@ function useSearchBulkActions({queryJSON}: UseSearchBulkActionsParams) { selectedReports, selectedTransactions, hash, + areAllMatchingItemsSelected, + queryJSON, clearSelectedTransactions, userBillingGracePeriodEnds, ownerBillingGracePeriodEnd, @@ -2436,6 +2448,17 @@ function useSearchBulkActions({queryJSON}: UseSearchBulkActionsParams) { onSelected: () => onBulkPaySelected(undefined), }; + const hasSubmitPolicyTransactions = areIncludedSubmitPolicyTransactions(selectedTransactions, selectedReports, policies); + const approveButtonOption: DropdownOption = { + icon: expensifyIcons.ThumbsUp, + text: translate('search.bulkActions.approve'), + value: CONST.SEARCH.BULK_ACTION_TYPES.APPROVE, + shouldCloseModalOnSelect: true, + onSelected: () => { + handleApproveWithDEWCheck(); + }, + }; + const isExpenseReportSearch = isExpenseReportType || searchResults?.search.type === CONST.SEARCH.DATA_TYPES.EXPENSE_REPORT; const downloadPDFOption: DropdownOption = { @@ -2484,11 +2507,20 @@ function useSearchBulkActions({queryJSON}: UseSearchBulkActionsParams) { }; if (areAllMatchingItemsSelected) { + // The backend only approves the matching reports the user can approve, so one approvable loaded item is enough to offer it. + const hasLoadedApprovableItem = selectedReports.length + ? selectedReports.some((report) => report.canApprove) + : selectedTransactionsKeys.some((id) => selectedTransactions[id].action === CONST.SEARCH.ACTION_TYPES.APPROVE); + const shouldShowApproveOptionForAllMatchingItems = !isOffline && !hasSubmitPolicyTransactions && hasLoadedApprovableItem; + // Offer an all-matching move only when no rows are excluded and unloaded matches are unreported. // The backend rejects the entire move if any matching expense is invalid const isAllMatchingSelectionMovable = isEmptyObject(excludedTransactions) && (!hasUnloadedMatchingExpenses || isUnreportedOnlyQuery); const allMatchingOptions: Array> = []; + if (shouldShowApproveOptionForAllMatchingItems) { + allMatchingOptions.push(approveButtonOption); + } if (shouldShowPayOption) { allMatchingOptions.push(payButtonOption); } @@ -2565,7 +2597,6 @@ function useSearchBulkActions({queryJSON}: UseSearchBulkActionsParams) { const areSelectedTransactionsIncludedInReports = selectedTransactionsKeys.every((id) => selectedTransactions[id].reportID ? selectedReportIDs.includes(selectedTransactions[id].reportID) : true, ); - const hasSubmitPolicyTransactions = areIncludedSubmitPolicyTransactions(selectedTransactions, selectedReports, policies); const shouldShowApproveOption = !isOffline && !isAnyTransactionOnHold && @@ -2576,15 +2607,7 @@ function useSearchBulkActions({queryJSON}: UseSearchBulkActionsParams) { : selectedTransactionsKeys.every((id) => selectedTransactions[id].action === CONST.SEARCH.ACTION_TYPES.APPROVE)); if (shouldShowApproveOption) { - options.push({ - icon: expensifyIcons.ThumbsUp, - text: translate('search.bulkActions.approve'), - value: CONST.SEARCH.BULK_ACTION_TYPES.APPROVE, - shouldCloseModalOnSelect: true, - onSelected: () => { - handleApproveWithDEWCheck(); - }, - }); + options.push(approveButtonOption); } const hasNoRejectedTransaction = selectedTransactionsKeys.every( diff --git a/src/libs/API/parameters/QueueBulkApproveReportsParams.ts b/src/libs/API/parameters/QueueBulkApproveReportsParams.ts new file mode 100644 index 000000000000..a79539c4e13b --- /dev/null +++ b/src/libs/API/parameters/QueueBulkApproveReportsParams.ts @@ -0,0 +1,8 @@ +import type {SearchQueryString} from '@components/Search/types'; + +type QueueBulkApproveReportsParams = { + /** Serialized search query describing every report to approve, so the backend can page through all matches instead of relying on a client-side list */ + jsonQuery: SearchQueryString; +}; + +export default QueueBulkApproveReportsParams; diff --git a/src/libs/API/parameters/index.ts b/src/libs/API/parameters/index.ts index 306f45d02d0d..0d78d295a37c 100644 --- a/src/libs/API/parameters/index.ts +++ b/src/libs/API/parameters/index.ts @@ -600,6 +600,7 @@ export type {default as ExportSearchWithTemplateParams} from './ExportSearchWith export type {default as QueueExportSearchItemsToCSVParams} from './QueueExportSearchItemsToCSVParams'; export type {default as QueueExportSearchWithTemplateParams} from './QueueExportSearchWithTemplateParams'; export type {default as QueueBulkPayReportsParams} from './QueueBulkPayReportsParams'; +export type {default as QueueBulkApproveReportsParams} from './QueueBulkApproveReportsParams'; export type {default as AssignReportToMeParams} from './AssignReportToMeParams'; export type {default as AddReportApproverParams} from './AddReportApproverParams'; export type {default as EnableGlobalReimbursementsForUSDBankAccountParams} from './EnableGlobalReimbursementsForUSDBankAccountParams'; diff --git a/src/libs/API/types.ts b/src/libs/API/types.ts index cc6d8eebf708..b5169eb6d387 100644 --- a/src/libs/API/types.ts +++ b/src/libs/API/types.ts @@ -603,6 +603,7 @@ const WRITE_COMMANDS = { QUEUE_EXPORT_SEARCH_ITEMS_TO_CSV: 'QueueExportSearchToCSV', QUEUE_EXPORT_SEARCH_WITH_TEMPLATE: 'QueueExportSearchWithTemplate', QUEUE_BULK_PAY_REPORTS: 'QueueBulkPayReports', + QUEUE_BULK_APPROVE_REPORTS: 'QueueBulkApproveReports', CREATE_WORKSPACE_APPROVAL: 'CreateWorkspaceApproval', UPDATE_WORKSPACE_APPROVAL: 'UpdateWorkspaceApproval', REMOVE_WORKSPACE_APPROVAL: 'RemoveWorkspaceApproval', @@ -1385,6 +1386,7 @@ type WriteCommandParameters = { [WRITE_COMMANDS.QUEUE_EXPORT_SEARCH_ITEMS_TO_CSV]: Parameters.QueueExportSearchItemsToCSVParams; [WRITE_COMMANDS.QUEUE_EXPORT_SEARCH_WITH_TEMPLATE]: Parameters.QueueExportSearchWithTemplateParams; [WRITE_COMMANDS.QUEUE_BULK_PAY_REPORTS]: Parameters.QueueBulkPayReportsParams; + [WRITE_COMMANDS.QUEUE_BULK_APPROVE_REPORTS]: Parameters.QueueBulkApproveReportsParams; [WRITE_COMMANDS.EXPORT_REPORT_TO_CSV]: Parameters.ExportReportCSVParams; [WRITE_COMMANDS.CREATE_WORKSPACE_APPROVAL]: Parameters.CreateWorkspaceApprovalParams; [WRITE_COMMANDS.UPDATE_WORKSPACE_APPROVAL]: Parameters.UpdateWorkspaceApprovalParams; diff --git a/src/libs/actions/Search.ts b/src/libs/actions/Search.ts index 2b6ce89f325a..d0638a0eac8f 100644 --- a/src/libs/actions/Search.ts +++ b/src/libs/actions/Search.ts @@ -2153,6 +2153,14 @@ function queueBulkPayReports(jsonQuery: string) { write(WRITE_COMMANDS.QUEUE_BULK_PAY_REPORTS, {jsonQuery, bulkActionID}, onyxData); } +/** + * Queues a bulk approval for every report matching the given search query. The backend pages through all matches itself, + * so this covers reports beyond the currently loaded page(s) when "Select all" is checked in Search. + */ +function queueBulkApproveReports(jsonQuery: string) { + write(WRITE_COMMANDS.QUEUE_BULK_APPROVE_REPORTS, {jsonQuery}); +} + /** Export templates pre-grouped for the Export menus: each group is sorted alphabetically and rendered with a divider between groups */ type ExportTemplateGroups = { /** Custom templates (custom integrations + account/policy in-app templates) */ @@ -2588,6 +2596,7 @@ export { queueExportSearchItemsToCSV, queueExportSearchWithTemplate, queueBulkPayReports, + queueBulkApproveReports, updateAdvancedFilters, setSearchContext, deleteSavedSearch, diff --git a/tests/unit/hooks/useSearchBulkActionsTest.ts b/tests/unit/hooks/useSearchBulkActionsTest.ts index 053ee015ff2d..3c3819bf47a8 100644 --- a/tests/unit/hooks/useSearchBulkActionsTest.ts +++ b/tests/unit/hooks/useSearchBulkActionsTest.ts @@ -5,7 +5,8 @@ import type {SearchQueryJSON, SelectedReports, SelectedTransactions} from '@comp import useSearchBulkActions from '@hooks/useSearchBulkActions'; -import {getExportTemplates, queueExportSearchItemsToCSV, queueExportSearchWithTemplate} from '@libs/actions/Search'; +import {approveMoneyRequest} from '@libs/actions/IOU/ReportWorkflow'; +import {getExportTemplates, queueBulkApproveReports, queueExportSearchItemsToCSV, queueExportSearchWithTemplate} from '@libs/actions/Search'; import CONST from '@src/CONST'; import ONYXKEYS from '@src/ONYXKEYS'; @@ -25,6 +26,7 @@ jest.mock('@libs/actions/Search', () => ({ exportSearchItemsToCSV: jest.fn(), queueExportSearchItemsToCSV: jest.fn(() => 'mock-export-id'), queueExportSearchWithTemplate: jest.fn(() => 'mock-template-export-id'), + queueBulkApproveReports: jest.fn(), getSearchApproveOnyxData: jest.fn(() => ({})), getSearchPayOnyxData: jest.fn(() => ({})), bulkDeleteReports: jest.fn(), @@ -40,6 +42,10 @@ jest.mock('@libs/actions/Search', () => ({ unholdMoneyRequestOnSearch: jest.fn(), })); +jest.mock('@libs/actions/IOU/ReportWorkflow', () => ({ + approveMoneyRequest: jest.fn(), +})); + jest.mock('@libs/actions/MergeTransaction', () => ({ setupMergeTransactionDataAndNavigate: jest.fn(), })); @@ -539,3 +545,76 @@ describe('useSearchBulkActions - CSV export flow', () => { expect(exportItems.some((item) => item.text === 'export.basicExport')).toBe(true); }); }); + +describe('useSearchBulkActions - Approve under Select all', () => { + beforeAll(() => { + Onyx.init({keys: ONYXKEYS}); + }); + + beforeEach(async () => { + jest.clearAllMocks(); + mockIsOffline = false; + mockAreAllMatchingItemsSelected = true; + await Onyx.clear(); + mockSelectedTransactions = {}; + mockExcludedTransactions = {}; + mockSelectedReports = []; + mockCurrentSearchResults = undefined; + mockGetExportTemplates.mockReturnValue({customTemplates: [], defaultTemplates: []}); + + await Onyx.merge(ONYXKEYS.SESSION, {accountID: CURRENT_USER_ACCOUNT_ID, email: 'test@example.com'}); + }); + + afterEach(async () => { + await Onyx.clear(); + }); + + it('queues a server-side bulk approval instead of approving per report', async () => { + // Given "Select all" is checked with an approvable expense loaded, so the selection can span more reports than are on the page + mockSelectedTransactions = {tx1: makeSelectedTransaction({action: CONST.SEARCH.ACTION_TYPES.APPROVE})}; + + const {result} = renderHook(() => useSearchBulkActions({queryJSON: baseQueryJSON})); + + await waitFor(() => { + expect(result.current.headerButtonsOptions.some((option) => option.value === CONST.SEARCH.BULK_ACTION_TYPES.APPROVE)).toBe(true); + }); + + // When the user selects Approve + const approveOption = result.current.headerButtonsOptions.find((option) => option.value === CONST.SEARCH.BULK_ACTION_TYPES.APPROVE); + await act(async () => { + await approveOption?.onSelected?.(); + }); + + // Then the approval is handed to the backend via the search query, not looped per loaded report + expect(queueBulkApproveReports).toHaveBeenCalledTimes(1); + expect(queueBulkApproveReports).toHaveBeenCalledWith(expect.any(String)); + expect(approveMoneyRequest).not.toHaveBeenCalled(); + expect(mockClearSelectedTransactions).toHaveBeenCalled(); + }); + + it('keeps the Approve option when a loaded expense is held', async () => { + // Given a held expense on the loaded page, which hides Approve for a normal selection + mockSelectedTransactions = {tx1: makeSelectedTransaction({action: CONST.SEARCH.ACTION_TYPES.APPROVE, isHeld: true})}; + + const {result} = renderHook(() => useSearchBulkActions({queryJSON: baseQueryJSON})); + + // Then Approve is still offered, because the backend skips reports it cannot approve + await waitFor(() => { + expect(result.current.headerButtonsOptions.some((option) => option.value === CONST.SEARCH.BULK_ACTION_TYPES.APPROVE)).toBe(true); + }); + }); + + it('hides the Approve option when no loaded expense can be approved', async () => { + // Given nothing on the loaded page is awaiting the user's approval + mockSelectedTransactions = {tx1: makeSelectedTransaction({action: CONST.SEARCH.ACTION_TYPES.VIEW})}; + + const {result} = renderHook(() => useSearchBulkActions({queryJSON: baseQueryJSON})); + + await waitFor(() => { + expect(result.current.headerButtonsOptions.length).toBeGreaterThan(0); + }); + + // Then Approve is not offered + expect(result.current.headerButtonsOptions.some((option) => option.value === CONST.SEARCH.BULK_ACTION_TYPES.APPROVE)).toBe(false); + }); +}); From 77fbae85bcaab32fd2e5c15141b5ef7c26b3c7cd Mon Sep 17 00:00:00 2001 From: allgandaf Date: Wed, 30 Sep 2026 10:13:48 +0530 Subject: [PATCH 09/73] show the bulk action modal for select all approve --- src/hooks/useSearchBulkActions.ts | 10 ++++++++-- .../API/parameters/QueueBulkApproveReportsParams.ts | 3 +++ src/libs/actions/Search.ts | 3 ++- 3 files changed, 13 insertions(+), 3 deletions(-) diff --git a/src/hooks/useSearchBulkActions.ts b/src/hooks/useSearchBulkActions.ts index ebedfd53830f..d7a588a2a99d 100644 --- a/src/hooks/useSearchBulkActions.ts +++ b/src/hooks/useSearchBulkActions.ts @@ -1243,9 +1243,13 @@ function useSearchBulkActions({queryJSON}: UseSearchBulkActionsParams) { // "Select all" can cover more reports than are loaded, so hand the search query to the backend to approve every match. if (areAllMatchingItemsSelected) { - const serializedQuery = queryJSON ? serializeQueryJSONForBackend(queryJSON) : JSON.stringify(queryJSON); + const allMatchingQuery = isExpenseReportType && queryJSON ? getAllMatchingReportQuery(queryJSON, excludedTransactions) : queryJSON; + if (isExpenseReportType && !allMatchingQuery) { + Log.info('[BulkApprove] Dropping bulk approve: report exclusion has no reportID'); + return; + } + const serializedQuery = allMatchingQuery ? serializeQueryJSONForBackend(allMatchingQuery) : JSON.stringify(allMatchingQuery); queueBulkApproveReports(serializedQuery); - playSound(SOUNDS.SUCCESS); clearSelectedTransactions(); return; } @@ -1315,6 +1319,8 @@ function useSearchBulkActions({queryJSON}: UseSearchBulkActionsParams) { hash, areAllMatchingItemsSelected, queryJSON, + isExpenseReportType, + excludedTransactions, clearSelectedTransactions, userBillingGracePeriodEnds, ownerBillingGracePeriodEnd, diff --git a/src/libs/API/parameters/QueueBulkApproveReportsParams.ts b/src/libs/API/parameters/QueueBulkApproveReportsParams.ts index a79539c4e13b..ca63571d96fe 100644 --- a/src/libs/API/parameters/QueueBulkApproveReportsParams.ts +++ b/src/libs/API/parameters/QueueBulkApproveReportsParams.ts @@ -3,6 +3,9 @@ import type {SearchQueryString} from '@components/Search/types'; type QueueBulkApproveReportsParams = { /** Serialized search query describing every report to approve, so the backend can page through all matches instead of relying on a client-side list */ jsonQuery: SearchQueryString; + + /** ID of the bulk action record the backend updates as the approvals finish */ + bulkActionID: string; }; export default QueueBulkApproveReportsParams; diff --git a/src/libs/actions/Search.ts b/src/libs/actions/Search.ts index d0638a0eac8f..fb77ea690284 100644 --- a/src/libs/actions/Search.ts +++ b/src/libs/actions/Search.ts @@ -2158,7 +2158,8 @@ function queueBulkPayReports(jsonQuery: string) { * so this covers reports beyond the currently loaded page(s) when "Select all" is checked in Search. */ function queueBulkApproveReports(jsonQuery: string) { - write(WRITE_COMMANDS.QUEUE_BULK_APPROVE_REPORTS, {jsonQuery}); + const {bulkActionID, onyxData} = buildBulkActionOnyxData(CONST.SEARCH.BULK_ACTION_TYPES.APPROVE); + write(WRITE_COMMANDS.QUEUE_BULK_APPROVE_REPORTS, {jsonQuery, bulkActionID}, onyxData); } /** Export templates pre-grouped for the Export menus: each group is sorted alphabetically and rendered with a divider between groups */ From f3ad99606344b2dd9d661e74ec6d5909fd27176a Mon Sep 17 00:00:00 2001 From: allgandaf Date: Wed, 30 Sep 2026 10:14:22 +0530 Subject: [PATCH 10/73] submit every report matching select all through the backend --- src/hooks/useSearchBulkActions.ts | 34 ++++++ .../QueueBulkSubmitReportsParams.ts | 8 ++ src/libs/API/parameters/index.ts | 1 + src/libs/API/types.ts | 2 + src/libs/actions/Search.ts | 9 ++ tests/unit/hooks/useSearchBulkActionsTest.ts | 101 +++++++++++++++++- 6 files changed, 154 insertions(+), 1 deletion(-) create mode 100644 src/libs/API/parameters/QueueBulkSubmitReportsParams.ts diff --git a/src/hooks/useSearchBulkActions.ts b/src/hooks/useSearchBulkActions.ts index d7a588a2a99d..cc6468d3d06b 100644 --- a/src/hooks/useSearchBulkActions.ts +++ b/src/hooks/useSearchBulkActions.ts @@ -36,6 +36,7 @@ import { isCurrencySupportWalletBulkPay, queueBulkApproveReports, queueBulkPayReports, + queueBulkSubmitReports, queueExportSearchItemsToCSV, queueExportSearchWithTemplate, resolveSearchPayPaymentMethod, @@ -2518,6 +2519,36 @@ function useSearchBulkActions({queryJSON}: UseSearchBulkActionsParams) { ? selectedReports.some((report) => report.canApprove) : selectedTransactionsKeys.some((id) => selectedTransactions[id].action === CONST.SEARCH.ACTION_TYPES.APPROVE); const shouldShowApproveOptionForAllMatchingItems = !isOffline && !hasSubmitPolicyTransactions && hasLoadedApprovableItem; + // The backend only submits the matching reports the user can submit, so one submittable loaded item is enough to offer it. + // Submit plan workspaces pick an approver per report and Mark as done is a different action, so neither is sent to the backend. + const hasLoadedSubmittableItem = selectedReports.length + ? selectedReports.some((report) => report.canSubmit) + : selectedTransactionsKeys.some((id) => selectedTransactions[id].action === CONST.SEARCH.ACTION_TYPES.SUBMIT); + const shouldShowSubmitOptionForAllMatchingItems = !isOffline && !doSelectedItemsBelongToSubmitPolicy && noReportsShouldMarkAsDone && hasLoadedSubmittableItem; + const submitAllMatchingItemsOption: DropdownOption = { + icon: expensifyIcons.Send, + text: translate('common.submit'), + value: CONST.SEARCH.BULK_ACTION_TYPES.SUBMIT, + shouldCloseModalOnSelect: true, + onSelected: () => { + if (isOffline) { + setIsOfflineModalVisible(true); + return; + } + + const itemList = selectedReports.length ? selectedReports : Object.values(selectedTransactions); + const restrictedPolicyID = getRestrictedPolicyID(itemList, userBillingGracePeriodEnds, ownerBillingGracePeriodEnd, amountOwed, policies, accountID); + if (restrictedPolicyID) { + Navigation.navigate(ROUTES.RESTRICTED_ACTION.getRoute(restrictedPolicyID)); + return; + } + + const serializedQuery = queryJSON ? serializeQueryJSONForBackend(queryJSON) : JSON.stringify(queryJSON); + queueBulkSubmitReports(serializedQuery); + playSound(SOUNDS.SUCCESS); + clearSelectedTransactions(); + }, + }; // Offer an all-matching move only when no rows are excluded and unloaded matches are unreported. // The backend rejects the entire move if any matching expense is invalid @@ -2527,6 +2558,9 @@ function useSearchBulkActions({queryJSON}: UseSearchBulkActionsParams) { if (shouldShowApproveOptionForAllMatchingItems) { allMatchingOptions.push(approveButtonOption); } + if (shouldShowSubmitOptionForAllMatchingItems) { + allMatchingOptions.push(submitAllMatchingItemsOption); + } if (shouldShowPayOption) { allMatchingOptions.push(payButtonOption); } diff --git a/src/libs/API/parameters/QueueBulkSubmitReportsParams.ts b/src/libs/API/parameters/QueueBulkSubmitReportsParams.ts new file mode 100644 index 000000000000..d091db5228b6 --- /dev/null +++ b/src/libs/API/parameters/QueueBulkSubmitReportsParams.ts @@ -0,0 +1,8 @@ +import type {SearchQueryString} from '@components/Search/types'; + +type QueueBulkSubmitReportsParams = { + /** Serialized search query describing every report to submit, so the backend can page through all matches instead of relying on a client-side list */ + jsonQuery: SearchQueryString; +}; + +export default QueueBulkSubmitReportsParams; diff --git a/src/libs/API/parameters/index.ts b/src/libs/API/parameters/index.ts index 0d78d295a37c..aad119f30361 100644 --- a/src/libs/API/parameters/index.ts +++ b/src/libs/API/parameters/index.ts @@ -601,6 +601,7 @@ export type {default as QueueExportSearchItemsToCSVParams} from './QueueExportSe export type {default as QueueExportSearchWithTemplateParams} from './QueueExportSearchWithTemplateParams'; export type {default as QueueBulkPayReportsParams} from './QueueBulkPayReportsParams'; export type {default as QueueBulkApproveReportsParams} from './QueueBulkApproveReportsParams'; +export type {default as QueueBulkSubmitReportsParams} from './QueueBulkSubmitReportsParams'; export type {default as AssignReportToMeParams} from './AssignReportToMeParams'; export type {default as AddReportApproverParams} from './AddReportApproverParams'; export type {default as EnableGlobalReimbursementsForUSDBankAccountParams} from './EnableGlobalReimbursementsForUSDBankAccountParams'; diff --git a/src/libs/API/types.ts b/src/libs/API/types.ts index b5169eb6d387..112c9c58fb4d 100644 --- a/src/libs/API/types.ts +++ b/src/libs/API/types.ts @@ -604,6 +604,7 @@ const WRITE_COMMANDS = { QUEUE_EXPORT_SEARCH_WITH_TEMPLATE: 'QueueExportSearchWithTemplate', QUEUE_BULK_PAY_REPORTS: 'QueueBulkPayReports', QUEUE_BULK_APPROVE_REPORTS: 'QueueBulkApproveReports', + QUEUE_BULK_SUBMIT_REPORTS: 'QueueBulkSubmitReports', CREATE_WORKSPACE_APPROVAL: 'CreateWorkspaceApproval', UPDATE_WORKSPACE_APPROVAL: 'UpdateWorkspaceApproval', REMOVE_WORKSPACE_APPROVAL: 'RemoveWorkspaceApproval', @@ -1387,6 +1388,7 @@ type WriteCommandParameters = { [WRITE_COMMANDS.QUEUE_EXPORT_SEARCH_WITH_TEMPLATE]: Parameters.QueueExportSearchWithTemplateParams; [WRITE_COMMANDS.QUEUE_BULK_PAY_REPORTS]: Parameters.QueueBulkPayReportsParams; [WRITE_COMMANDS.QUEUE_BULK_APPROVE_REPORTS]: Parameters.QueueBulkApproveReportsParams; + [WRITE_COMMANDS.QUEUE_BULK_SUBMIT_REPORTS]: Parameters.QueueBulkSubmitReportsParams; [WRITE_COMMANDS.EXPORT_REPORT_TO_CSV]: Parameters.ExportReportCSVParams; [WRITE_COMMANDS.CREATE_WORKSPACE_APPROVAL]: Parameters.CreateWorkspaceApprovalParams; [WRITE_COMMANDS.UPDATE_WORKSPACE_APPROVAL]: Parameters.UpdateWorkspaceApprovalParams; diff --git a/src/libs/actions/Search.ts b/src/libs/actions/Search.ts index fb77ea690284..d5bf6a8a45af 100644 --- a/src/libs/actions/Search.ts +++ b/src/libs/actions/Search.ts @@ -2162,6 +2162,14 @@ function queueBulkApproveReports(jsonQuery: string) { write(WRITE_COMMANDS.QUEUE_BULK_APPROVE_REPORTS, {jsonQuery, bulkActionID}, onyxData); } +/** + * Queues a bulk submit for every report matching the given search query. The backend pages through all matches itself, + * so this covers reports beyond the currently loaded page(s) when "Select all" is checked in Search. + */ +function queueBulkSubmitReports(jsonQuery: string) { + write(WRITE_COMMANDS.QUEUE_BULK_SUBMIT_REPORTS, {jsonQuery}); +} + /** Export templates pre-grouped for the Export menus: each group is sorted alphabetically and rendered with a divider between groups */ type ExportTemplateGroups = { /** Custom templates (custom integrations + account/policy in-app templates) */ @@ -2598,6 +2606,7 @@ export { queueExportSearchWithTemplate, queueBulkPayReports, queueBulkApproveReports, + queueBulkSubmitReports, updateAdvancedFilters, setSearchContext, deleteSavedSearch, diff --git a/tests/unit/hooks/useSearchBulkActionsTest.ts b/tests/unit/hooks/useSearchBulkActionsTest.ts index 3c3819bf47a8..8fdfa4fdaab7 100644 --- a/tests/unit/hooks/useSearchBulkActionsTest.ts +++ b/tests/unit/hooks/useSearchBulkActionsTest.ts @@ -6,7 +6,14 @@ import type {SearchQueryJSON, SelectedReports, SelectedTransactions} from '@comp import useSearchBulkActions from '@hooks/useSearchBulkActions'; import {approveMoneyRequest} from '@libs/actions/IOU/ReportWorkflow'; -import {getExportTemplates, queueBulkApproveReports, queueExportSearchItemsToCSV, queueExportSearchWithTemplate} from '@libs/actions/Search'; +import { + getExportTemplates, + queueBulkApproveReports, + queueBulkSubmitReports, + queueExportSearchItemsToCSV, + queueExportSearchWithTemplate, + submitMoneyRequestOnSearch, +} from '@libs/actions/Search'; import CONST from '@src/CONST'; import ONYXKEYS from '@src/ONYXKEYS'; @@ -27,6 +34,7 @@ jest.mock('@libs/actions/Search', () => ({ queueExportSearchItemsToCSV: jest.fn(() => 'mock-export-id'), queueExportSearchWithTemplate: jest.fn(() => 'mock-template-export-id'), queueBulkApproveReports: jest.fn(), + queueBulkSubmitReports: jest.fn(), getSearchApproveOnyxData: jest.fn(() => ({})), getSearchPayOnyxData: jest.fn(() => ({})), bulkDeleteReports: jest.fn(), @@ -618,3 +626,94 @@ describe('useSearchBulkActions - Approve under Select all', () => { expect(result.current.headerButtonsOptions.some((option) => option.value === CONST.SEARCH.BULK_ACTION_TYPES.APPROVE)).toBe(false); }); }); + +describe('useSearchBulkActions - Submit under Select all', () => { + beforeAll(() => { + Onyx.init({keys: ONYXKEYS}); + }); + + beforeEach(async () => { + jest.clearAllMocks(); + mockIsOffline = false; + mockAreAllMatchingItemsSelected = true; + await Onyx.clear(); + mockSelectedTransactions = {}; + mockExcludedTransactions = {}; + mockSelectedReports = []; + mockCurrentSearchResults = undefined; + mockGetExportTemplates.mockReturnValue({customTemplates: [], defaultTemplates: []}); + + await Onyx.merge(ONYXKEYS.SESSION, {accountID: CURRENT_USER_ACCOUNT_ID, email: 'test@example.com'}); + }); + + afterEach(async () => { + await Onyx.clear(); + }); + + it('queues a server-side bulk submit instead of submitting per report', async () => { + // Given "Select all" is checked with a submittable expense loaded, so the selection can span more reports than are on the page + mockSelectedTransactions = {tx1: makeSelectedTransaction({action: CONST.SEARCH.ACTION_TYPES.SUBMIT})}; + + const {result} = renderHook(() => useSearchBulkActions({queryJSON: baseQueryJSON})); + + await waitFor(() => { + expect(result.current.headerButtonsOptions.some((option) => option.value === CONST.SEARCH.BULK_ACTION_TYPES.SUBMIT)).toBe(true); + }); + + // When the user selects Submit + const submitOption = result.current.headerButtonsOptions.find((option) => option.value === CONST.SEARCH.BULK_ACTION_TYPES.SUBMIT); + await act(async () => { + await submitOption?.onSelected?.(); + }); + + // Then the submit is handed to the backend via the search query, not looped per loaded report + expect(queueBulkSubmitReports).toHaveBeenCalledTimes(1); + expect(queueBulkSubmitReports).toHaveBeenCalledWith(expect.any(String)); + expect(submitMoneyRequestOnSearch).not.toHaveBeenCalled(); + expect(mockClearSelectedTransactions).toHaveBeenCalled(); + }); + + it('hides the Submit option when no loaded expense can be submitted', async () => { + // Given nothing on the loaded page is waiting to be submitted + mockSelectedTransactions = {tx1: makeSelectedTransaction({action: CONST.SEARCH.ACTION_TYPES.VIEW})}; + + const {result} = renderHook(() => useSearchBulkActions({queryJSON: baseQueryJSON})); + + await waitFor(() => { + expect(result.current.headerButtonsOptions.length).toBeGreaterThan(0); + }); + + // Then Submit is not offered + expect(result.current.headerButtonsOptions.some((option) => option.value === CONST.SEARCH.BULK_ACTION_TYPES.SUBMIT)).toBe(false); + }); + + it('hides the Submit option when offline', async () => { + // Given a submittable expense is loaded but the user is offline + mockIsOffline = true; + mockSelectedTransactions = {tx1: makeSelectedTransaction({action: CONST.SEARCH.ACTION_TYPES.SUBMIT})}; + + const {result} = renderHook(() => useSearchBulkActions({queryJSON: baseQueryJSON})); + + await waitFor(() => { + expect(result.current.headerButtonsOptions.length).toBeGreaterThan(0); + }); + + // Then Submit is not offered + expect(result.current.headerButtonsOptions.some((option) => option.value === CONST.SEARCH.BULK_ACTION_TYPES.SUBMIT)).toBe(false); + }); + + it('hides the Submit option for a Submit plan workspace, where the approver is picked per report', async () => { + // Given the loaded submittable expense belongs to a Submit plan workspace + await Onyx.merge(`${ONYXKEYS.COLLECTION.POLICY}policy1`, {id: 'policy1', type: CONST.POLICY.TYPE.SUBMIT}); + mockSelectedTransactions = {tx1: makeSelectedTransaction({action: CONST.SEARCH.ACTION_TYPES.SUBMIT, policyID: 'policy1'})}; + + const {result} = renderHook(() => useSearchBulkActions({queryJSON: baseQueryJSON})); + + await waitFor(() => { + expect(result.current.headerButtonsOptions.length).toBeGreaterThan(0); + }); + + // Then Submit is not offered, because the backend cannot ask which approver to send each report to + expect(result.current.headerButtonsOptions.some((option) => option.value === CONST.SEARCH.BULK_ACTION_TYPES.SUBMIT)).toBe(false); + }); +}); From db3c46b5e2ee0abb32702e854eb5c86e2bafe85e Mon Sep 17 00:00:00 2001 From: allgandaf Date: Wed, 30 Sep 2026 10:14:42 +0530 Subject: [PATCH 11/73] show the bulk action modal for select all submit --- src/hooks/useSearchBulkActions.ts | 8 ++++++-- src/libs/API/parameters/QueueBulkSubmitReportsParams.ts | 3 +++ src/libs/actions/Search.ts | 3 ++- 3 files changed, 11 insertions(+), 3 deletions(-) diff --git a/src/hooks/useSearchBulkActions.ts b/src/hooks/useSearchBulkActions.ts index cc6468d3d06b..55befe13f8bf 100644 --- a/src/hooks/useSearchBulkActions.ts +++ b/src/hooks/useSearchBulkActions.ts @@ -2543,9 +2543,13 @@ function useSearchBulkActions({queryJSON}: UseSearchBulkActionsParams) { return; } - const serializedQuery = queryJSON ? serializeQueryJSONForBackend(queryJSON) : JSON.stringify(queryJSON); + const allMatchingQuery = isExpenseReportType && queryJSON ? getAllMatchingReportQuery(queryJSON, excludedTransactions) : queryJSON; + if (isExpenseReportType && !allMatchingQuery) { + Log.info('[BulkSubmit] Dropping bulk submit: report exclusion has no reportID'); + return; + } + const serializedQuery = allMatchingQuery ? serializeQueryJSONForBackend(allMatchingQuery) : JSON.stringify(allMatchingQuery); queueBulkSubmitReports(serializedQuery); - playSound(SOUNDS.SUCCESS); clearSelectedTransactions(); }, }; diff --git a/src/libs/API/parameters/QueueBulkSubmitReportsParams.ts b/src/libs/API/parameters/QueueBulkSubmitReportsParams.ts index d091db5228b6..6b49003c2a02 100644 --- a/src/libs/API/parameters/QueueBulkSubmitReportsParams.ts +++ b/src/libs/API/parameters/QueueBulkSubmitReportsParams.ts @@ -3,6 +3,9 @@ import type {SearchQueryString} from '@components/Search/types'; type QueueBulkSubmitReportsParams = { /** Serialized search query describing every report to submit, so the backend can page through all matches instead of relying on a client-side list */ jsonQuery: SearchQueryString; + + /** ID of the bulk action record the backend updates as the submissions finish */ + bulkActionID: string; }; export default QueueBulkSubmitReportsParams; diff --git a/src/libs/actions/Search.ts b/src/libs/actions/Search.ts index d5bf6a8a45af..91a9e18ceb57 100644 --- a/src/libs/actions/Search.ts +++ b/src/libs/actions/Search.ts @@ -2167,7 +2167,8 @@ function queueBulkApproveReports(jsonQuery: string) { * so this covers reports beyond the currently loaded page(s) when "Select all" is checked in Search. */ function queueBulkSubmitReports(jsonQuery: string) { - write(WRITE_COMMANDS.QUEUE_BULK_SUBMIT_REPORTS, {jsonQuery}); + const {bulkActionID, onyxData} = buildBulkActionOnyxData(CONST.SEARCH.BULK_ACTION_TYPES.SUBMIT); + write(WRITE_COMMANDS.QUEUE_BULK_SUBMIT_REPORTS, {jsonQuery, bulkActionID}, onyxData); } /** Export templates pre-grouped for the Export menus: each group is sorted alphabetically and rendered with a divider between groups */ From d33b266fadd185004af2918bac594111f5265991 Mon Sep 17 00:00:00 2001 From: allgandaf Date: Wed, 30 Sep 2026 10:15:56 +0530 Subject: [PATCH 12/73] wrap select all approve and submit tests in OnyxListItemProvider --- tests/unit/hooks/useSearchBulkActionsTest.ts | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/tests/unit/hooks/useSearchBulkActionsTest.ts b/tests/unit/hooks/useSearchBulkActionsTest.ts index 8fdfa4fdaab7..8fde1e8b30d8 100644 --- a/tests/unit/hooks/useSearchBulkActionsTest.ts +++ b/tests/unit/hooks/useSearchBulkActionsTest.ts @@ -581,7 +581,7 @@ describe('useSearchBulkActions - Approve under Select all', () => { // Given "Select all" is checked with an approvable expense loaded, so the selection can span more reports than are on the page mockSelectedTransactions = {tx1: makeSelectedTransaction({action: CONST.SEARCH.ACTION_TYPES.APPROVE})}; - const {result} = renderHook(() => useSearchBulkActions({queryJSON: baseQueryJSON})); + const {result} = renderHook(() => useSearchBulkActions({queryJSON: baseQueryJSON}), {wrapper: OnyxListItemProvider}); await waitFor(() => { expect(result.current.headerButtonsOptions.some((option) => option.value === CONST.SEARCH.BULK_ACTION_TYPES.APPROVE)).toBe(true); @@ -604,7 +604,7 @@ describe('useSearchBulkActions - Approve under Select all', () => { // Given a held expense on the loaded page, which hides Approve for a normal selection mockSelectedTransactions = {tx1: makeSelectedTransaction({action: CONST.SEARCH.ACTION_TYPES.APPROVE, isHeld: true})}; - const {result} = renderHook(() => useSearchBulkActions({queryJSON: baseQueryJSON})); + const {result} = renderHook(() => useSearchBulkActions({queryJSON: baseQueryJSON}), {wrapper: OnyxListItemProvider}); // Then Approve is still offered, because the backend skips reports it cannot approve await waitFor(() => { @@ -616,7 +616,7 @@ describe('useSearchBulkActions - Approve under Select all', () => { // Given nothing on the loaded page is awaiting the user's approval mockSelectedTransactions = {tx1: makeSelectedTransaction({action: CONST.SEARCH.ACTION_TYPES.VIEW})}; - const {result} = renderHook(() => useSearchBulkActions({queryJSON: baseQueryJSON})); + const {result} = renderHook(() => useSearchBulkActions({queryJSON: baseQueryJSON}), {wrapper: OnyxListItemProvider}); await waitFor(() => { expect(result.current.headerButtonsOptions.length).toBeGreaterThan(0); @@ -654,7 +654,7 @@ describe('useSearchBulkActions - Submit under Select all', () => { // Given "Select all" is checked with a submittable expense loaded, so the selection can span more reports than are on the page mockSelectedTransactions = {tx1: makeSelectedTransaction({action: CONST.SEARCH.ACTION_TYPES.SUBMIT})}; - const {result} = renderHook(() => useSearchBulkActions({queryJSON: baseQueryJSON})); + const {result} = renderHook(() => useSearchBulkActions({queryJSON: baseQueryJSON}), {wrapper: OnyxListItemProvider}); await waitFor(() => { expect(result.current.headerButtonsOptions.some((option) => option.value === CONST.SEARCH.BULK_ACTION_TYPES.SUBMIT)).toBe(true); @@ -677,7 +677,7 @@ describe('useSearchBulkActions - Submit under Select all', () => { // Given nothing on the loaded page is waiting to be submitted mockSelectedTransactions = {tx1: makeSelectedTransaction({action: CONST.SEARCH.ACTION_TYPES.VIEW})}; - const {result} = renderHook(() => useSearchBulkActions({queryJSON: baseQueryJSON})); + const {result} = renderHook(() => useSearchBulkActions({queryJSON: baseQueryJSON}), {wrapper: OnyxListItemProvider}); await waitFor(() => { expect(result.current.headerButtonsOptions.length).toBeGreaterThan(0); @@ -692,7 +692,7 @@ describe('useSearchBulkActions - Submit under Select all', () => { mockIsOffline = true; mockSelectedTransactions = {tx1: makeSelectedTransaction({action: CONST.SEARCH.ACTION_TYPES.SUBMIT})}; - const {result} = renderHook(() => useSearchBulkActions({queryJSON: baseQueryJSON})); + const {result} = renderHook(() => useSearchBulkActions({queryJSON: baseQueryJSON}), {wrapper: OnyxListItemProvider}); await waitFor(() => { expect(result.current.headerButtonsOptions.length).toBeGreaterThan(0); @@ -707,7 +707,7 @@ describe('useSearchBulkActions - Submit under Select all', () => { await Onyx.merge(`${ONYXKEYS.COLLECTION.POLICY}policy1`, {id: 'policy1', type: CONST.POLICY.TYPE.SUBMIT}); mockSelectedTransactions = {tx1: makeSelectedTransaction({action: CONST.SEARCH.ACTION_TYPES.SUBMIT, policyID: 'policy1'})}; - const {result} = renderHook(() => useSearchBulkActions({queryJSON: baseQueryJSON})); + const {result} = renderHook(() => useSearchBulkActions({queryJSON: baseQueryJSON}), {wrapper: OnyxListItemProvider}); await waitFor(() => { expect(result.current.headerButtonsOptions.length).toBeGreaterThan(0); From aa6e5ba24b74815a013d6368f3c302e2418ee518 Mon Sep 17 00:00:00 2001 From: allgandaf Date: Wed, 30 Sep 2026 10:15:56 +0530 Subject: [PATCH 13/73] test that deselected reports are left out of bulk approve and submit --- tests/unit/hooks/useSearchBulkActionsTest.ts | 42 ++++++++++++++++++++ 1 file changed, 42 insertions(+) diff --git a/tests/unit/hooks/useSearchBulkActionsTest.ts b/tests/unit/hooks/useSearchBulkActionsTest.ts index 8fde1e8b30d8..8fe4f7c23096 100644 --- a/tests/unit/hooks/useSearchBulkActionsTest.ts +++ b/tests/unit/hooks/useSearchBulkActionsTest.ts @@ -600,6 +600,27 @@ describe('useSearchBulkActions - Approve under Select all', () => { expect(mockClearSelectedTransactions).toHaveBeenCalled(); }); + it('leaves out reports the user deselected from the bulk approval', async () => { + // Given "Select all" on a reports search, with one report deselected afterwards + mockSelectedTransactions = {tx1: makeSelectedTransaction({action: CONST.SEARCH.ACTION_TYPES.APPROVE, reportID: 'report1'})}; + mockExcludedTransactions = {tx2: makeSelectedTransaction({reportID: 'report2'})}; + + const {result} = renderHook(() => useSearchBulkActions({queryJSON: expenseReportQueryJSON}), {wrapper: OnyxListItemProvider}); + + await waitFor(() => { + expect(result.current.headerButtonsOptions.some((option) => option.value === CONST.SEARCH.BULK_ACTION_TYPES.APPROVE)).toBe(true); + }); + + // When the user selects Approve + const approveOption = result.current.headerButtonsOptions.find((option) => option.value === CONST.SEARCH.BULK_ACTION_TYPES.APPROVE); + await act(async () => { + await approveOption?.onSelected?.(); + }); + + // Then the query sent to the backend excludes the deselected report, so it isn't approved + expect(queueBulkApproveReports).toHaveBeenCalledWith(expect.stringContaining('report2')); + }); + it('keeps the Approve option when a loaded expense is held', async () => { // Given a held expense on the loaded page, which hides Approve for a normal selection mockSelectedTransactions = {tx1: makeSelectedTransaction({action: CONST.SEARCH.ACTION_TYPES.APPROVE, isHeld: true})}; @@ -673,6 +694,27 @@ describe('useSearchBulkActions - Submit under Select all', () => { expect(mockClearSelectedTransactions).toHaveBeenCalled(); }); + it('leaves out reports the user deselected from the bulk submit', async () => { + // Given "Select all" on a reports search, with one report deselected afterwards + mockSelectedTransactions = {tx1: makeSelectedTransaction({action: CONST.SEARCH.ACTION_TYPES.SUBMIT, reportID: 'report1'})}; + mockExcludedTransactions = {tx2: makeSelectedTransaction({reportID: 'report2'})}; + + const {result} = renderHook(() => useSearchBulkActions({queryJSON: expenseReportQueryJSON}), {wrapper: OnyxListItemProvider}); + + await waitFor(() => { + expect(result.current.headerButtonsOptions.some((option) => option.value === CONST.SEARCH.BULK_ACTION_TYPES.SUBMIT)).toBe(true); + }); + + // When the user selects Submit + const submitOption = result.current.headerButtonsOptions.find((option) => option.value === CONST.SEARCH.BULK_ACTION_TYPES.SUBMIT); + await act(async () => { + await submitOption?.onSelected?.(); + }); + + // Then the query sent to the backend excludes the deselected report, so it isn't submitted + expect(queueBulkSubmitReports).toHaveBeenCalledWith(expect.stringContaining('report2')); + }); + it('hides the Submit option when no loaded expense can be submitted', async () => { // Given nothing on the loaded page is waiting to be submitted mockSelectedTransactions = {tx1: makeSelectedTransaction({action: CONST.SEARCH.ACTION_TYPES.VIEW})}; From 5d8a2366817be0f49de5c9abca2330de176d6f19 Mon Sep 17 00:00:00 2001 From: allgandaf Date: Wed, 30 Sep 2026 10:16:41 +0530 Subject: [PATCH 14/73] test the bulk action status modal --- tests/unit/BulkActionStatusManagerTest.tsx | 137 +++++++++++++++++++++ 1 file changed, 137 insertions(+) create mode 100644 tests/unit/BulkActionStatusManagerTest.tsx diff --git a/tests/unit/BulkActionStatusManagerTest.tsx b/tests/unit/BulkActionStatusManagerTest.tsx new file mode 100644 index 000000000000..ac43aa4bdc25 --- /dev/null +++ b/tests/unit/BulkActionStatusManagerTest.tsx @@ -0,0 +1,137 @@ +import {fireEvent, render, screen} from '@testing-library/react-native'; + +import BulkActionStatusManager from '@components/BulkActionStatusManager'; + +import Navigation from '@libs/Navigation/Navigation'; + +import {clearBulkAction, sendBulkActionSummaryFromConcierge} from '@userActions/BulkAction'; +import type * as Modal from '@userActions/Modal'; + +import CONST from '@src/CONST'; +import ONYXKEYS from '@src/ONYXKEYS'; + +import React from 'react'; +import Onyx from 'react-native-onyx'; + +import waitForBatchedUpdatesWithAct from '../utils/waitForBatchedUpdatesWithAct'; + +jest.mock('@userActions/BulkAction', () => ({ + sendBulkActionSummaryFromConcierge: jest.fn(), + clearBulkAction: jest.fn(), + wasBulkActionInitiatedLocally: jest.fn(() => false), +})); +jest.mock('@userActions/Modal', () => ({ + ...jest.requireActual('@userActions/Modal'), + close: jest.fn((cb?: () => void) => cb?.()), +})); +jest.mock('@libs/Navigation/Navigation', () => ({ + navigate: jest.fn(), + isNavigationReady: jest.fn(() => Promise.resolve()), + isTopmostRouteModalScreen: jest.fn(() => false), + getActiveRouteWithoutParams: jest.fn(() => ''), +})); +jest.mock('@hooks/useOpenConciergeAnywhere', () => ({ + __esModule: true, + default: () => ({ + openConciergeAnywhere: jest.fn(), + isInSidePanel: false, + }), +})); +jest.mock('@hooks/useLocalize', () => ({ + __esModule: true, + default: () => ({ + translate: (key: string) => key, + }), +})); + +const mockClearBulkAction = jest.mocked(clearBulkAction); +const mockSendFromConcierge = jest.mocked(sendBulkActionSummaryFromConcierge); +const mockNavigate = jest.mocked(Navigation.navigate); + +const BULK_ACTION_ID = 'test-bulk-action-123'; +const BULK_ACTION_KEY = `${ONYXKEYS.COLLECTION.BULK_ACTION}${BULK_ACTION_ID}` as const; + +describe('BulkActionStatusManager', () => { + beforeAll(() => { + Onyx.init({keys: ONYXKEYS}); + }); + + beforeEach(async () => { + jest.clearAllMocks(); + await Onyx.clear(); + }); + + it('shows the running approval with the option to have Concierge message the result', async () => { + // Given a bulk approval that is still running + await Onyx.set(BULK_ACTION_KEY, {state: CONST.BULK_ACTION.STATE.RUNNING, action: CONST.SEARCH.BULK_ACTION_TYPES.APPROVE}); + + render(); + await waitForBatchedUpdatesWithAct(); + + // When the user asks Concierge to message them + expect(screen.getByText('bulkAction.approvingTitle')).toBeTruthy(); + fireEvent.press(screen.getByText('bulkAction.sendFromConcierge')); + + // Then Concierge is asked for the summary and the record stays, because the backend still has to finish it + expect(mockSendFromConcierge).toHaveBeenCalledWith(BULK_ACTION_ID, expect.objectContaining({state: CONST.BULK_ACTION.STATE.RUNNING})); + expect(mockClearBulkAction).not.toHaveBeenCalled(); + }); + + it('does not show a bulk action Concierge will message about', async () => { + // Given a running bulk action the user already handed to Concierge + await Onyx.set(BULK_ACTION_KEY, {state: CONST.BULK_ACTION.STATE.RUNNING, action: CONST.SEARCH.BULK_ACTION_TYPES.PAY, shouldSendFromConcierge: true}); + + // When the app loads + render(); + await waitForBatchedUpdatesWithAct(); + + // Then no modal is shown, because Concierge sends the result + expect(screen.queryByText('bulkAction.payingTitle')).toBeNull(); + expect(screen.queryByText('bulkAction.conciergeTitle')).toBeNull(); + }); + + it('opens the reports that could not be approved in Search', async () => { + // Given a finished bulk approval where two reports could not be approved + await Onyx.set(BULK_ACTION_KEY, {state: CONST.BULK_ACTION.STATE.DONE, action: CONST.SEARCH.BULK_ACTION_TYPES.APPROVE, total: 5, failedReportIDs: ['111', '222']}); + + render(); + await waitForBatchedUpdatesWithAct(); + + // When the user opens those reports + expect(screen.getByText('bulkAction.approvedTitle')).toBeTruthy(); + fireEvent.press(screen.getByText('bulkAction.viewFailedReports')); + + // Then Search opens on exactly those reports and the record is cleared + expect(mockNavigate).toHaveBeenCalledWith(expect.stringMatching(/reportID%3A111%2C222/)); + expect(mockClearBulkAction).toHaveBeenCalledWith(BULK_ACTION_ID, expect.objectContaining({state: CONST.BULK_ACTION.STATE.DONE})); + }); + + it('clears a finished bulk submit when it is closed', async () => { + // Given a finished bulk submit where every report was submitted + await Onyx.set(BULK_ACTION_KEY, {state: CONST.BULK_ACTION.STATE.DONE, action: CONST.SEARCH.BULK_ACTION_TYPES.SUBMIT, total: 3, failedReportIDs: []}); + + render(); + await waitForBatchedUpdatesWithAct(); + + // When the user closes the modal + expect(screen.getByText('bulkAction.submittedTitle')).toBeTruthy(); + expect(screen.queryByText('bulkAction.viewFailedReports')).toBeNull(); + fireEvent.press(screen.getByText('common.close')); + + // Then the record is cleared so the modal doesn't come back + expect(mockClearBulkAction).toHaveBeenCalledWith(BULK_ACTION_ID, expect.objectContaining({state: CONST.BULK_ACTION.STATE.DONE})); + }); + + it('says so when no report matched', async () => { + // Given a bulk pay that found no report to mark as paid + await Onyx.set(BULK_ACTION_KEY, {state: CONST.BULK_ACTION.STATE.DONE, action: CONST.SEARCH.BULK_ACTION_TYPES.PAY, total: 0}); + + // When the app loads + render(); + await waitForBatchedUpdatesWithAct(); + + // Then the modal says nothing matched instead of "0 of 0" + expect(screen.getByText('bulkAction.noReportsTitle')).toBeTruthy(); + expect(screen.queryByText('bulkAction.paidTitle')).toBeNull(); + }); +}); From dab3043c40553f54aeb38f769988980b4c2cea00 Mon Sep 17 00:00:00 2001 From: allgandaf Date: Sun, 4 Oct 2026 01:59:46 +0530 Subject: [PATCH 15/73] list the bulk action key in the onyx state export rules --- src/libs/ExportOnyxState/masking.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/src/libs/ExportOnyxState/masking.ts b/src/libs/ExportOnyxState/masking.ts index d6312161bfdd..3d509abb5ebf 100644 --- a/src/libs/ExportOnyxState/masking.ts +++ b/src/libs/ExportOnyxState/masking.ts @@ -381,6 +381,7 @@ const onyxKeysToMaskFragileData = new Set([ ONYXKEYS.BILLING_RECEIPT_DETAILS, ONYXKEYS.COLLECTION.ATTACHMENT, ONYXKEYS.COLLECTION.BANK_ACCOUNT_SHARE_DETAILS, + ONYXKEYS.COLLECTION.BULK_ACTION, ONYXKEYS.COLLECTION.CODING_RULE_MATCHING_TRANSACTION, ONYXKEYS.COLLECTION.DEPRECATED_POLICY_MEMBER_LIST, ONYXKEYS.COLLECTION.DOMAIN, From 910f42e1716e23fd7eafb6eb6547e914f366373b Mon Sep 17 00:00:00 2001 From: allgandaf Date: Sun, 4 Oct 2026 02:22:07 +0530 Subject: [PATCH 16/73] add bulk hold and unhold commands --- .../parameters/QueueBulkHoldExpensesParams.ts | 17 +++++++++++++++++ .../parameters/QueueBulkUnholdExpensesParams.ts | 14 ++++++++++++++ src/libs/API/parameters/index.ts | 2 ++ src/libs/API/types.ts | 4 ++++ src/libs/actions/Search.ts | 14 ++++++++++++++ src/types/onyx/BulkAction.ts | 7 ++++++- 6 files changed, 57 insertions(+), 1 deletion(-) create mode 100644 src/libs/API/parameters/QueueBulkHoldExpensesParams.ts create mode 100644 src/libs/API/parameters/QueueBulkUnholdExpensesParams.ts diff --git a/src/libs/API/parameters/QueueBulkHoldExpensesParams.ts b/src/libs/API/parameters/QueueBulkHoldExpensesParams.ts new file mode 100644 index 000000000000..65568c911945 --- /dev/null +++ b/src/libs/API/parameters/QueueBulkHoldExpensesParams.ts @@ -0,0 +1,17 @@ +import type {SearchQueryString} from '@components/Search/types'; + +type QueueBulkHoldExpensesParams = { + /** Serialized search query describing every expense to hold, so the backend can page through all matches instead of relying on a client-side list */ + jsonQuery: SearchQueryString; + + /** Why the expenses are being held */ + comment: string; + + /** ID of the bulk action record the backend updates as the holds finish */ + bulkActionID: string; + + /** Comma-separated expenses the user deselected after "Select all" */ + excludedTransactionIDList: string; +}; + +export default QueueBulkHoldExpensesParams; diff --git a/src/libs/API/parameters/QueueBulkUnholdExpensesParams.ts b/src/libs/API/parameters/QueueBulkUnholdExpensesParams.ts new file mode 100644 index 000000000000..6b251fdd2196 --- /dev/null +++ b/src/libs/API/parameters/QueueBulkUnholdExpensesParams.ts @@ -0,0 +1,14 @@ +import type {SearchQueryString} from '@components/Search/types'; + +type QueueBulkUnholdExpensesParams = { + /** Serialized search query describing every expense to unhold, so the backend can page through all matches instead of relying on a client-side list */ + jsonQuery: SearchQueryString; + + /** ID of the bulk action record the backend updates as each expense comes off hold */ + bulkActionID: string; + + /** Comma-separated expenses the user deselected after "Select all" */ + excludedTransactionIDList: string; +}; + +export default QueueBulkUnholdExpensesParams; diff --git a/src/libs/API/parameters/index.ts b/src/libs/API/parameters/index.ts index 1393bb225fc8..a4d5367f3663 100644 --- a/src/libs/API/parameters/index.ts +++ b/src/libs/API/parameters/index.ts @@ -613,6 +613,8 @@ export type {default as QueueExportSearchWithTemplateParams} from './QueueExport export type {default as QueueBulkPayReportsParams} from './QueueBulkPayReportsParams'; export type {default as QueueBulkApproveReportsParams} from './QueueBulkApproveReportsParams'; export type {default as QueueBulkSubmitReportsParams} from './QueueBulkSubmitReportsParams'; +export type {default as QueueBulkHoldExpensesParams} from './QueueBulkHoldExpensesParams'; +export type {default as QueueBulkUnholdExpensesParams} from './QueueBulkUnholdExpensesParams'; export type {default as QueueBulkMarkAsExportedParams} from './QueueBulkMarkAsExportedParams'; export type {default as AssignReportToMeParams} from './AssignReportToMeParams'; export type {default as AddReportApproverParams} from './AddReportApproverParams'; diff --git a/src/libs/API/types.ts b/src/libs/API/types.ts index 3f54adfc11a8..e330170e0258 100644 --- a/src/libs/API/types.ts +++ b/src/libs/API/types.ts @@ -618,6 +618,8 @@ const WRITE_COMMANDS = { QUEUE_BULK_PAY_REPORTS: 'QueueBulkPayReports', QUEUE_BULK_APPROVE_REPORTS: 'QueueBulkApproveReports', QUEUE_BULK_SUBMIT_REPORTS: 'QueueBulkSubmitReports', + QUEUE_BULK_HOLD_EXPENSES: 'QueueBulkHoldExpenses', + QUEUE_BULK_UNHOLD_EXPENSES: 'QueueBulkUnholdExpenses', QUEUE_BULK_MARK_AS_EXPORTED: 'QueueBulkMarkAsExported', CREATE_WORKSPACE_APPROVAL: 'CreateWorkspaceApproval', UPDATE_WORKSPACE_APPROVAL: 'UpdateWorkspaceApproval', @@ -1416,6 +1418,8 @@ type WriteCommandParameters = { [WRITE_COMMANDS.QUEUE_BULK_PAY_REPORTS]: Parameters.QueueBulkPayReportsParams; [WRITE_COMMANDS.QUEUE_BULK_APPROVE_REPORTS]: Parameters.QueueBulkApproveReportsParams; [WRITE_COMMANDS.QUEUE_BULK_SUBMIT_REPORTS]: Parameters.QueueBulkSubmitReportsParams; + [WRITE_COMMANDS.QUEUE_BULK_HOLD_EXPENSES]: Parameters.QueueBulkHoldExpensesParams; + [WRITE_COMMANDS.QUEUE_BULK_UNHOLD_EXPENSES]: Parameters.QueueBulkUnholdExpensesParams; [WRITE_COMMANDS.QUEUE_BULK_MARK_AS_EXPORTED]: Parameters.QueueBulkMarkAsExportedParams; [WRITE_COMMANDS.EXPORT_REPORT_TO_CSV]: Parameters.ExportReportCSVParams; [WRITE_COMMANDS.CREATE_WORKSPACE_APPROVAL]: Parameters.CreateWorkspaceApprovalParams; diff --git a/src/libs/actions/Search.ts b/src/libs/actions/Search.ts index 87b7cc8a3c14..59d56d9a0dde 100644 --- a/src/libs/actions/Search.ts +++ b/src/libs/actions/Search.ts @@ -2188,6 +2188,18 @@ function queueBulkSubmitReports(jsonQuery: string) { write(WRITE_COMMANDS.QUEUE_BULK_SUBMIT_REPORTS, {jsonQuery, bulkActionID}, onyxData); } +/** Queues a hold, with the given reason, for every expense matching the search query that the user can hold. */ +function queueBulkHoldExpenses(jsonQuery: string, comment: string, excludedTransactionIDList: string[]) { + const {bulkActionID, onyxData} = buildBulkActionOnyxData(CONST.SEARCH.BULK_ACTION_TYPES.HOLD); + write(WRITE_COMMANDS.QUEUE_BULK_HOLD_EXPENSES, {jsonQuery, comment, bulkActionID, excludedTransactionIDList: excludedTransactionIDList.join(',')}, onyxData); +} + +/** Queues an unhold for every held expense matching the search query that the user can unhold. */ +function queueBulkUnholdExpenses(jsonQuery: string, excludedTransactionIDList: string[]) { + const {bulkActionID, onyxData} = buildBulkActionOnyxData(CONST.SEARCH.BULK_ACTION_TYPES.UNHOLD); + write(WRITE_COMMANDS.QUEUE_BULK_UNHOLD_EXPENSES, {jsonQuery, bulkActionID, excludedTransactionIDList: excludedTransactionIDList.join(',')}, onyxData); +} + /** * Queues a manual bulk "Mark as exported" for every report matching the given search query on the given connection. * The backend pages through all matches itself, so this covers reports beyond the currently loaded page(s) when @@ -2636,6 +2648,8 @@ export { queueBulkPayReports, queueBulkApproveReports, queueBulkSubmitReports, + queueBulkHoldExpenses, + queueBulkUnholdExpenses, queueBulkMarkAsExported, updateAdvancedFilters, setSearchContext, diff --git a/src/types/onyx/BulkAction.ts b/src/types/onyx/BulkAction.ts index 745fe159c54d..0a03ce94513d 100644 --- a/src/types/onyx/BulkAction.ts +++ b/src/types/onyx/BulkAction.ts @@ -6,7 +6,12 @@ import type {ValueOf} from 'type-fest'; type BulkActionState = ValueOf; /** Bulk actions from Search "Select all" that run on the backend */ -type BulkActionType = typeof CONST.SEARCH.BULK_ACTION_TYPES.APPROVE | typeof CONST.SEARCH.BULK_ACTION_TYPES.SUBMIT | typeof CONST.SEARCH.BULK_ACTION_TYPES.PAY; +type BulkActionType = + | typeof CONST.SEARCH.BULK_ACTION_TYPES.APPROVE + | typeof CONST.SEARCH.BULK_ACTION_TYPES.SUBMIT + | typeof CONST.SEARCH.BULK_ACTION_TYPES.PAY + | typeof CONST.SEARCH.BULK_ACTION_TYPES.HOLD + | typeof CONST.SEARCH.BULK_ACTION_TYPES.UNHOLD; /** Model of a bulk action started from Search "Select all" */ type BulkAction = { From 69756c5df342ef92005d2acc294041cf4f191d5b Mon Sep 17 00:00:00 2001 From: allgandaf Date: Sun, 4 Oct 2026 02:22:08 +0530 Subject: [PATCH 17/73] add bulk hold and unhold copy --- src/languages/en.ts | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/languages/en.ts b/src/languages/en.ts index bddf444b5001..ef18b07cb112 100644 --- a/src/languages/en.ts +++ b/src/languages/en.ts @@ -11696,6 +11696,8 @@ const translations = { approvingTitle: 'Approving reports...', submittingTitle: 'Submitting reports...', payingTitle: 'Marking reports as paid...', + holdingTitle: 'Holding expenses...', + unholdingTitle: 'Unholding expenses...', runningBody: "This can take a few minutes. You can wait here, or Concierge can message you when it's done.", sendFromConcierge: "Message me when it's done", conciergeTitle: 'You bet!', @@ -11704,6 +11706,8 @@ const translations = { approvedTitle: ({count, total}: {count: number; total: number}) => `Approved ${count} of ${total} ${total === 1 ? 'report' : 'reports'}`, submittedTitle: ({count, total}: {count: number; total: number}) => `Submitted ${count} of ${total} ${total === 1 ? 'report' : 'reports'}`, paidTitle: ({count, total}: {count: number; total: number}) => `Marked ${count} of ${total} ${total === 1 ? 'report' : 'reports'} as paid`, + heldTitle: ({count, total}: {count: number; total: number}) => `Held expenses on ${count} of ${total} ${total === 1 ? 'report' : 'reports'}`, + unheldTitle: ({count, total}: {count: number; total: number}) => `Unheld expenses on ${count} of ${total} ${total === 1 ? 'report' : 'reports'}`, noReportsTitle: 'No matching reports', noReportsBody: 'None of the reports you selected needed this action.', failedReportsBody: ({count}: {count: number}) => (count === 1 ? "1 report couldn't be updated." : `${count} reports couldn't be updated.`), From c8f3b5225b9e8ffbc599e6fa0bb0572d116d22ee Mon Sep 17 00:00:00 2001 From: allgandaf Date: Sun, 4 Oct 2026 02:22:09 +0530 Subject: [PATCH 18/73] translate bulk hold and unhold copy --- src/languages/de.ts | 4 ++++ src/languages/el.ts | 4 ++++ src/languages/es.ts | 4 ++++ src/languages/fr.ts | 4 ++++ src/languages/it.ts | 4 ++++ src/languages/ja.ts | 4 ++++ src/languages/nl.ts | 4 ++++ src/languages/pl.ts | 4 ++++ src/languages/pt-BR.ts | 4 ++++ src/languages/zh-hans.ts | 4 ++++ 10 files changed, 40 insertions(+) diff --git a/src/languages/de.ts b/src/languages/de.ts index 9cbb01e752dc..df5bfa75fe77 100644 --- a/src/languages/de.ts +++ b/src/languages/de.ts @@ -11712,6 +11712,8 @@ Hier ist ein *Testbeleg*, um dir zu zeigen, wie es funktioniert:`, approvingTitle: 'Berichte werden genehmigt …', submittingTitle: 'Berichte werden eingereicht …', payingTitle: 'Berichte werden als bezahlt markiert …', + holdingTitle: 'Ausgaben werden zurückgehalten …', + unholdingTitle: 'Zurückhalten von Ausgaben wird aufgehoben …', runningBody: 'Dies kann einige Minuten dauern. Sie können hier warten, oder Concierge kann Ihnen eine Nachricht senden, wenn es fertig ist.', sendFromConcierge: 'Mir eine Nachricht senden, wenn es fertig ist', conciergeTitle: 'Auf jeden Fall!', @@ -11720,6 +11722,8 @@ Hier ist ein *Testbeleg*, um dir zu zeigen, wie es funktioniert:`, approvedTitle: ({count, total}: {count: number; total: number}) => `${count} von ${total} ${total === 1 ? 'Bericht' : 'Berichte'} genehmigt`, submittedTitle: ({count, total}: {count: number; total: number}) => `${count} von ${total} ${total === 1 ? 'Bericht' : 'Berichte'} eingereicht`, paidTitle: ({count, total}: {count: number; total: number}) => `${count} von ${total} ${total === 1 ? 'Bericht' : 'Berichte'} als bezahlt markiert`, + heldTitle: ({count, total}: {count: number; total: number}) => `Ausgaben in ${count} von ${total} ${total === 1 ? 'Bericht' : 'Berichten'} zurückgehalten`, + unheldTitle: ({count, total}: {count: number; total: number}) => `Zurückhalten von Ausgaben in ${count} von ${total} ${total === 1 ? 'Bericht' : 'Berichten'} aufgehoben`, noReportsTitle: 'Keine übereinstimmenden Berichte', noReportsBody: 'Keiner der von Ihnen ausgewählten Berichte benötigte diese Aktion.', failedReportsBody: ({count}: {count: number}) => (count === 1 ? '1 Bericht konnte nicht aktualisiert werden.' : `${count} Berichte konnten nicht aktualisiert werden.`), diff --git a/src/languages/el.ts b/src/languages/el.ts index a06440c6d14c..3cae4c054bbf 100644 --- a/src/languages/el.ts +++ b/src/languages/el.ts @@ -11954,6 +11954,8 @@ ${reportName}`, approvingTitle: 'Γίνεται έγκριση αναφορών...', submittingTitle: 'Υποβολή αναφορών...', payingTitle: 'Σημειώνονται οι αναφορές ως πληρωμένες...', + holdingTitle: 'Τα έξοδα τίθενται σε αναμονή...', + unholdingTitle: 'Αφαιρείται η κράτηση των εξόδων...', runningBody: 'Αυτό μπορεί να πάρει μερικά λεπτά. Μπορείτε να περιμένετε εδώ ή ο Concierge μπορεί να σας στείλει μήνυμα όταν ολοκληρωθεί.', sendFromConcierge: 'Στείλτε μου μήνυμα όταν τελειώσει', conciergeTitle: 'Βεβαίως!', @@ -11962,6 +11964,8 @@ ${reportName}`, approvedTitle: ({count, total}: {count: number; total: number}) => `Εγκρίθηκαν ${count} από ${total} ${total === 1 ? 'αναφορά' : 'αναφορές'}`, submittedTitle: ({count, total}: {count: number; total: number}) => `Υποβλήθηκαν ${count} από ${total} ${total === 1 ? 'αναφορά' : 'αναφορές'}`, paidTitle: ({count, total}: {count: number; total: number}) => `Σημειώθηκαν ως πληρωμένες ${count} από ${total} ${total === 1 ? 'αναφορά' : 'αναφορές'}`, + heldTitle: ({count, total}: {count: number; total: number}) => `Τέθηκαν σε αναμονή έξοδα σε ${count} από ${total} ${total === 1 ? 'αναφορά' : 'αναφορές'}`, + unheldTitle: ({count, total}: {count: number; total: number}) => `Αφαιρέθηκε η κράτηση εξόδων σε ${count} από ${total} ${total === 1 ? 'αναφορά' : 'αναφορές'}`, noReportsTitle: 'Δεν υπάρχουν αντιστοιχίες αναφορών', noReportsBody: 'Καμία από τις αναφορές που επιλέξατε δεν χρειαζόταν αυτή την ενέργεια.', failedReportsBody: ({count}: {count: number}) => (count === 1 ? '1 αναφορά δεν μπόρεσε να ενημερωθεί.' : `${count} αναφορές δεν ήταν δυνατό να ενημερωθούν.`), diff --git a/src/languages/es.ts b/src/languages/es.ts index 9454d4f10dad..92b73a2f7958 100644 --- a/src/languages/es.ts +++ b/src/languages/es.ts @@ -11981,6 +11981,8 @@ ${reportName}`, approvingTitle: 'Aprobando informes...', submittingTitle: 'Enviando informes...', payingTitle: 'Marcando informes como pagados...', + holdingTitle: 'Reteniendo gastos...', + unholdingTitle: 'Desbloqueando gastos...', runningBody: 'Esto puede tardar unos minutos. Puedes esperar aquí o Concierge puede enviarte un mensaje cuando haya terminado.', sendFromConcierge: 'Envíame un mensaje cuando esté listo', conciergeTitle: '¡Por supuesto!', @@ -11989,6 +11991,8 @@ ${reportName}`, approvedTitle: ({count, total}: {count: number; total: number}) => `Aprobados ${count} de ${total} ${total === 1 ? 'informe' : 'informes'}`, submittedTitle: ({count, total}: {count: number; total: number}) => `Enviados ${count} de ${total} ${total === 1 ? 'informe' : 'informes'}`, paidTitle: ({count, total}: {count: number; total: number}) => `Marcados ${count} de ${total} ${total === 1 ? 'informe' : 'informes'} como pagados`, + heldTitle: ({count, total}: {count: number; total: number}) => `Gastos retenidos en ${count} de ${total} ${total === 1 ? 'informe' : 'informes'}`, + unheldTitle: ({count, total}: {count: number; total: number}) => `Gastos desbloqueados en ${count} de ${total} ${total === 1 ? 'informe' : 'informes'}`, noReportsTitle: 'No hay informes coincidentes', noReportsBody: 'Ninguno de los informes que seleccionaste necesitaba esta acción.', failedReportsBody: ({count}: {count: number}) => (count === 1 ? 'No se pudo actualizar 1 informe.' : `No se pudieron actualizar ${count} informes.`), diff --git a/src/languages/fr.ts b/src/languages/fr.ts index 98ffffa697c0..5690062a9ba6 100644 --- a/src/languages/fr.ts +++ b/src/languages/fr.ts @@ -11740,6 +11740,8 @@ Voici un *reçu test* pour vous montrer comment ça fonctionne :`, approvingTitle: 'Approbation des notes de frais...', submittingTitle: 'Soumission des notes de frais...', payingTitle: 'Marquage des notes de frais comme payées...', + holdingTitle: 'Mise en attente des dépenses...', + unholdingTitle: 'Suppression de la mise en attente des dépenses...', runningBody: 'Cela peut prendre quelques minutes. Vous pouvez attendre ici ou Concierge peut vous envoyer un message lorsque ce sera terminé.', sendFromConcierge: 'Envoyez-moi un message quand ce sera fait', conciergeTitle: 'Bien sûr !', @@ -11748,6 +11750,8 @@ Voici un *reçu test* pour vous montrer comment ça fonctionne :`, approvedTitle: ({count, total}: {count: number; total: number}) => `Approuvé ${count} sur ${total} ${total === 1 ? 'note de frais' : 'notes de frais'}`, submittedTitle: ({count, total}: {count: number; total: number}) => `Soumis ${count} sur ${total} ${total === 1 ? 'note de frais' : 'notes de frais'}`, paidTitle: ({count, total}: {count: number; total: number}) => `Marqué ${count} sur ${total} ${total === 1 ? 'note de frais' : 'notes de frais'} comme payé`, + heldTitle: ({count, total}: {count: number; total: number}) => `Dépenses mises en attente pour ${count} sur ${total} ${total === 1 ? 'note de frais' : 'notes de frais'}`, + unheldTitle: ({count, total}: {count: number; total: number}) => `Mise en attente supprimée pour ${count} sur ${total} ${total === 1 ? 'note de frais' : 'notes de frais'}`, noReportsTitle: 'Aucune note de frais correspondante', noReportsBody: 'Aucune des notes de frais que vous avez sélectionnées n’avait besoin de cette action.', failedReportsBody: ({count}: {count: number}) => (count === 1 ? "1 note de frais n'a pas pu être mise à jour." : `${count} notes de frais n'ont pas pu être mises à jour.`), diff --git a/src/languages/it.ts b/src/languages/it.ts index b834b82d320b..0d77e4d21a56 100644 --- a/src/languages/it.ts +++ b/src/languages/it.ts @@ -11663,6 +11663,8 @@ Ecco una *ricevuta di prova* per mostrarti come funziona:`, approvingTitle: 'Approvazione dei report in corso...', submittingTitle: 'Invio dei report in corso...', payingTitle: 'Contrassegno dei report come pagati in corso...', + holdingTitle: 'Messa in attesa delle spese in corso...', + unholdingTitle: 'Rimozione del blocco delle spese in corso...', runningBody: 'Questo può richiedere alcuni minuti. Puoi aspettare qui oppure Concierge può mandarti un messaggio quando è tutto pronto.', sendFromConcierge: 'Scrivimi quando hai finito', conciergeTitle: 'Ci puoi contare!', @@ -11671,6 +11673,8 @@ Ecco una *ricevuta di prova* per mostrarti come funziona:`, approvedTitle: ({count, total}: {count: number; total: number}) => `Approvati ${count} su ${total} report`, submittedTitle: ({count, total}: {count: number; total: number}) => `Inviati ${count} su ${total} report`, paidTitle: ({count, total}: {count: number; total: number}) => `Contrassegnati ${count} su ${total} report come pagati`, + heldTitle: ({count, total}: {count: number; total: number}) => `Spese messe in attesa in ${count} su ${total} report`, + unheldTitle: ({count, total}: {count: number; total: number}) => `Blocco rimosso dalle spese in ${count} su ${total} report`, noReportsTitle: 'Nessun report corrispondente', noReportsBody: 'Nessuno dei report che hai selezionato richiedeva questa azione.', failedReportsBody: ({count}: {count: number}) => (count === 1 ? '1 report non può essere aggiornato.' : `${count} report non hanno potuto essere aggiornati.`), diff --git a/src/languages/ja.ts b/src/languages/ja.ts index 93bf1bf777bc..9f0e9cbb077e 100644 --- a/src/languages/ja.ts +++ b/src/languages/ja.ts @@ -11494,6 +11494,8 @@ ${reportName}`, approvingTitle: 'レポートを承認しています…', submittingTitle: 'レポートを送信しています…', payingTitle: 'レポートを支払済みにしています…', + holdingTitle: '経費を保留にしています…', + unholdingTitle: '経費の保留を解除しています…', runningBody: '数分かかる場合があります。ここでお待ちいただくか、完了したときに Concierge からメッセージを受け取ることもできます。', sendFromConcierge: '完了したらメッセージを送ってください', conciergeTitle: 'もちろんです!', @@ -11502,6 +11504,8 @@ ${reportName}`, approvedTitle: ({count, total}: {count: number; total: number}) => `${total} 件中 ${count} 件のレポートを承認しました`, submittedTitle: ({count, total}: {count: number; total: number}) => `${total} 件中 ${count} 件のレポートを提出しました`, paidTitle: ({count, total}: {count: number; total: number}) => `${total} 件中 ${count} 件のレポートを支払済みにしました`, + heldTitle: ({count, total}: {count: number; total: number}) => `${total} 件中 ${count} 件のレポートの経費を保留にしました`, + unheldTitle: ({count, total}: {count: number; total: number}) => `${total} 件中 ${count} 件のレポートの経費の保留を解除しました`, noReportsTitle: '一致するレポートはありません', noReportsBody: '選択したレポートには、いずれもこの操作は必要ありませんでした。', failedReportsBody: ({count}: {count: number}) => (count === 1 ? '1件のレポートを更新できませんでした。' : `${count} 件のレポートを更新できませんでした。`), diff --git a/src/languages/nl.ts b/src/languages/nl.ts index da1a65df9c56..55f84a147e2c 100644 --- a/src/languages/nl.ts +++ b/src/languages/nl.ts @@ -11627,6 +11627,8 @@ Hier is een *proefbon* om je te laten zien hoe het werkt:`, approvingTitle: 'Rapporten goedkeuren...', submittingTitle: 'Rapporten worden ingediend...', payingTitle: 'Rapporten markeren als betaald...', + holdingTitle: 'Uitgaven vasthouden...', + unholdingTitle: 'Blokkering van uitgaven opheffen...', runningBody: 'Dit kan een paar minuten duren. Je kunt hier wachten, of Concierge kan je een bericht sturen als het klaar is.', sendFromConcierge: 'Stuur me een bericht als het klaar is', conciergeTitle: 'Zeker weten!', @@ -11635,6 +11637,8 @@ Hier is een *proefbon* om je te laten zien hoe het werkt:`, approvedTitle: ({count, total}: {count: number; total: number}) => `${count} van ${total} ${total === 1 ? 'rapport' : 'rapporten'} goedgekeurd`, submittedTitle: ({count, total}: {count: number; total: number}) => `${count} van ${total} ${total === 1 ? 'rapport' : 'rapporten'} ingediend`, paidTitle: ({count, total}: {count: number; total: number}) => `${count} van ${total} ${total === 1 ? 'rapport' : 'rapporten'} als betaald gemarkeerd`, + heldTitle: ({count, total}: {count: number; total: number}) => `Uitgaven vastgehouden in ${count} van ${total} ${total === 1 ? 'rapport' : 'rapporten'}`, + unheldTitle: ({count, total}: {count: number; total: number}) => `Blokkering van uitgaven opgeheven in ${count} van ${total} ${total === 1 ? 'rapport' : 'rapporten'}`, noReportsTitle: 'Geen overeenkomende rapporten', noReportsBody: 'Geen van de rapporten die je hebt geselecteerd had deze actie nodig.', failedReportsBody: ({count}: {count: number}) => (count === 1 ? '1 rapport kon niet worden bijgewerkt.' : `${count} rapporten konden niet worden bijgewerkt.`), diff --git a/src/languages/pl.ts b/src/languages/pl.ts index b6fa12a86aa5..c3b22b6831f6 100644 --- a/src/languages/pl.ts +++ b/src/languages/pl.ts @@ -11642,6 +11642,8 @@ Oto *paragon testowy*, żeby pokazać Ci, jak to działa:`, approvingTitle: 'Zatwierdzanie raportów...', submittingTitle: 'Wysyłanie raportów...', payingTitle: 'Oznaczanie raportów jako opłacone...', + holdingTitle: 'Wstrzymywanie wydatków...', + unholdingTitle: 'Usuwanie blokady wydatków...', runningBody: 'To może potrwać kilka minut. Możesz poczekać tutaj albo Concierge napisze do ciebie, kiedy będzie gotowe.', sendFromConcierge: 'Napisz do mnie, kiedy będzie gotowe', conciergeTitle: 'No jasne!', @@ -11650,6 +11652,8 @@ Oto *paragon testowy*, żeby pokazać Ci, jak to działa:`, approvedTitle: ({count, total}: {count: number; total: number}) => `Zatwierdzono ${count} z ${total} ${total === 1 ? 'raportu' : 'raportów'}`, submittedTitle: ({count, total}: {count: number; total: number}) => `Przesłano ${count} z ${total} ${total === 1 ? 'raportu' : 'raportów'}`, paidTitle: ({count, total}: {count: number; total: number}) => `Oznaczono ${count} z ${total} ${total === 1 ? 'raportu' : 'raportów'} jako opłacone`, + heldTitle: ({count, total}: {count: number; total: number}) => `Wstrzymano wydatki w ${count} z ${total} ${total === 1 ? 'raportu' : 'raportów'}`, + unheldTitle: ({count, total}: {count: number; total: number}) => `Usunięto blokadę wydatków w ${count} z ${total} ${total === 1 ? 'raportu' : 'raportów'}`, noReportsTitle: 'Brak pasujących raportów', noReportsBody: 'Żaden z wybranych raportów nie wymagał tej akcji.', failedReportsBody: ({count}: {count: number}) => (count === 1 ? 'Nie udało się zaktualizować 1 raportu.' : `Nie udało się zaktualizować ${count} raportów.`), diff --git a/src/languages/pt-BR.ts b/src/languages/pt-BR.ts index 772996160f82..f46a7b28d0ba 100644 --- a/src/languages/pt-BR.ts +++ b/src/languages/pt-BR.ts @@ -11619,6 +11619,8 @@ Aqui está um *comprovante de teste* para mostrar como funciona:`, approvingTitle: 'Aprovando relatórios...', submittingTitle: 'Enviando relatórios...', payingTitle: 'Marcando relatórios como pagos...', + holdingTitle: 'Retendo despesas...', + unholdingTitle: 'Removendo bloqueio das despesas...', runningBody: 'Isso pode levar alguns minutos. Você pode esperar aqui ou o Concierge pode te mandar uma mensagem quando terminar.', sendFromConcierge: 'Me avise quando terminar', conciergeTitle: 'Pode apostar!', @@ -11627,6 +11629,8 @@ Aqui está um *comprovante de teste* para mostrar como funciona:`, approvedTitle: ({count, total}: {count: number; total: number}) => `Aprovado(s) ${count} de ${total} ${total === 1 ? 'relatório' : 'relatórios'}`, submittedTitle: ({count, total}: {count: number; total: number}) => `Enviado(s) ${count} de ${total} ${total === 1 ? 'relatório' : 'relatórios'}`, paidTitle: ({count, total}: {count: number; total: number}) => `Marcado(s) ${count} de ${total} ${total === 1 ? 'relatório' : 'relatórios'} como pago(s)`, + heldTitle: ({count, total}: {count: number; total: number}) => `Despesas retidas em ${count} de ${total} ${total === 1 ? 'relatório' : 'relatórios'}`, + unheldTitle: ({count, total}: {count: number; total: number}) => `Bloqueio removido das despesas em ${count} de ${total} ${total === 1 ? 'relatório' : 'relatórios'}`, noReportsTitle: 'Nenhum relatório correspondente', noReportsBody: 'Nenhum dos relatórios que você selecionou precisava dessa ação.', failedReportsBody: ({count}: {count: number}) => (count === 1 ? '1 relatório não pôde ser atualizado.' : `${count} relatórios não puderam ser atualizados.`), diff --git a/src/languages/zh-hans.ts b/src/languages/zh-hans.ts index 62b68c97f4b3..c5af00894faf 100644 --- a/src/languages/zh-hans.ts +++ b/src/languages/zh-hans.ts @@ -11203,6 +11203,8 @@ ${reportName}`, approvingTitle: '正在批准报表…', submittingTitle: '正在提交报表…', payingTitle: '正在将报表标记为已支付…', + holdingTitle: '正在暂挂报销费用…', + unholdingTitle: '正在解除报销费用的保留…', runningBody: '这可能需要几分钟。你可以在这里等待,或者等完成后由 Concierge 给你发送消息。', sendFromConcierge: '完成后给我发消息', conciergeTitle: '当然!', @@ -11211,6 +11213,8 @@ ${reportName}`, approvedTitle: ({count, total}: {count: number; total: number}) => `已批准 ${total} 份报表中的 ${count} 份`, submittedTitle: ({count, total}: {count: number; total: number}) => `已提交 ${total} 份报表中的 ${count} 份`, paidTitle: ({count, total}: {count: number; total: number}) => `已将 ${total} 份报表中的 ${count} 份标记为已支付`, + heldTitle: ({count, total}: {count: number; total: number}) => `已暂挂 ${total} 份报表中 ${count} 份的报销费用`, + unheldTitle: ({count, total}: {count: number; total: number}) => `已解除 ${total} 份报表中 ${count} 份的报销费用保留`, noReportsTitle: '没有匹配的报表', noReportsBody: '您选择的报表都不需要执行此操作。', failedReportsBody: ({count}: {count: number}) => (count === 1 ? '1 份报表无法更新。' : `${count} 份报表无法更新。`), From 3b7c602b8159bee496f93c74703f90a8a1a52340 Mon Sep 17 00:00:00 2001 From: allgandaf Date: Sun, 4 Oct 2026 02:22:10 +0530 Subject: [PATCH 19/73] show hold and unhold in the bulk action modal --- cspell.json | 1 + src/components/BulkActionStatusModal.tsx | 35 ++++++++++++++---------- 2 files changed, 21 insertions(+), 15 deletions(-) diff --git a/cspell.json b/cspell.json index ae144d5cb8e7..4fde843bcc06 100644 --- a/cspell.json +++ b/cspell.json @@ -1088,6 +1088,7 @@ "unflushed", "unheld", "unhold", + "unholding", "unimodules", "uninstallations", "unminified", diff --git a/src/components/BulkActionStatusModal.tsx b/src/components/BulkActionStatusModal.tsx index 74e054e850cf..2dc6ab51dc8c 100644 --- a/src/components/BulkActionStatusModal.tsx +++ b/src/components/BulkActionStatusModal.tsx @@ -13,8 +13,10 @@ import {sendBulkActionSummaryFromConcierge} from '@userActions/BulkAction'; import {close} from '@userActions/Modal'; import CONST from '@src/CONST'; +import type {TranslationPaths} from '@src/languages/types'; import ONYXKEYS from '@src/ONYXKEYS'; import ROUTES from '@src/ROUTES'; +import type {BulkActionType} from '@src/types/onyx/BulkAction'; import React from 'react'; import {View} from 'react-native'; @@ -24,6 +26,22 @@ import Button from './Button'; import Modal from './Modal'; import Text from './Text'; +const RUNNING_TITLES = { + [CONST.SEARCH.BULK_ACTION_TYPES.APPROVE]: 'bulkAction.approvingTitle', + [CONST.SEARCH.BULK_ACTION_TYPES.SUBMIT]: 'bulkAction.submittingTitle', + [CONST.SEARCH.BULK_ACTION_TYPES.PAY]: 'bulkAction.payingTitle', + [CONST.SEARCH.BULK_ACTION_TYPES.HOLD]: 'bulkAction.holdingTitle', + [CONST.SEARCH.BULK_ACTION_TYPES.UNHOLD]: 'bulkAction.unholdingTitle', +} as const satisfies Record; + +const DONE_TITLES = { + [CONST.SEARCH.BULK_ACTION_TYPES.APPROVE]: 'bulkAction.approvedTitle', + [CONST.SEARCH.BULK_ACTION_TYPES.SUBMIT]: 'bulkAction.submittedTitle', + [CONST.SEARCH.BULK_ACTION_TYPES.PAY]: 'bulkAction.paidTitle', + [CONST.SEARCH.BULK_ACTION_TYPES.HOLD]: 'bulkAction.heldTitle', + [CONST.SEARCH.BULK_ACTION_TYPES.UNHOLD]: 'bulkAction.unheldTitle', +} as const satisfies Record; + type BulkActionStatusModalProps = { /** The bulk action ID to subscribe to */ bulkActionID: string; @@ -68,16 +86,10 @@ function BulkActionStatusModal({bulkActionID, isVisible, onClose}: BulkActionSta const renderContent = () => { if (isRunning) { - let runningTitle = translate('bulkAction.payingTitle'); - if (action === CONST.SEARCH.BULK_ACTION_TYPES.APPROVE) { - runningTitle = translate('bulkAction.approvingTitle'); - } else if (action === CONST.SEARCH.BULK_ACTION_TYPES.SUBMIT) { - runningTitle = translate('bulkAction.submittingTitle'); - } return ( <> - {runningTitle} + {translate(RUNNING_TITLES[action ?? CONST.SEARCH.BULK_ACTION_TYPES.PAY])} {translate('bulkAction.runningBody')} @@ -115,14 +127,7 @@ function BulkActionStatusModal({bulkActionID, isVisible, onClose}: BulkActionSta if (state === CONST.BULK_ACTION.STATE.DONE) { const count = total - failedReportIDs.length; - let doneTitle = translate('bulkAction.paidTitle', {count, total}); - if (total === 0) { - doneTitle = translate('bulkAction.noReportsTitle'); - } else if (action === CONST.SEARCH.BULK_ACTION_TYPES.APPROVE) { - doneTitle = translate('bulkAction.approvedTitle', {count, total}); - } else if (action === CONST.SEARCH.BULK_ACTION_TYPES.SUBMIT) { - doneTitle = translate('bulkAction.submittedTitle', {count, total}); - } + const doneTitle = total === 0 ? translate('bulkAction.noReportsTitle') : translate(DONE_TITLES[action ?? CONST.SEARCH.BULK_ACTION_TYPES.PAY], {count, total}); return ( <> {doneTitle} From 4f36f87812a77bdd4671c547414b5fb6a4813262 Mon Sep 17 00:00:00 2001 From: allgandaf Date: Sun, 4 Oct 2026 02:22:10 +0530 Subject: [PATCH 20/73] offer hold and unhold under select all --- src/hooks/useSearchBulkActions.ts | 172 ++++++++++++++++++------------ 1 file changed, 105 insertions(+), 67 deletions(-) diff --git a/src/hooks/useSearchBulkActions.ts b/src/hooks/useSearchBulkActions.ts index a6cf420f93c3..b962a04dd27b 100644 --- a/src/hooks/useSearchBulkActions.ts +++ b/src/hooks/useSearchBulkActions.ts @@ -38,6 +38,7 @@ import { queueBulkMarkAsExported, queueBulkPayReports, queueBulkSubmitReports, + queueBulkUnholdExpenses, queueExportSearchItemsToCSV, queueExportSearchWithTemplate, resolveSearchPayPaymentMethod, @@ -395,6 +396,21 @@ function getAllMatchingReportQuery(queryJSON: SearchQueryJSON, excludedTransacti return buildSearchQueryJSON(buildSearchQueryString({...queryJSON, flatFilters})); } +/** Builds the query and the deselected expenses to send to the backend for a "Select all" bulk action on expenses. */ +function getAllMatchingExpenseActionQuery( + queryJSON: SearchQueryJSON, + excludedTransactions: SelectedTransactions, + searchData: SearchResultDataType | undefined, +): {jsonQuery: string; excludedTransactionIDList: string[]} | undefined { + if (queryJSON.type === CONST.SEARCH.DATA_TYPES.EXPENSE_REPORT) { + const reportQuery = getAllMatchingReportQuery(queryJSON, excludedTransactions); + return reportQuery ? {jsonQuery: serializeQueryJSONForBackend(reportQuery), excludedTransactionIDList: []} : undefined; + } + + const expenseQuery = getAllMatchingExportQueryAndExclusions(queryJSON, excludedTransactions, searchData); + return expenseQuery ? {jsonQuery: serializeQueryJSONForBackend(expenseQuery.queryJSON), excludedTransactionIDList: expenseQuery.excludedTransactionIDList} : undefined; +} + const MERCHANT_GROUP_EXACT_MATCH_FILTER_KEYS = new Set([CONST.SEARCH.SYNTAX_FILTER_KEYS.MERCHANT]); function getGroupExportExactMatchFilterKeys(groupBy: SearchQueryJSON['groupBy']): ReadonlySet | undefined { @@ -2500,6 +2516,85 @@ function useSearchBulkActions({queryJSON}: UseSearchBulkActionsParams) { }, }; + const holdOption: DropdownOption = { + icon: expensifyIcons.Stopwatch, + text: translate('search.bulkActions.hold'), + value: CONST.SEARCH.BULK_ACTION_TYPES.HOLD, + shouldCloseModalOnSelect: true, + onSelected: () => { + if (isOffline) { + setIsOfflineModalVisible(true); + return; + } + + if (isDelegateAccessRestricted) { + showDelegateNoAccessModal(); + return; + } + + const shouldShowHoldEducationalModal = areAllTransactionsFromSubmitter || areAllTransactionsFromDMReports; + const isDismissed = shouldShowHoldEducationalModal ? dismissedHoldUseExplanation : dismissedRejectUseExplanation; + + if (isDismissed) { + navigateToSearchRHP(ROUTES.TRANSACTION_HOLD_REASON_SEARCH, ROUTES.TRANSACTION_HOLD_REASON_RHP); + } else if (shouldShowHoldEducationalModal) { + setIsHoldEducationalModalVisible(true); + } else { + setRejectModalAction(CONST.REPORT.TRANSACTION_SECONDARY_ACTIONS.HOLD); + } + }, + }; + + const unholdOption: DropdownOption = { + icon: expensifyIcons.Stopwatch, + text: translate('search.bulkActions.unhold'), + value: CONST.SEARCH.BULK_ACTION_TYPES.UNHOLD, + shouldCloseModalOnSelect: true, + onSelected: () => { + if (isOffline) { + setIsOfflineModalVisible(true); + return; + } + + if (isDelegateAccessRestricted) { + showDelegateNoAccessModal(); + return; + } + + if (areAllMatchingItemsSelected) { + const allMatchingQuery = queryJSON ? getAllMatchingExpenseActionQuery(queryJSON, excludedTransactions, currentSearchResults?.data) : undefined; + if (!allMatchingQuery) { + Log.info('[BulkUnhold] Dropping bulk unhold: an excluded row could not be resolved'); + return; + } + queueBulkUnholdExpenses(allMatchingQuery.jsonQuery, allMatchingQuery.excludedTransactionIDList); + clearSelectedTransactions(); + return; + } + + for (const transactionID of selectedTransactionsKeys) { + if (!selectedTransactions[transactionID].reportAction?.childReportID) { + Log.info('[BulkUnhold] Skipping transaction: report action has no childReportID', false, {transactionID}); + continue; + } + const transactionViolations = allTransactionViolations?.[`${ONYXKEYS.COLLECTION.TRANSACTION_VIOLATIONS}${transactionID}`]; + unholdRequest( + transactionID, + selectedTransactions[transactionID].reportAction?.childReportID, + policies?.[`${ONYXKEYS.COLLECTION.POLICY}${selectedTransactions[transactionID].policyID}`], + isOffline, + currentUserLogin ?? '', + accountID, + transactionViolations, + isTrackIntentUser, + delegateAccountID, + rules, + ); + } + clearSelectedTransactions(); + }, + }; + const isExpenseReportSearch = isExpenseReportType || searchResults?.search.type === CONST.SEARCH.DATA_TYPES.EXPENSE_REPORT; const downloadPDFOption: DropdownOption = { @@ -2602,6 +2697,13 @@ function useSearchBulkActions({queryJSON}: UseSearchBulkActionsParams) { if (shouldShowPayOption) { allMatchingOptions.push(payButtonOption); } + // The backend only acts on the matching expenses the user can hold or unhold, so one loaded item is enough to offer it. + if (!isOffline && selectedTransactionsKeys.some((id) => selectedTransactions[id].canHold)) { + allMatchingOptions.push(holdOption); + } + if (!isOffline && selectedTransactionsKeys.some((id) => selectedTransactions[id].canUnhold)) { + allMatchingOptions.push(unholdOption); + } allMatchingOptions.push(exportButtonOption); if (isExpenseReportSearch) { allMatchingOptions.push(downloadPDFOption); @@ -2996,77 +3098,13 @@ function useSearchBulkActions({queryJSON}: UseSearchBulkActionsParams) { const shouldShowHoldOption = !isOffline && selectedTransactionsKeys.every((id) => selectedTransactions[id].canHold); if (shouldShowHoldOption) { - options.push({ - icon: expensifyIcons.Stopwatch, - text: translate('search.bulkActions.hold'), - value: CONST.SEARCH.BULK_ACTION_TYPES.HOLD, - shouldCloseModalOnSelect: true, - onSelected: () => { - if (isOffline) { - setIsOfflineModalVisible(true); - return; - } - - if (isDelegateAccessRestricted) { - showDelegateNoAccessModal(); - return; - } - - const shouldShowHoldEducationalModal = areAllTransactionsFromSubmitter || areAllTransactionsFromDMReports; - const isDismissed = shouldShowHoldEducationalModal ? dismissedHoldUseExplanation : dismissedRejectUseExplanation; - - if (isDismissed) { - navigateToSearchRHP(ROUTES.TRANSACTION_HOLD_REASON_SEARCH, ROUTES.TRANSACTION_HOLD_REASON_RHP); - } else if (shouldShowHoldEducationalModal) { - setIsHoldEducationalModalVisible(true); - } else { - setRejectModalAction(CONST.REPORT.TRANSACTION_SECONDARY_ACTIONS.HOLD); - } - }, - }); + options.push(holdOption); } const shouldShowUnholdOption = !isOffline && selectedTransactionsKeys.every((id) => selectedTransactions[id].canUnhold); if (shouldShowUnholdOption) { - options.push({ - icon: expensifyIcons.Stopwatch, - text: translate('search.bulkActions.unhold'), - value: CONST.SEARCH.BULK_ACTION_TYPES.UNHOLD, - shouldCloseModalOnSelect: true, - onSelected: () => { - if (isOffline) { - setIsOfflineModalVisible(true); - return; - } - - if (isDelegateAccessRestricted) { - showDelegateNoAccessModal(); - return; - } - - for (const transactionID of selectedTransactionsKeys) { - if (!selectedTransactions[transactionID].reportAction?.childReportID) { - Log.info('[BulkUnhold] Skipping transaction: report action has no childReportID', false, {transactionID}); - continue; - } - const transactionViolations = allTransactionViolations?.[`${ONYXKEYS.COLLECTION.TRANSACTION_VIOLATIONS}${transactionID}`]; - unholdRequest( - transactionID, - selectedTransactions[transactionID].reportAction?.childReportID, - policies?.[`${ONYXKEYS.COLLECTION.POLICY}${selectedTransactions[transactionID].policyID}`], - isOffline, - currentUserLogin ?? '', - accountID, - transactionViolations, - isTrackIntentUser, - delegateAccountID, - rules, - ); - } - clearSelectedTransactions(); - }, - }); + options.push(unholdOption); } if (selectedTransactionsKeys.length < 3 && searchResults?.search.type !== CONST.SEARCH.DATA_TYPES.EXPENSE_REPORT && searchResults?.data) { @@ -3388,5 +3426,5 @@ function useSearchBulkActions({queryJSON}: UseSearchBulkActionsParams) { } export default useSearchBulkActions; -export {getFullyDeletedGroupKeysByTransactionID, getGroupKeysSelectedViaGroup, getSelectedGroupKeys, shouldShowBulkDuplicateOption}; +export {getAllMatchingExpenseActionQuery, getFullyDeletedGroupKeysByTransactionID, getGroupKeysSelectedViaGroup, getSelectedGroupKeys, shouldShowBulkDuplicateOption}; export type {SearchHeaderOptionValue}; From 304a4a5858959c9421ad13582084757a6211eedf Mon Sep 17 00:00:00 2001 From: allgandaf Date: Sun, 4 Oct 2026 02:22:11 +0530 Subject: [PATCH 21/73] queue a bulk hold from the hold reason page --- src/pages/Search/SearchHoldReasonPage.tsx | 24 ++++++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) diff --git a/src/pages/Search/SearchHoldReasonPage.tsx b/src/pages/Search/SearchHoldReasonPage.tsx index 30702e2c52a9..302b20d209da 100644 --- a/src/pages/Search/SearchHoldReasonPage.tsx +++ b/src/pages/Search/SearchHoldReasonPage.tsx @@ -1,6 +1,6 @@ import {useDelegateNoAccessActions, useDelegateNoAccessState} from '@components/DelegateNoAccessModalProvider'; import type {FormInputErrors, FormOnyxValues} from '@components/Form/types'; -import {useSearchSelectionActions, useSearchSelectionContext} from '@components/Search/SearchContext'; +import {useSearchQueryContext, useSearchResultsContext, useSearchSelectionActions, useSearchSelectionContext} from '@components/Search/SearchContext'; import useAncestors from '@hooks/useAncestors'; import useCurrentUserPersonalDetails from '@hooks/useCurrentUserPersonalDetails'; @@ -9,10 +9,13 @@ import useDynamicBackPath from '@hooks/useDynamicBackPath'; import useLocalize from '@hooks/useLocalize'; import useNetwork from '@hooks/useNetwork'; import useOnyx from '@hooks/useOnyx'; +import {getAllMatchingExpenseActionQuery} from '@hooks/useSearchBulkActions'; import useTransactionsByID from '@hooks/useTransactionsByID'; import {clearErrorFields, clearErrors} from '@libs/actions/FormActions'; import {putOnHold, putTransactionsOnHold} from '@libs/actions/IOU/Hold'; +import {queueBulkHoldExpenses} from '@libs/actions/Search'; +import Log from '@libs/Log'; import Navigation from '@libs/Navigation/Navigation'; import type {PlatformStackScreenProps} from '@libs/Navigation/PlatformStackNavigation/types'; import {getFieldRequiredErrors} from '@libs/ValidationUtils'; @@ -40,7 +43,9 @@ function SearchHoldReasonPage({route}: SearchHoldReasonPageProps) { const {reportID} = route.params ?? {}; const dynamicBackPath = useDynamicBackPath(DYNAMIC_ROUTES.HOLD_TRANSACTIONS.path); const backTo = isBulkHold ? dynamicBackPath : route.params.backTo; - const {selectedTransactionIDs, selectedTransactions} = useSearchSelectionContext(); + const {selectedTransactionIDs, selectedTransactions, excludedTransactions, areAllMatchingItemsSelected} = useSearchSelectionContext(); + const {currentSearchQueryJSON} = useSearchQueryContext(); + const {currentSearchResults} = useSearchResultsContext(); const {clearSelectedTransactions} = useSearchSelectionActions(); const {accountID: currentUserAccountID, login: currentUserLogin} = useCurrentUserPersonalDetails(); const delegateAccountID = useDelegateAccountID(); @@ -67,7 +72,16 @@ function SearchHoldReasonPage({route}: SearchHoldReasonPageProps) { showDelegateNoAccessModal(); return; } - if (isBulkHold) { + if (!isBulkHold && areAllMatchingItemsSelected) { + // "Select all" can cover more expenses than are loaded, so hand the search query to the backend to hold every match. + const allMatchingQuery = currentSearchQueryJSON ? getAllMatchingExpenseActionQuery(currentSearchQueryJSON, excludedTransactions, currentSearchResults?.data) : undefined; + if (!allMatchingQuery) { + Log.info('[BulkHold] Dropping bulk hold: an excluded row could not be resolved'); + return; + } + queueBulkHoldExpenses(allMatchingQuery.jsonQuery, comment, allMatchingQuery.excludedTransactionIDList); + clearSelectedTransactions(); + } else if (isBulkHold) { putTransactionsOnHold({ transactionsID: selectedTransactionIDs, comment, @@ -127,6 +141,10 @@ function SearchHoldReasonPage({route}: SearchHoldReasonPageProps) { ancestors, clearSelectedTransactions, selectedTransactions, + areAllMatchingItemsSelected, + currentSearchQueryJSON, + excludedTransactions, + currentSearchResults?.data, ], ); From 5ca3eee425156cbb56799c2b8e2ef7f580e2614c Mon Sep 17 00:00:00 2001 From: allgandaf Date: Sun, 4 Oct 2026 02:22:11 +0530 Subject: [PATCH 22/73] test hold and unhold under select all --- tests/unit/hooks/useSearchBulkActionsTest.ts | 79 ++++++++++++++++++++ 1 file changed, 79 insertions(+) diff --git a/tests/unit/hooks/useSearchBulkActionsTest.ts b/tests/unit/hooks/useSearchBulkActionsTest.ts index 8fe4f7c23096..402ca4bfa22a 100644 --- a/tests/unit/hooks/useSearchBulkActionsTest.ts +++ b/tests/unit/hooks/useSearchBulkActionsTest.ts @@ -10,6 +10,7 @@ import { getExportTemplates, queueBulkApproveReports, queueBulkSubmitReports, + queueBulkUnholdExpenses, queueExportSearchItemsToCSV, queueExportSearchWithTemplate, submitMoneyRequestOnSearch, @@ -35,6 +36,7 @@ jest.mock('@libs/actions/Search', () => ({ queueExportSearchWithTemplate: jest.fn(() => 'mock-template-export-id'), queueBulkApproveReports: jest.fn(), queueBulkSubmitReports: jest.fn(), + queueBulkUnholdExpenses: jest.fn(), getSearchApproveOnyxData: jest.fn(() => ({})), getSearchPayOnyxData: jest.fn(() => ({})), bulkDeleteReports: jest.fn(), @@ -759,3 +761,80 @@ describe('useSearchBulkActions - Submit under Select all', () => { expect(result.current.headerButtonsOptions.some((option) => option.value === CONST.SEARCH.BULK_ACTION_TYPES.SUBMIT)).toBe(false); }); }); + +describe('useSearchBulkActions - Hold and Unhold under Select all', () => { + beforeAll(() => { + Onyx.init({keys: ONYXKEYS}); + }); + + beforeEach(async () => { + jest.clearAllMocks(); + mockIsOffline = false; + mockAreAllMatchingItemsSelected = true; + await Onyx.clear(); + mockSelectedTransactions = {}; + mockExcludedTransactions = {}; + mockSelectedReports = []; + mockCurrentSearchResults = undefined; + mockGetExportTemplates.mockReturnValue({customTemplates: [], defaultTemplates: []}); + + await Onyx.merge(ONYXKEYS.SESSION, {accountID: CURRENT_USER_ACCOUNT_ID, email: 'test@example.com'}); + }); + + afterEach(async () => { + await Onyx.clear(); + }); + + it('offers Hold when one loaded expense can be held, even if another cannot', async () => { + // Given "Select all" with one holdable expense and one that is already held, which hides Hold for a normal selection + mockSelectedTransactions = {tx1: makeSelectedTransaction({canHold: true}), tx2: makeSelectedTransaction({canHold: false, canUnhold: true})}; + + // When the bulk actions are built + const {result} = renderHook(() => useSearchBulkActions({queryJSON: baseQueryJSON}), {wrapper: OnyxListItemProvider}); + + // Then both Hold and Unhold are offered, because the backend only acts on the expenses the user can act on + await waitFor(() => { + expect(result.current.headerButtonsOptions.some((option) => option.value === CONST.SEARCH.BULK_ACTION_TYPES.HOLD)).toBe(true); + }); + expect(result.current.headerButtonsOptions.some((option) => option.value === CONST.SEARCH.BULK_ACTION_TYPES.UNHOLD)).toBe(true); + }); + + it('queues a server-side bulk unhold without the expenses the user deselected', async () => { + // Given "Select all" on an expenses search with a held expense loaded, and one expense deselected afterwards + mockSelectedTransactions = {tx1: makeSelectedTransaction({canUnhold: true})}; + mockExcludedTransactions = {tx2: makeSelectedTransaction()}; + + const {result} = renderHook(() => useSearchBulkActions({queryJSON: baseQueryJSON}), {wrapper: OnyxListItemProvider}); + + await waitFor(() => { + expect(result.current.headerButtonsOptions.some((option) => option.value === CONST.SEARCH.BULK_ACTION_TYPES.UNHOLD)).toBe(true); + }); + + // When the user selects Unhold + const unholdOption = result.current.headerButtonsOptions.find((option) => option.value === CONST.SEARCH.BULK_ACTION_TYPES.UNHOLD); + await act(async () => { + await unholdOption?.onSelected?.(); + }); + + // Then the search is handed to the backend with the deselected expense listed, so it stays held + expect(queueBulkUnholdExpenses).toHaveBeenCalledTimes(1); + expect(queueBulkUnholdExpenses).toHaveBeenCalledWith(expect.any(String), ['tx2']); + expect(mockClearSelectedTransactions).toHaveBeenCalled(); + }); + + it('hides Hold and Unhold when no loaded expense can be held or unheld', async () => { + // Given nothing on the loaded page can be held or unheld + mockSelectedTransactions = {tx1: makeSelectedTransaction()}; + + // When the bulk actions are built + const {result} = renderHook(() => useSearchBulkActions({queryJSON: baseQueryJSON}), {wrapper: OnyxListItemProvider}); + + await waitFor(() => { + expect(result.current.headerButtonsOptions.length).toBeGreaterThan(0); + }); + + // Then neither is offered + expect(result.current.headerButtonsOptions.some((option) => option.value === CONST.SEARCH.BULK_ACTION_TYPES.HOLD)).toBe(false); + expect(result.current.headerButtonsOptions.some((option) => option.value === CONST.SEARCH.BULK_ACTION_TYPES.UNHOLD)).toBe(false); + }); +}); From 7e982dd1b0391f55474edeb411174ca146f95371 Mon Sep 17 00:00:00 2001 From: allgandaf Date: Sun, 4 Oct 2026 02:22:12 +0530 Subject: [PATCH 23/73] test the hold reason page under select all --- tests/unit/SearchHoldReasonPageTest.tsx | 113 ++++++++++++++++++++++++ 1 file changed, 113 insertions(+) create mode 100644 tests/unit/SearchHoldReasonPageTest.tsx diff --git a/tests/unit/SearchHoldReasonPageTest.tsx b/tests/unit/SearchHoldReasonPageTest.tsx new file mode 100644 index 000000000000..4495145ab674 --- /dev/null +++ b/tests/unit/SearchHoldReasonPageTest.tsx @@ -0,0 +1,113 @@ +import {render} from '@testing-library/react-native'; + +import type {SearchQueryJSON} from '@components/Search/types'; + +import {putOnHold} from '@libs/actions/IOU/Hold'; +import {queueBulkHoldExpenses} from '@libs/actions/Search'; + +import SearchHoldReasonPage from '@pages/Search/SearchHoldReasonPage'; + +import CONST from '@src/CONST'; +import ONYXKEYS from '@src/ONYXKEYS'; +import SCREENS from '@src/SCREENS'; + +import React from 'react'; +import Onyx from 'react-native-onyx'; + +import waitForBatchedUpdatesWithAct from '../utils/waitForBatchedUpdatesWithAct'; + +const mockQueryJSON: SearchQueryJSON = { + inputQuery: 'type:expense status:all', + hash: 12345, + recentSearchHash: 12345, + similarSearchHash: 12345, + flatFilters: [], + type: CONST.SEARCH.DATA_TYPES.EXPENSE, + sortBy: CONST.SEARCH.TABLE_COLUMNS.DATE, + sortOrder: CONST.SEARCH.SORT_ORDER.DESC, + view: CONST.SEARCH.VIEW.TABLE, + filters: {operator: CONST.SEARCH.SYNTAX_OPERATORS.AND, left: 'type', right: 'expense'}, +}; +const mockClearSelectedTransactions = jest.fn(); +let mockAreAllMatchingItemsSelected = false; +let mockSubmitHoldReason: ((values: {comment: string}) => void) | undefined; + +jest.mock('@pages/iou/HoldReasonFormView', () => { + function MockHoldReasonFormView({onSubmit}: {onSubmit: (values: {comment: string}) => void}) { + mockSubmitHoldReason = onSubmit; + return null; + } + return MockHoldReasonFormView; +}); +jest.mock('@components/Search/SearchContext', () => ({ + useSearchQueryContext: () => ({currentSearchQueryJSON: mockQueryJSON}), + useSearchResultsContext: () => ({currentSearchResults: undefined}), + useSearchSelectionActions: () => ({clearSelectedTransactions: mockClearSelectedTransactions}), + useSearchSelectionContext: () => ({ + selectedTransactionIDs: [], + selectedTransactions: {tx1: {reportID: 'report1'}}, + excludedTransactions: {tx2: {reportID: 'report1'}}, + areAllMatchingItemsSelected: mockAreAllMatchingItemsSelected, + }), +})); +jest.mock('@libs/actions/Search', () => ({ + queueBulkHoldExpenses: jest.fn(), +})); +jest.mock('@libs/actions/IOU/Hold', () => ({ + putOnHold: jest.fn(), + putTransactionsOnHold: jest.fn(), +})); +jest.mock('@libs/Navigation/Navigation', () => ({ + goBack: jest.fn(), + isNavigationReady: jest.fn(() => Promise.resolve()), +})); +jest.mock('@hooks/useDynamicBackPath', () => ({ + __esModule: true, + default: () => '', +})); + +function renderPage(areAllMatchingItemsSelected: boolean) { + mockAreAllMatchingItemsSelected = areAllMatchingItemsSelected; + const route = {name: SCREENS.SEARCH.TRANSACTION_HOLD_REASON_RHP, key: 'hold', params: {backTo: ''}}; + // @ts-expect-error the page only reads route.name and route.params + render(); +} + +describe('SearchHoldReasonPage', () => { + beforeAll(() => { + Onyx.init({keys: ONYXKEYS}); + }); + + beforeEach(async () => { + jest.clearAllMocks(); + mockSubmitHoldReason = undefined; + await Onyx.clear(); + }); + + it('hands the search to the backend when Select all is checked', async () => { + // Given the hold reason page opened with "Select all" checked and one expense deselected + renderPage(true); + await waitForBatchedUpdatesWithAct(); + + // When the user submits a reason + mockSubmitHoldReason?.({comment: 'needs a receipt'}); + + // Then every matching expense is held by the backend, except the deselected one, and nothing is held per expense + expect(queueBulkHoldExpenses).toHaveBeenCalledWith(expect.any(String), 'needs a receipt', ['tx2']); + expect(putOnHold).not.toHaveBeenCalled(); + expect(mockClearSelectedTransactions).toHaveBeenCalled(); + }); + + it('holds each selected expense when Select all is not checked', async () => { + // Given the hold reason page opened with a manual selection + renderPage(false); + await waitForBatchedUpdatesWithAct(); + + // When the user submits a reason + mockSubmitHoldReason?.({comment: 'needs a receipt'}); + + // Then the selected expense is held directly and nothing is queued on the backend + expect(putOnHold).toHaveBeenCalledTimes(1); + expect(queueBulkHoldExpenses).not.toHaveBeenCalled(); + }); +}); From db705a3281431c6c7bfe5fa5056b5161e17d02e4 Mon Sep 17 00:00:00 2001 From: allgandaf Date: Sun, 4 Oct 2026 02:22:13 +0530 Subject: [PATCH 24/73] test bulk hold in the status modal --- tests/unit/BulkActionStatusManagerTest.tsx | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/tests/unit/BulkActionStatusManagerTest.tsx b/tests/unit/BulkActionStatusManagerTest.tsx index ac43aa4bdc25..0b89eaf648e1 100644 --- a/tests/unit/BulkActionStatusManagerTest.tsx +++ b/tests/unit/BulkActionStatusManagerTest.tsx @@ -122,6 +122,22 @@ describe('BulkActionStatusManager', () => { expect(mockClearBulkAction).toHaveBeenCalledWith(BULK_ACTION_ID, expect.objectContaining({state: CONST.BULK_ACTION.STATE.DONE})); }); + it('shows a bulk hold while it runs and once it is done', async () => { + // Given a bulk hold that is still running + await Onyx.set(BULK_ACTION_KEY, {state: CONST.BULK_ACTION.STATE.RUNNING, action: CONST.SEARCH.BULK_ACTION_TYPES.HOLD}); + + render(); + await waitForBatchedUpdatesWithAct(); + expect(screen.getByText('bulkAction.holdingTitle')).toBeTruthy(); + + // When the backend finishes it + await Onyx.set(BULK_ACTION_KEY, {state: CONST.BULK_ACTION.STATE.DONE, action: CONST.SEARCH.BULK_ACTION_TYPES.HOLD, total: 2, failedReportIDs: []}); + await waitForBatchedUpdatesWithAct(); + + // Then the modal shows the hold result + expect(screen.getByText('bulkAction.heldTitle')).toBeTruthy(); + }); + it('says so when no report matched', async () => { // Given a bulk pay that found no report to mark as paid await Onyx.set(BULK_ACTION_KEY, {state: CONST.BULK_ACTION.STATE.DONE, action: CONST.SEARCH.BULK_ACTION_TYPES.PAY, total: 0}); From fcec3624de567bfb872891c3ed81c2e3d6c6e59f Mon Sep 17 00:00:00 2001 From: allgandaf Date: Sun, 4 Oct 2026 10:07:48 +0530 Subject: [PATCH 25/73] add the bulk reject command --- .../parameters/QueueBulkRejectExpensesParams.ts | 17 +++++++++++++++++ src/libs/API/parameters/index.ts | 1 + src/libs/API/types.ts | 2 ++ src/libs/actions/Search.ts | 7 +++++++ src/types/onyx/BulkAction.ts | 3 ++- 5 files changed, 29 insertions(+), 1 deletion(-) create mode 100644 src/libs/API/parameters/QueueBulkRejectExpensesParams.ts diff --git a/src/libs/API/parameters/QueueBulkRejectExpensesParams.ts b/src/libs/API/parameters/QueueBulkRejectExpensesParams.ts new file mode 100644 index 000000000000..09d7bce054f4 --- /dev/null +++ b/src/libs/API/parameters/QueueBulkRejectExpensesParams.ts @@ -0,0 +1,17 @@ +import type {SearchQueryString} from '@components/Search/types'; + +type QueueBulkRejectExpensesParams = { + /** Serialized search query describing every expense to reject, so the backend can page through all matches instead of relying on a client-side list */ + jsonQuery: SearchQueryString; + + /** Why the expenses are being rejected */ + comment: string; + + /** ID of the bulk action record the backend updates as the rejections finish */ + bulkActionID: string; + + /** Comma-separated expenses the user deselected after "Select all" */ + excludedTransactionIDList: string; +}; + +export default QueueBulkRejectExpensesParams; diff --git a/src/libs/API/parameters/index.ts b/src/libs/API/parameters/index.ts index a4d5367f3663..ac580d6f4fc8 100644 --- a/src/libs/API/parameters/index.ts +++ b/src/libs/API/parameters/index.ts @@ -615,6 +615,7 @@ export type {default as QueueBulkApproveReportsParams} from './QueueBulkApproveR export type {default as QueueBulkSubmitReportsParams} from './QueueBulkSubmitReportsParams'; export type {default as QueueBulkHoldExpensesParams} from './QueueBulkHoldExpensesParams'; export type {default as QueueBulkUnholdExpensesParams} from './QueueBulkUnholdExpensesParams'; +export type {default as QueueBulkRejectExpensesParams} from './QueueBulkRejectExpensesParams'; export type {default as QueueBulkMarkAsExportedParams} from './QueueBulkMarkAsExportedParams'; export type {default as AssignReportToMeParams} from './AssignReportToMeParams'; export type {default as AddReportApproverParams} from './AddReportApproverParams'; diff --git a/src/libs/API/types.ts b/src/libs/API/types.ts index e330170e0258..8e873a923867 100644 --- a/src/libs/API/types.ts +++ b/src/libs/API/types.ts @@ -620,6 +620,7 @@ const WRITE_COMMANDS = { QUEUE_BULK_SUBMIT_REPORTS: 'QueueBulkSubmitReports', QUEUE_BULK_HOLD_EXPENSES: 'QueueBulkHoldExpenses', QUEUE_BULK_UNHOLD_EXPENSES: 'QueueBulkUnholdExpenses', + QUEUE_BULK_REJECT_EXPENSES: 'QueueBulkRejectExpenses', QUEUE_BULK_MARK_AS_EXPORTED: 'QueueBulkMarkAsExported', CREATE_WORKSPACE_APPROVAL: 'CreateWorkspaceApproval', UPDATE_WORKSPACE_APPROVAL: 'UpdateWorkspaceApproval', @@ -1420,6 +1421,7 @@ type WriteCommandParameters = { [WRITE_COMMANDS.QUEUE_BULK_SUBMIT_REPORTS]: Parameters.QueueBulkSubmitReportsParams; [WRITE_COMMANDS.QUEUE_BULK_HOLD_EXPENSES]: Parameters.QueueBulkHoldExpensesParams; [WRITE_COMMANDS.QUEUE_BULK_UNHOLD_EXPENSES]: Parameters.QueueBulkUnholdExpensesParams; + [WRITE_COMMANDS.QUEUE_BULK_REJECT_EXPENSES]: Parameters.QueueBulkRejectExpensesParams; [WRITE_COMMANDS.QUEUE_BULK_MARK_AS_EXPORTED]: Parameters.QueueBulkMarkAsExportedParams; [WRITE_COMMANDS.EXPORT_REPORT_TO_CSV]: Parameters.ExportReportCSVParams; [WRITE_COMMANDS.CREATE_WORKSPACE_APPROVAL]: Parameters.CreateWorkspaceApprovalParams; diff --git a/src/libs/actions/Search.ts b/src/libs/actions/Search.ts index 59d56d9a0dde..97484b5c2932 100644 --- a/src/libs/actions/Search.ts +++ b/src/libs/actions/Search.ts @@ -2200,6 +2200,12 @@ function queueBulkUnholdExpenses(jsonQuery: string, excludedTransactionIDList: s write(WRITE_COMMANDS.QUEUE_BULK_UNHOLD_EXPENSES, {jsonQuery, bulkActionID, excludedTransactionIDList: excludedTransactionIDList.join(',')}, onyxData); } +/** Queues a rejection, with the given reason, for every expense matching the search query on reports the user can reject. */ +function queueBulkRejectExpenses(jsonQuery: string, comment: string, excludedTransactionIDList: string[]) { + const {bulkActionID, onyxData} = buildBulkActionOnyxData(CONST.SEARCH.BULK_ACTION_TYPES.REJECT); + write(WRITE_COMMANDS.QUEUE_BULK_REJECT_EXPENSES, {jsonQuery, comment: getParsedComment(comment), bulkActionID, excludedTransactionIDList: excludedTransactionIDList.join(',')}, onyxData); +} + /** * Queues a manual bulk "Mark as exported" for every report matching the given search query on the given connection. * The backend pages through all matches itself, so this covers reports beyond the currently loaded page(s) when @@ -2650,6 +2656,7 @@ export { queueBulkSubmitReports, queueBulkHoldExpenses, queueBulkUnholdExpenses, + queueBulkRejectExpenses, queueBulkMarkAsExported, updateAdvancedFilters, setSearchContext, diff --git a/src/types/onyx/BulkAction.ts b/src/types/onyx/BulkAction.ts index 0a03ce94513d..4933fde8a89c 100644 --- a/src/types/onyx/BulkAction.ts +++ b/src/types/onyx/BulkAction.ts @@ -11,7 +11,8 @@ type BulkActionType = | typeof CONST.SEARCH.BULK_ACTION_TYPES.SUBMIT | typeof CONST.SEARCH.BULK_ACTION_TYPES.PAY | typeof CONST.SEARCH.BULK_ACTION_TYPES.HOLD - | typeof CONST.SEARCH.BULK_ACTION_TYPES.UNHOLD; + | typeof CONST.SEARCH.BULK_ACTION_TYPES.UNHOLD + | typeof CONST.SEARCH.BULK_ACTION_TYPES.REJECT; /** Model of a bulk action started from Search "Select all" */ type BulkAction = { From 3d31ed34f2837f50c870556475ddf9d2c8087466 Mon Sep 17 00:00:00 2001 From: allgandaf Date: Sun, 4 Oct 2026 10:07:49 +0530 Subject: [PATCH 26/73] add bulk reject copy --- src/languages/en.ts | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/languages/en.ts b/src/languages/en.ts index ef18b07cb112..1f22c40eb5af 100644 --- a/src/languages/en.ts +++ b/src/languages/en.ts @@ -11698,6 +11698,7 @@ const translations = { payingTitle: 'Marking reports as paid...', holdingTitle: 'Holding expenses...', unholdingTitle: 'Unholding expenses...', + rejectingTitle: 'Rejecting expenses...', runningBody: "This can take a few minutes. You can wait here, or Concierge can message you when it's done.", sendFromConcierge: "Message me when it's done", conciergeTitle: 'You bet!', @@ -11708,6 +11709,7 @@ const translations = { paidTitle: ({count, total}: {count: number; total: number}) => `Marked ${count} of ${total} ${total === 1 ? 'report' : 'reports'} as paid`, heldTitle: ({count, total}: {count: number; total: number}) => `Held expenses on ${count} of ${total} ${total === 1 ? 'report' : 'reports'}`, unheldTitle: ({count, total}: {count: number; total: number}) => `Unheld expenses on ${count} of ${total} ${total === 1 ? 'report' : 'reports'}`, + rejectedTitle: ({count, total}: {count: number; total: number}) => `Rejected expenses on ${count} of ${total} ${total === 1 ? 'report' : 'reports'}`, noReportsTitle: 'No matching reports', noReportsBody: 'None of the reports you selected needed this action.', failedReportsBody: ({count}: {count: number}) => (count === 1 ? "1 report couldn't be updated." : `${count} reports couldn't be updated.`), From fcb88afd487b5c151ca7fb7d1297e29b372bcd05 Mon Sep 17 00:00:00 2001 From: allgandaf Date: Sun, 4 Oct 2026 10:07:49 +0530 Subject: [PATCH 27/73] translate bulk reject copy --- src/languages/de.ts | 2 ++ src/languages/el.ts | 2 ++ src/languages/es.ts | 2 ++ src/languages/fr.ts | 2 ++ src/languages/it.ts | 2 ++ src/languages/ja.ts | 2 ++ src/languages/nl.ts | 2 ++ src/languages/pl.ts | 2 ++ src/languages/pt-BR.ts | 2 ++ src/languages/zh-hans.ts | 2 ++ 10 files changed, 20 insertions(+) diff --git a/src/languages/de.ts b/src/languages/de.ts index df5bfa75fe77..ecea954cc94c 100644 --- a/src/languages/de.ts +++ b/src/languages/de.ts @@ -11714,6 +11714,7 @@ Hier ist ein *Testbeleg*, um dir zu zeigen, wie es funktioniert:`, payingTitle: 'Berichte werden als bezahlt markiert …', holdingTitle: 'Ausgaben werden zurückgehalten …', unholdingTitle: 'Zurückhalten von Ausgaben wird aufgehoben …', + rejectingTitle: 'Ausgaben werden abgelehnt …', runningBody: 'Dies kann einige Minuten dauern. Sie können hier warten, oder Concierge kann Ihnen eine Nachricht senden, wenn es fertig ist.', sendFromConcierge: 'Mir eine Nachricht senden, wenn es fertig ist', conciergeTitle: 'Auf jeden Fall!', @@ -11724,6 +11725,7 @@ Hier ist ein *Testbeleg*, um dir zu zeigen, wie es funktioniert:`, paidTitle: ({count, total}: {count: number; total: number}) => `${count} von ${total} ${total === 1 ? 'Bericht' : 'Berichte'} als bezahlt markiert`, heldTitle: ({count, total}: {count: number; total: number}) => `Ausgaben in ${count} von ${total} ${total === 1 ? 'Bericht' : 'Berichten'} zurückgehalten`, unheldTitle: ({count, total}: {count: number; total: number}) => `Zurückhalten von Ausgaben in ${count} von ${total} ${total === 1 ? 'Bericht' : 'Berichten'} aufgehoben`, + rejectedTitle: ({count, total}: {count: number; total: number}) => `Ausgaben in ${count} von ${total} ${total === 1 ? 'Bericht' : 'Berichten'} abgelehnt`, noReportsTitle: 'Keine übereinstimmenden Berichte', noReportsBody: 'Keiner der von Ihnen ausgewählten Berichte benötigte diese Aktion.', failedReportsBody: ({count}: {count: number}) => (count === 1 ? '1 Bericht konnte nicht aktualisiert werden.' : `${count} Berichte konnten nicht aktualisiert werden.`), diff --git a/src/languages/el.ts b/src/languages/el.ts index 3cae4c054bbf..492f2717e6a1 100644 --- a/src/languages/el.ts +++ b/src/languages/el.ts @@ -11956,6 +11956,7 @@ ${reportName}`, payingTitle: 'Σημειώνονται οι αναφορές ως πληρωμένες...', holdingTitle: 'Τα έξοδα τίθενται σε αναμονή...', unholdingTitle: 'Αφαιρείται η κράτηση των εξόδων...', + rejectingTitle: 'Απόρριψη εξόδων...', runningBody: 'Αυτό μπορεί να πάρει μερικά λεπτά. Μπορείτε να περιμένετε εδώ ή ο Concierge μπορεί να σας στείλει μήνυμα όταν ολοκληρωθεί.', sendFromConcierge: 'Στείλτε μου μήνυμα όταν τελειώσει', conciergeTitle: 'Βεβαίως!', @@ -11966,6 +11967,7 @@ ${reportName}`, paidTitle: ({count, total}: {count: number; total: number}) => `Σημειώθηκαν ως πληρωμένες ${count} από ${total} ${total === 1 ? 'αναφορά' : 'αναφορές'}`, heldTitle: ({count, total}: {count: number; total: number}) => `Τέθηκαν σε αναμονή έξοδα σε ${count} από ${total} ${total === 1 ? 'αναφορά' : 'αναφορές'}`, unheldTitle: ({count, total}: {count: number; total: number}) => `Αφαιρέθηκε η κράτηση εξόδων σε ${count} από ${total} ${total === 1 ? 'αναφορά' : 'αναφορές'}`, + rejectedTitle: ({count, total}: {count: number; total: number}) => `Απορρίφθηκαν έξοδα σε ${count} από ${total} ${total === 1 ? 'αναφορά' : 'αναφορές'}`, noReportsTitle: 'Δεν υπάρχουν αντιστοιχίες αναφορών', noReportsBody: 'Καμία από τις αναφορές που επιλέξατε δεν χρειαζόταν αυτή την ενέργεια.', failedReportsBody: ({count}: {count: number}) => (count === 1 ? '1 αναφορά δεν μπόρεσε να ενημερωθεί.' : `${count} αναφορές δεν ήταν δυνατό να ενημερωθούν.`), diff --git a/src/languages/es.ts b/src/languages/es.ts index 92b73a2f7958..7ee0a1ca50eb 100644 --- a/src/languages/es.ts +++ b/src/languages/es.ts @@ -11983,6 +11983,7 @@ ${reportName}`, payingTitle: 'Marcando informes como pagados...', holdingTitle: 'Reteniendo gastos...', unholdingTitle: 'Desbloqueando gastos...', + rejectingTitle: 'Rechazando gastos...', runningBody: 'Esto puede tardar unos minutos. Puedes esperar aquí o Concierge puede enviarte un mensaje cuando haya terminado.', sendFromConcierge: 'Envíame un mensaje cuando esté listo', conciergeTitle: '¡Por supuesto!', @@ -11993,6 +11994,7 @@ ${reportName}`, paidTitle: ({count, total}: {count: number; total: number}) => `Marcados ${count} de ${total} ${total === 1 ? 'informe' : 'informes'} como pagados`, heldTitle: ({count, total}: {count: number; total: number}) => `Gastos retenidos en ${count} de ${total} ${total === 1 ? 'informe' : 'informes'}`, unheldTitle: ({count, total}: {count: number; total: number}) => `Gastos desbloqueados en ${count} de ${total} ${total === 1 ? 'informe' : 'informes'}`, + rejectedTitle: ({count, total}: {count: number; total: number}) => `Gastos rechazados en ${count} de ${total} ${total === 1 ? 'informe' : 'informes'}`, noReportsTitle: 'No hay informes coincidentes', noReportsBody: 'Ninguno de los informes que seleccionaste necesitaba esta acción.', failedReportsBody: ({count}: {count: number}) => (count === 1 ? 'No se pudo actualizar 1 informe.' : `No se pudieron actualizar ${count} informes.`), diff --git a/src/languages/fr.ts b/src/languages/fr.ts index 5690062a9ba6..69be3e0452eb 100644 --- a/src/languages/fr.ts +++ b/src/languages/fr.ts @@ -11742,6 +11742,7 @@ Voici un *reçu test* pour vous montrer comment ça fonctionne :`, payingTitle: 'Marquage des notes de frais comme payées...', holdingTitle: 'Mise en attente des dépenses...', unholdingTitle: 'Suppression de la mise en attente des dépenses...', + rejectingTitle: 'Rejet des dépenses...', runningBody: 'Cela peut prendre quelques minutes. Vous pouvez attendre ici ou Concierge peut vous envoyer un message lorsque ce sera terminé.', sendFromConcierge: 'Envoyez-moi un message quand ce sera fait', conciergeTitle: 'Bien sûr !', @@ -11752,6 +11753,7 @@ Voici un *reçu test* pour vous montrer comment ça fonctionne :`, paidTitle: ({count, total}: {count: number; total: number}) => `Marqué ${count} sur ${total} ${total === 1 ? 'note de frais' : 'notes de frais'} comme payé`, heldTitle: ({count, total}: {count: number; total: number}) => `Dépenses mises en attente pour ${count} sur ${total} ${total === 1 ? 'note de frais' : 'notes de frais'}`, unheldTitle: ({count, total}: {count: number; total: number}) => `Mise en attente supprimée pour ${count} sur ${total} ${total === 1 ? 'note de frais' : 'notes de frais'}`, + rejectedTitle: ({count, total}: {count: number; total: number}) => `Dépenses rejetées pour ${count} sur ${total} ${total === 1 ? 'note de frais' : 'notes de frais'}`, noReportsTitle: 'Aucune note de frais correspondante', noReportsBody: 'Aucune des notes de frais que vous avez sélectionnées n’avait besoin de cette action.', failedReportsBody: ({count}: {count: number}) => (count === 1 ? "1 note de frais n'a pas pu être mise à jour." : `${count} notes de frais n'ont pas pu être mises à jour.`), diff --git a/src/languages/it.ts b/src/languages/it.ts index 0d77e4d21a56..8ee3b1d0d938 100644 --- a/src/languages/it.ts +++ b/src/languages/it.ts @@ -11665,6 +11665,7 @@ Ecco una *ricevuta di prova* per mostrarti come funziona:`, payingTitle: 'Contrassegno dei report come pagati in corso...', holdingTitle: 'Messa in attesa delle spese in corso...', unholdingTitle: 'Rimozione del blocco delle spese in corso...', + rejectingTitle: 'Rifiuto delle spese in corso...', runningBody: 'Questo può richiedere alcuni minuti. Puoi aspettare qui oppure Concierge può mandarti un messaggio quando è tutto pronto.', sendFromConcierge: 'Scrivimi quando hai finito', conciergeTitle: 'Ci puoi contare!', @@ -11675,6 +11676,7 @@ Ecco una *ricevuta di prova* per mostrarti come funziona:`, paidTitle: ({count, total}: {count: number; total: number}) => `Contrassegnati ${count} su ${total} report come pagati`, heldTitle: ({count, total}: {count: number; total: number}) => `Spese messe in attesa in ${count} su ${total} report`, unheldTitle: ({count, total}: {count: number; total: number}) => `Blocco rimosso dalle spese in ${count} su ${total} report`, + rejectedTitle: ({count, total}: {count: number; total: number}) => `Spese rifiutate in ${count} su ${total} report`, noReportsTitle: 'Nessun report corrispondente', noReportsBody: 'Nessuno dei report che hai selezionato richiedeva questa azione.', failedReportsBody: ({count}: {count: number}) => (count === 1 ? '1 report non può essere aggiornato.' : `${count} report non hanno potuto essere aggiornati.`), diff --git a/src/languages/ja.ts b/src/languages/ja.ts index 9f0e9cbb077e..f3b570f1b673 100644 --- a/src/languages/ja.ts +++ b/src/languages/ja.ts @@ -11496,6 +11496,7 @@ ${reportName}`, payingTitle: 'レポートを支払済みにしています…', holdingTitle: '経費を保留にしています…', unholdingTitle: '経費の保留を解除しています…', + rejectingTitle: '経費を却下しています…', runningBody: '数分かかる場合があります。ここでお待ちいただくか、完了したときに Concierge からメッセージを受け取ることもできます。', sendFromConcierge: '完了したらメッセージを送ってください', conciergeTitle: 'もちろんです!', @@ -11506,6 +11507,7 @@ ${reportName}`, paidTitle: ({count, total}: {count: number; total: number}) => `${total} 件中 ${count} 件のレポートを支払済みにしました`, heldTitle: ({count, total}: {count: number; total: number}) => `${total} 件中 ${count} 件のレポートの経費を保留にしました`, unheldTitle: ({count, total}: {count: number; total: number}) => `${total} 件中 ${count} 件のレポートの経費の保留を解除しました`, + rejectedTitle: ({count, total}: {count: number; total: number}) => `${total} 件中 ${count} 件のレポートの経費を却下しました`, noReportsTitle: '一致するレポートはありません', noReportsBody: '選択したレポートには、いずれもこの操作は必要ありませんでした。', failedReportsBody: ({count}: {count: number}) => (count === 1 ? '1件のレポートを更新できませんでした。' : `${count} 件のレポートを更新できませんでした。`), diff --git a/src/languages/nl.ts b/src/languages/nl.ts index 55f84a147e2c..a13da6f609c6 100644 --- a/src/languages/nl.ts +++ b/src/languages/nl.ts @@ -11629,6 +11629,7 @@ Hier is een *proefbon* om je te laten zien hoe het werkt:`, payingTitle: 'Rapporten markeren als betaald...', holdingTitle: 'Uitgaven vasthouden...', unholdingTitle: 'Blokkering van uitgaven opheffen...', + rejectingTitle: 'Uitgaven afwijzen...', runningBody: 'Dit kan een paar minuten duren. Je kunt hier wachten, of Concierge kan je een bericht sturen als het klaar is.', sendFromConcierge: 'Stuur me een bericht als het klaar is', conciergeTitle: 'Zeker weten!', @@ -11639,6 +11640,7 @@ Hier is een *proefbon* om je te laten zien hoe het werkt:`, paidTitle: ({count, total}: {count: number; total: number}) => `${count} van ${total} ${total === 1 ? 'rapport' : 'rapporten'} als betaald gemarkeerd`, heldTitle: ({count, total}: {count: number; total: number}) => `Uitgaven vastgehouden in ${count} van ${total} ${total === 1 ? 'rapport' : 'rapporten'}`, unheldTitle: ({count, total}: {count: number; total: number}) => `Blokkering van uitgaven opgeheven in ${count} van ${total} ${total === 1 ? 'rapport' : 'rapporten'}`, + rejectedTitle: ({count, total}: {count: number; total: number}) => `Uitgaven afgewezen in ${count} van ${total} ${total === 1 ? 'rapport' : 'rapporten'}`, noReportsTitle: 'Geen overeenkomende rapporten', noReportsBody: 'Geen van de rapporten die je hebt geselecteerd had deze actie nodig.', failedReportsBody: ({count}: {count: number}) => (count === 1 ? '1 rapport kon niet worden bijgewerkt.' : `${count} rapporten konden niet worden bijgewerkt.`), diff --git a/src/languages/pl.ts b/src/languages/pl.ts index c3b22b6831f6..2fdd4036842f 100644 --- a/src/languages/pl.ts +++ b/src/languages/pl.ts @@ -11644,6 +11644,7 @@ Oto *paragon testowy*, żeby pokazać Ci, jak to działa:`, payingTitle: 'Oznaczanie raportów jako opłacone...', holdingTitle: 'Wstrzymywanie wydatków...', unholdingTitle: 'Usuwanie blokady wydatków...', + rejectingTitle: 'Odrzucanie wydatków...', runningBody: 'To może potrwać kilka minut. Możesz poczekać tutaj albo Concierge napisze do ciebie, kiedy będzie gotowe.', sendFromConcierge: 'Napisz do mnie, kiedy będzie gotowe', conciergeTitle: 'No jasne!', @@ -11654,6 +11655,7 @@ Oto *paragon testowy*, żeby pokazać Ci, jak to działa:`, paidTitle: ({count, total}: {count: number; total: number}) => `Oznaczono ${count} z ${total} ${total === 1 ? 'raportu' : 'raportów'} jako opłacone`, heldTitle: ({count, total}: {count: number; total: number}) => `Wstrzymano wydatki w ${count} z ${total} ${total === 1 ? 'raportu' : 'raportów'}`, unheldTitle: ({count, total}: {count: number; total: number}) => `Usunięto blokadę wydatków w ${count} z ${total} ${total === 1 ? 'raportu' : 'raportów'}`, + rejectedTitle: ({count, total}: {count: number; total: number}) => `Odrzucono wydatki w ${count} z ${total} ${total === 1 ? 'raportu' : 'raportów'}`, noReportsTitle: 'Brak pasujących raportów', noReportsBody: 'Żaden z wybranych raportów nie wymagał tej akcji.', failedReportsBody: ({count}: {count: number}) => (count === 1 ? 'Nie udało się zaktualizować 1 raportu.' : `Nie udało się zaktualizować ${count} raportów.`), diff --git a/src/languages/pt-BR.ts b/src/languages/pt-BR.ts index f46a7b28d0ba..ffcc2ef09f87 100644 --- a/src/languages/pt-BR.ts +++ b/src/languages/pt-BR.ts @@ -11621,6 +11621,7 @@ Aqui está um *comprovante de teste* para mostrar como funciona:`, payingTitle: 'Marcando relatórios como pagos...', holdingTitle: 'Retendo despesas...', unholdingTitle: 'Removendo bloqueio das despesas...', + rejectingTitle: 'Rejeitando despesas...', runningBody: 'Isso pode levar alguns minutos. Você pode esperar aqui ou o Concierge pode te mandar uma mensagem quando terminar.', sendFromConcierge: 'Me avise quando terminar', conciergeTitle: 'Pode apostar!', @@ -11631,6 +11632,7 @@ Aqui está um *comprovante de teste* para mostrar como funciona:`, paidTitle: ({count, total}: {count: number; total: number}) => `Marcado(s) ${count} de ${total} ${total === 1 ? 'relatório' : 'relatórios'} como pago(s)`, heldTitle: ({count, total}: {count: number; total: number}) => `Despesas retidas em ${count} de ${total} ${total === 1 ? 'relatório' : 'relatórios'}`, unheldTitle: ({count, total}: {count: number; total: number}) => `Bloqueio removido das despesas em ${count} de ${total} ${total === 1 ? 'relatório' : 'relatórios'}`, + rejectedTitle: ({count, total}: {count: number; total: number}) => `Despesas rejeitadas em ${count} de ${total} ${total === 1 ? 'relatório' : 'relatórios'}`, noReportsTitle: 'Nenhum relatório correspondente', noReportsBody: 'Nenhum dos relatórios que você selecionou precisava dessa ação.', failedReportsBody: ({count}: {count: number}) => (count === 1 ? '1 relatório não pôde ser atualizado.' : `${count} relatórios não puderam ser atualizados.`), diff --git a/src/languages/zh-hans.ts b/src/languages/zh-hans.ts index c5af00894faf..da5f5e1b9e7e 100644 --- a/src/languages/zh-hans.ts +++ b/src/languages/zh-hans.ts @@ -11205,6 +11205,7 @@ ${reportName}`, payingTitle: '正在将报表标记为已支付…', holdingTitle: '正在暂挂报销费用…', unholdingTitle: '正在解除报销费用的保留…', + rejectingTitle: '正在拒绝报销费用…', runningBody: '这可能需要几分钟。你可以在这里等待,或者等完成后由 Concierge 给你发送消息。', sendFromConcierge: '完成后给我发消息', conciergeTitle: '当然!', @@ -11215,6 +11216,7 @@ ${reportName}`, paidTitle: ({count, total}: {count: number; total: number}) => `已将 ${total} 份报表中的 ${count} 份标记为已支付`, heldTitle: ({count, total}: {count: number; total: number}) => `已暂挂 ${total} 份报表中 ${count} 份的报销费用`, unheldTitle: ({count, total}: {count: number; total: number}) => `已解除 ${total} 份报表中 ${count} 份的报销费用保留`, + rejectedTitle: ({count, total}: {count: number; total: number}) => `已拒绝 ${total} 份报表中 ${count} 份的报销费用`, noReportsTitle: '没有匹配的报表', noReportsBody: '您选择的报表都不需要执行此操作。', failedReportsBody: ({count}: {count: number}) => (count === 1 ? '1 份报表无法更新。' : `${count} 份报表无法更新。`), From 745584c4473c56e4159287c877d75f7a36b820cc Mon Sep 17 00:00:00 2001 From: allgandaf Date: Sun, 4 Oct 2026 10:07:50 +0530 Subject: [PATCH 28/73] show reject in the bulk action modal --- src/components/BulkActionStatusModal.tsx | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/components/BulkActionStatusModal.tsx b/src/components/BulkActionStatusModal.tsx index 2dc6ab51dc8c..fd8818fe356b 100644 --- a/src/components/BulkActionStatusModal.tsx +++ b/src/components/BulkActionStatusModal.tsx @@ -32,6 +32,7 @@ const RUNNING_TITLES = { [CONST.SEARCH.BULK_ACTION_TYPES.PAY]: 'bulkAction.payingTitle', [CONST.SEARCH.BULK_ACTION_TYPES.HOLD]: 'bulkAction.holdingTitle', [CONST.SEARCH.BULK_ACTION_TYPES.UNHOLD]: 'bulkAction.unholdingTitle', + [CONST.SEARCH.BULK_ACTION_TYPES.REJECT]: 'bulkAction.rejectingTitle', } as const satisfies Record; const DONE_TITLES = { @@ -40,6 +41,7 @@ const DONE_TITLES = { [CONST.SEARCH.BULK_ACTION_TYPES.PAY]: 'bulkAction.paidTitle', [CONST.SEARCH.BULK_ACTION_TYPES.HOLD]: 'bulkAction.heldTitle', [CONST.SEARCH.BULK_ACTION_TYPES.UNHOLD]: 'bulkAction.unheldTitle', + [CONST.SEARCH.BULK_ACTION_TYPES.REJECT]: 'bulkAction.rejectedTitle', } as const satisfies Record; type BulkActionStatusModalProps = { From 4c1d1be9e864352292b1021142a9f741760799d3 Mon Sep 17 00:00:00 2001 From: allgandaf Date: Sun, 4 Oct 2026 10:07:50 +0530 Subject: [PATCH 29/73] offer reject under select all --- src/hooks/useSearchBulkActions.ts | 52 +++++++++++++++++-------------- 1 file changed, 29 insertions(+), 23 deletions(-) diff --git a/src/hooks/useSearchBulkActions.ts b/src/hooks/useSearchBulkActions.ts index b962a04dd27b..719ee3dfafb7 100644 --- a/src/hooks/useSearchBulkActions.ts +++ b/src/hooks/useSearchBulkActions.ts @@ -2516,6 +2516,30 @@ function useSearchBulkActions({queryJSON}: UseSearchBulkActionsParams) { }, }; + const rejectOption: DropdownOption = { + icon: expensifyIcons.ThumbsDown, + text: translate('search.bulkActions.reject'), + value: CONST.SEARCH.BULK_ACTION_TYPES.REJECT, + shouldCloseModalOnSelect: true, + onSelected: () => { + if (isOffline) { + setIsOfflineModalVisible(true); + return; + } + + if (isDelegateAccessRestricted) { + showDelegateNoAccessModal(); + return; + } + + if (dismissedRejectUseExplanation) { + Navigation.navigate(ROUTES.SEARCH_REJECT_REASON_RHP); + } else { + setRejectModalAction(CONST.REPORT.TRANSACTION_SECONDARY_ACTIONS.REJECT); + } + }, + }; + const holdOption: DropdownOption = { icon: expensifyIcons.Stopwatch, text: translate('search.bulkActions.hold'), @@ -2697,6 +2721,10 @@ function useSearchBulkActions({queryJSON}: UseSearchBulkActionsParams) { if (shouldShowPayOption) { allMatchingOptions.push(payButtonOption); } + // The backend only rejects expenses on reports the user can reject, so one loaded item is enough to offer it. + if (queryJSON?.type !== CONST.SEARCH.DATA_TYPES.EXPENSE_REPORT && !isOffline && selectedTransactionsKeys.some((id) => selectedTransactions[id].canReject)) { + allMatchingOptions.push(rejectOption); + } // The backend only acts on the matching expenses the user can hold or unhold, so one loaded item is enough to offer it. if (!isOffline && selectedTransactionsKeys.some((id) => selectedTransactions[id].canHold)) { allMatchingOptions.push(holdOption); @@ -2802,29 +2830,7 @@ function useSearchBulkActions({queryJSON}: UseSearchBulkActionsParams) { hasNoRejectedTransaction; if (shouldShowRejectOption) { - options.push({ - icon: expensifyIcons.ThumbsDown, - text: translate('search.bulkActions.reject'), - value: CONST.SEARCH.BULK_ACTION_TYPES.REJECT, - shouldCloseModalOnSelect: true, - onSelected: () => { - if (isOffline) { - setIsOfflineModalVisible(true); - return; - } - - if (isDelegateAccessRestricted) { - showDelegateNoAccessModal(); - return; - } - - if (dismissedRejectUseExplanation) { - Navigation.navigate(ROUTES.SEARCH_REJECT_REASON_RHP); - } else { - setRejectModalAction(CONST.REPORT.TRANSACTION_SECONDARY_ACTIONS.REJECT); - } - }, - }); + options.push(rejectOption); } const shouldShowChangeApproverOption = From f6676f21fe080586ea48bc98578db67b12d7f100 Mon Sep 17 00:00:00 2001 From: allgandaf Date: Sun, 4 Oct 2026 10:07:51 +0530 Subject: [PATCH 30/73] queue a bulk reject from the reject reason page --- src/pages/Search/SearchRejectReasonPage.tsx | 28 ++++++++++++++++++--- 1 file changed, 24 insertions(+), 4 deletions(-) diff --git a/src/pages/Search/SearchRejectReasonPage.tsx b/src/pages/Search/SearchRejectReasonPage.tsx index 846b25079a36..ce7891a4069b 100644 --- a/src/pages/Search/SearchRejectReasonPage.tsx +++ b/src/pages/Search/SearchRejectReasonPage.tsx @@ -1,7 +1,7 @@ import {useDelegateNoAccessActions, useDelegateNoAccessState} from '@components/DelegateNoAccessModalProvider'; import type {FormInputErrors, FormOnyxValues} from '@components/Form/types'; import {useAllReportsTransactionsAndViolations} from '@components/OnyxListItemProvider'; -import {useSearchQueryContext, useSearchSelectionActions, useSearchSelectionContext} from '@components/Search/SearchContext'; +import {useSearchQueryContext, useSearchResultsContext, useSearchSelectionActions, useSearchSelectionContext} from '@components/Search/SearchContext'; import {useCurrencyListActions} from '@hooks/useCurrencyList'; import useCurrentUserPersonalDetails from '@hooks/useCurrentUserPersonalDetails'; @@ -9,9 +9,11 @@ import useDelegateAccountID from '@hooks/useDelegateAccountID'; import useLocalize from '@hooks/useLocalize'; import useOnyx from '@hooks/useOnyx'; import usePermissions from '@hooks/usePermissions'; +import {getAllMatchingExpenseActionQuery} from '@hooks/useSearchBulkActions'; import {clearErrorFields, clearErrors} from '@libs/actions/FormActions'; -import {rejectMoneyRequestsOnSearch} from '@libs/actions/Search'; +import {queueBulkRejectExpenses, rejectMoneyRequestsOnSearch} from '@libs/actions/Search'; +import Log from '@libs/Log'; import Navigation from '@libs/Navigation/Navigation'; import type {PlatformStackScreenProps} from '@libs/Navigation/PlatformStackNavigation/types'; import {getFieldRequiredErrors} from '@libs/ValidationUtils'; @@ -33,8 +35,9 @@ type SearchRejectReasonPageProps = | PlatformStackScreenProps; function SearchRejectReasonPage({route}: SearchRejectReasonPageProps) { - const {selectedTransactionIDs, selectedTransactions} = useSearchSelectionContext(); - const {currentSearchHash} = useSearchQueryContext(); + const {selectedTransactionIDs, selectedTransactions, excludedTransactions, areAllMatchingItemsSelected} = useSearchSelectionContext(); + const {currentSearchHash, currentSearchQueryJSON} = useSearchQueryContext(); + const {currentSearchResults} = useSearchResultsContext(); const {clearSelectedTransactions} = useSearchSelectionActions(); const {reportID} = route.params ?? {}; const [allPolicies] = useOnyx(ONYXKEYS.COLLECTION.POLICY); @@ -67,6 +70,19 @@ function SearchRejectReasonPage({route}: SearchRejectReasonPageProps) { return; } + // "Select all" can cover more expenses than are loaded, so hand the search query to the backend to reject every match. + if (route.name === SCREENS.SEARCH.SEARCH_REJECT_REASON_RHP && areAllMatchingItemsSelected) { + const allMatchingQuery = currentSearchQueryJSON ? getAllMatchingExpenseActionQuery(currentSearchQueryJSON, excludedTransactions, currentSearchResults?.data) : undefined; + if (!allMatchingQuery) { + Log.info('[BulkReject] Dropping bulk reject: an excluded row could not be resolved'); + return; + } + queueBulkRejectExpenses(allMatchingQuery.jsonQuery, comment, allMatchingQuery.excludedTransactionIDList); + clearSelectedTransactions(); + Navigation.dismissToSuperWideRHP(); + return; + } + const urlToNavigateBack = rejectMoneyRequestsOnSearch({ hash: currentSearchHash, selectedTransactions: selectedTransactionsForReject, @@ -107,6 +123,10 @@ function SearchRejectReasonPage({route}: SearchRejectReasonPageProps) { route.name, showDelegateNoAccessModal, clearSelectedTransactions, + areAllMatchingItemsSelected, + currentSearchQueryJSON, + excludedTransactions, + currentSearchResults?.data, ], ); From d31fc2754d92578b2aac541bec6177ee4dd09522 Mon Sep 17 00:00:00 2001 From: allgandaf Date: Sun, 4 Oct 2026 10:07:51 +0530 Subject: [PATCH 31/73] test reject under select all --- tests/unit/hooks/useSearchBulkActionsTest.ts | 30 +++++++++++++++++++- 1 file changed, 29 insertions(+), 1 deletion(-) diff --git a/tests/unit/hooks/useSearchBulkActionsTest.ts b/tests/unit/hooks/useSearchBulkActionsTest.ts index 402ca4bfa22a..a09d05a14344 100644 --- a/tests/unit/hooks/useSearchBulkActionsTest.ts +++ b/tests/unit/hooks/useSearchBulkActionsTest.ts @@ -762,7 +762,7 @@ describe('useSearchBulkActions - Submit under Select all', () => { }); }); -describe('useSearchBulkActions - Hold and Unhold under Select all', () => { +describe('useSearchBulkActions - Hold, Unhold and Reject under Select all', () => { beforeAll(() => { Onyx.init({keys: ONYXKEYS}); }); @@ -822,6 +822,34 @@ describe('useSearchBulkActions - Hold and Unhold under Select all', () => { expect(mockClearSelectedTransactions).toHaveBeenCalled(); }); + it('offers Reject on an expenses search when one loaded expense can be rejected', async () => { + // Given "Select all" on an expenses search with one rejectable expense and one that is not, which hides Reject for a normal selection + mockSelectedTransactions = {tx1: makeSelectedTransaction({canReject: true}), tx2: makeSelectedTransaction({canReject: false})}; + + // When the bulk actions are built + const {result} = renderHook(() => useSearchBulkActions({queryJSON: baseQueryJSON}), {wrapper: OnyxListItemProvider}); + + // Then Reject is offered, because the backend only rejects expenses on reports the user can reject + await waitFor(() => { + expect(result.current.headerButtonsOptions.some((option) => option.value === CONST.SEARCH.BULK_ACTION_TYPES.REJECT)).toBe(true); + }); + }); + + it('does not offer Reject on a reports search', async () => { + // Given "Select all" on a reports search with a rejectable expense loaded + mockSelectedTransactions = {tx1: makeSelectedTransaction({canReject: true})}; + + // When the bulk actions are built + const {result} = renderHook(() => useSearchBulkActions({queryJSON: expenseReportQueryJSON}), {wrapper: OnyxListItemProvider}); + + await waitFor(() => { + expect(result.current.headerButtonsOptions.length).toBeGreaterThan(0); + }); + + // Then Reject is not offered, the same as for a normal selection of reports + expect(result.current.headerButtonsOptions.some((option) => option.value === CONST.SEARCH.BULK_ACTION_TYPES.REJECT)).toBe(false); + }); + it('hides Hold and Unhold when no loaded expense can be held or unheld', async () => { // Given nothing on the loaded page can be held or unheld mockSelectedTransactions = {tx1: makeSelectedTransaction()}; From 46da901d96f907fe26759f2acbdf1ed0c07c58da Mon Sep 17 00:00:00 2001 From: allgandaf Date: Sun, 4 Oct 2026 10:07:52 +0530 Subject: [PATCH 32/73] test the reject reason page under select all --- tests/unit/SearchRejectReasonPageTest.tsx | 111 ++++++++++++++++++++++ 1 file changed, 111 insertions(+) create mode 100644 tests/unit/SearchRejectReasonPageTest.tsx diff --git a/tests/unit/SearchRejectReasonPageTest.tsx b/tests/unit/SearchRejectReasonPageTest.tsx new file mode 100644 index 000000000000..d7d90b602e54 --- /dev/null +++ b/tests/unit/SearchRejectReasonPageTest.tsx @@ -0,0 +1,111 @@ +import {render} from '@testing-library/react-native'; + +import type * as OnyxListItemProvider from '@components/OnyxListItemProvider'; +import type {SearchQueryJSON} from '@components/Search/types'; + +import {queueBulkRejectExpenses, rejectMoneyRequestsOnSearch} from '@libs/actions/Search'; + +import SearchRejectReasonPage from '@pages/Search/SearchRejectReasonPage'; + +import CONST from '@src/CONST'; +import ONYXKEYS from '@src/ONYXKEYS'; +import SCREENS from '@src/SCREENS'; + +import React from 'react'; +import Onyx from 'react-native-onyx'; + +import waitForBatchedUpdatesWithAct from '../utils/waitForBatchedUpdatesWithAct'; + +const mockQueryJSON: SearchQueryJSON = { + inputQuery: 'type:expense status:all', + hash: 12345, + recentSearchHash: 12345, + similarSearchHash: 12345, + flatFilters: [], + type: CONST.SEARCH.DATA_TYPES.EXPENSE, + sortBy: CONST.SEARCH.TABLE_COLUMNS.DATE, + sortOrder: CONST.SEARCH.SORT_ORDER.DESC, + view: CONST.SEARCH.VIEW.TABLE, + filters: {operator: CONST.SEARCH.SYNTAX_OPERATORS.AND, left: 'type', right: 'expense'}, +}; +const mockClearSelectedTransactions = jest.fn(); +let mockAreAllMatchingItemsSelected = false; +let mockSubmitRejectReason: ((values: {comment: string}) => void) | undefined; + +jest.mock('@pages/iou/RejectReasonFormView', () => { + function MockRejectReasonFormView({onSubmit}: {onSubmit: (values: {comment: string}) => void}) { + mockSubmitRejectReason = onSubmit; + return null; + } + return MockRejectReasonFormView; +}); +jest.mock('@components/Search/SearchContext', () => ({ + useSearchQueryContext: () => ({currentSearchHash: 12345, currentSearchQueryJSON: mockQueryJSON}), + useSearchResultsContext: () => ({currentSearchResults: undefined}), + useSearchSelectionActions: () => ({clearSelectedTransactions: mockClearSelectedTransactions}), + useSearchSelectionContext: () => ({ + selectedTransactionIDs: [], + selectedTransactions: {tx1: {reportID: 'report1'}}, + excludedTransactions: {tx2: {reportID: 'report1'}}, + areAllMatchingItemsSelected: mockAreAllMatchingItemsSelected, + }), +})); +jest.mock('@components/OnyxListItemProvider', () => ({ + ...jest.requireActual('@components/OnyxListItemProvider'), + useAllReportsTransactionsAndViolations: () => undefined, +})); +jest.mock('@libs/actions/Search', () => ({ + queueBulkRejectExpenses: jest.fn(), + rejectMoneyRequestsOnSearch: jest.fn(), +})); +jest.mock('@libs/Navigation/Navigation', () => ({ + dismissToSuperWideRHP: jest.fn(), + goBack: jest.fn(), + isNavigationReady: jest.fn(() => Promise.resolve()), +})); + +function renderPage(areAllMatchingItemsSelected: boolean) { + mockAreAllMatchingItemsSelected = areAllMatchingItemsSelected; + const route = {name: SCREENS.SEARCH.SEARCH_REJECT_REASON_RHP, key: 'reject', params: {}}; + // @ts-expect-error the page only reads route.name and route.params + render(); +} + +describe('SearchRejectReasonPage', () => { + beforeAll(() => { + Onyx.init({keys: ONYXKEYS}); + }); + + beforeEach(async () => { + jest.clearAllMocks(); + mockSubmitRejectReason = undefined; + await Onyx.clear(); + }); + + it('hands the search to the backend when Select all is checked', async () => { + // Given the reject reason page opened with "Select all" checked and one expense deselected + renderPage(true); + await waitForBatchedUpdatesWithAct(); + + // When the user submits a reason + mockSubmitRejectReason?.({comment: 'missing receipts'}); + + // Then every matching expense is rejected by the backend, except the deselected one, and nothing is rejected from the app + expect(queueBulkRejectExpenses).toHaveBeenCalledWith(expect.any(String), 'missing receipts', ['tx2']); + expect(rejectMoneyRequestsOnSearch).not.toHaveBeenCalled(); + expect(mockClearSelectedTransactions).toHaveBeenCalled(); + }); + + it('rejects the selected expenses from the app when Select all is not checked', async () => { + // Given the reject reason page opened with a manual selection + renderPage(false); + await waitForBatchedUpdatesWithAct(); + + // When the user submits a reason + mockSubmitRejectReason?.({comment: 'missing receipts'}); + + // Then the selected expenses are rejected directly and nothing is queued on the backend + expect(rejectMoneyRequestsOnSearch).toHaveBeenCalledTimes(1); + expect(queueBulkRejectExpenses).not.toHaveBeenCalled(); + }); +}); From 476803ae7b95b5fe351efe54b682e3f5027b0389 Mon Sep 17 00:00:00 2001 From: allgandaf Date: Sun, 4 Oct 2026 10:25:31 +0530 Subject: [PATCH 33/73] add the bulk delete commands --- src/CONST/index.ts | 1 + .../parameters/QueueBulkDeleteExpensesParams.ts | 14 ++++++++++++++ .../API/parameters/QueueBulkDeleteReportsParams.ts | 11 +++++++++++ src/libs/API/parameters/index.ts | 2 ++ src/libs/API/types.ts | 4 ++++ src/libs/actions/Search.ts | 14 ++++++++++++++ src/types/onyx/BulkAction.ts | 4 +++- 7 files changed, 49 insertions(+), 1 deletion(-) create mode 100644 src/libs/API/parameters/QueueBulkDeleteExpensesParams.ts create mode 100644 src/libs/API/parameters/QueueBulkDeleteReportsParams.ts diff --git a/src/CONST/index.ts b/src/CONST/index.ts index 4e1cecb2e307..9bcf8a997a25 100644 --- a/src/CONST/index.ts +++ b/src/CONST/index.ts @@ -617,6 +617,7 @@ const CONST = { DONE: 'done', FAILED: 'failed', }, + DELETE_EXPENSES: 'deleteExpenses', }, SECURE_DOWNLOAD_TYPE: { diff --git a/src/libs/API/parameters/QueueBulkDeleteExpensesParams.ts b/src/libs/API/parameters/QueueBulkDeleteExpensesParams.ts new file mode 100644 index 000000000000..623045f88230 --- /dev/null +++ b/src/libs/API/parameters/QueueBulkDeleteExpensesParams.ts @@ -0,0 +1,14 @@ +import type {SearchQueryString} from '@components/Search/types'; + +type QueueBulkDeleteExpensesParams = { + /** Serialized search query describing every expense to delete, so the backend can page through all matches instead of relying on a client-side list */ + jsonQuery: SearchQueryString; + + /** ID of the bulk action record the backend updates as the deletes finish */ + bulkActionID: string; + + /** Comma-separated expenses the user deselected after "Select all" */ + excludedTransactionIDList: string; +}; + +export default QueueBulkDeleteExpensesParams; diff --git a/src/libs/API/parameters/QueueBulkDeleteReportsParams.ts b/src/libs/API/parameters/QueueBulkDeleteReportsParams.ts new file mode 100644 index 000000000000..497f9deadc2f --- /dev/null +++ b/src/libs/API/parameters/QueueBulkDeleteReportsParams.ts @@ -0,0 +1,11 @@ +import type {SearchQueryString} from '@components/Search/types'; + +type QueueBulkDeleteReportsParams = { + /** Serialized search query describing every report to delete, so the backend can page through all matches instead of relying on a client-side list */ + jsonQuery: SearchQueryString; + + /** ID of the bulk action record the backend updates as the deletes finish */ + bulkActionID: string; +}; + +export default QueueBulkDeleteReportsParams; diff --git a/src/libs/API/parameters/index.ts b/src/libs/API/parameters/index.ts index ac580d6f4fc8..149b6d1264ac 100644 --- a/src/libs/API/parameters/index.ts +++ b/src/libs/API/parameters/index.ts @@ -616,6 +616,8 @@ export type {default as QueueBulkSubmitReportsParams} from './QueueBulkSubmitRep export type {default as QueueBulkHoldExpensesParams} from './QueueBulkHoldExpensesParams'; export type {default as QueueBulkUnholdExpensesParams} from './QueueBulkUnholdExpensesParams'; export type {default as QueueBulkRejectExpensesParams} from './QueueBulkRejectExpensesParams'; +export type {default as QueueBulkDeleteReportsParams} from './QueueBulkDeleteReportsParams'; +export type {default as QueueBulkDeleteExpensesParams} from './QueueBulkDeleteExpensesParams'; export type {default as QueueBulkMarkAsExportedParams} from './QueueBulkMarkAsExportedParams'; export type {default as AssignReportToMeParams} from './AssignReportToMeParams'; export type {default as AddReportApproverParams} from './AddReportApproverParams'; diff --git a/src/libs/API/types.ts b/src/libs/API/types.ts index 8e873a923867..23cbadc67b5b 100644 --- a/src/libs/API/types.ts +++ b/src/libs/API/types.ts @@ -621,6 +621,8 @@ const WRITE_COMMANDS = { QUEUE_BULK_HOLD_EXPENSES: 'QueueBulkHoldExpenses', QUEUE_BULK_UNHOLD_EXPENSES: 'QueueBulkUnholdExpenses', QUEUE_BULK_REJECT_EXPENSES: 'QueueBulkRejectExpenses', + QUEUE_BULK_DELETE_REPORTS: 'QueueBulkDeleteReports', + QUEUE_BULK_DELETE_EXPENSES: 'QueueBulkDeleteExpenses', QUEUE_BULK_MARK_AS_EXPORTED: 'QueueBulkMarkAsExported', CREATE_WORKSPACE_APPROVAL: 'CreateWorkspaceApproval', UPDATE_WORKSPACE_APPROVAL: 'UpdateWorkspaceApproval', @@ -1422,6 +1424,8 @@ type WriteCommandParameters = { [WRITE_COMMANDS.QUEUE_BULK_HOLD_EXPENSES]: Parameters.QueueBulkHoldExpensesParams; [WRITE_COMMANDS.QUEUE_BULK_UNHOLD_EXPENSES]: Parameters.QueueBulkUnholdExpensesParams; [WRITE_COMMANDS.QUEUE_BULK_REJECT_EXPENSES]: Parameters.QueueBulkRejectExpensesParams; + [WRITE_COMMANDS.QUEUE_BULK_DELETE_REPORTS]: Parameters.QueueBulkDeleteReportsParams; + [WRITE_COMMANDS.QUEUE_BULK_DELETE_EXPENSES]: Parameters.QueueBulkDeleteExpensesParams; [WRITE_COMMANDS.QUEUE_BULK_MARK_AS_EXPORTED]: Parameters.QueueBulkMarkAsExportedParams; [WRITE_COMMANDS.EXPORT_REPORT_TO_CSV]: Parameters.ExportReportCSVParams; [WRITE_COMMANDS.CREATE_WORKSPACE_APPROVAL]: Parameters.CreateWorkspaceApprovalParams; diff --git a/src/libs/actions/Search.ts b/src/libs/actions/Search.ts index 97484b5c2932..8913fca6ce5c 100644 --- a/src/libs/actions/Search.ts +++ b/src/libs/actions/Search.ts @@ -2206,6 +2206,18 @@ function queueBulkRejectExpenses(jsonQuery: string, comment: string, excludedTra write(WRITE_COMMANDS.QUEUE_BULK_REJECT_EXPENSES, {jsonQuery, comment: getParsedComment(comment), bulkActionID, excludedTransactionIDList: excludedTransactionIDList.join(',')}, onyxData); } +/** Queues a delete for every report matching the search query that the user can delete. */ +function queueBulkDeleteReports(jsonQuery: string) { + const {bulkActionID, onyxData} = buildBulkActionOnyxData(CONST.SEARCH.BULK_ACTION_TYPES.DELETE); + write(WRITE_COMMANDS.QUEUE_BULK_DELETE_REPORTS, {jsonQuery, bulkActionID}, onyxData); +} + +/** Queues a delete for every expense matching the search query that the user can delete. */ +function queueBulkDeleteExpenses(jsonQuery: string, excludedTransactionIDList: string[]) { + const {bulkActionID, onyxData} = buildBulkActionOnyxData(CONST.BULK_ACTION.DELETE_EXPENSES); + write(WRITE_COMMANDS.QUEUE_BULK_DELETE_EXPENSES, {jsonQuery, bulkActionID, excludedTransactionIDList: excludedTransactionIDList.join(',')}, onyxData); +} + /** * Queues a manual bulk "Mark as exported" for every report matching the given search query on the given connection. * The backend pages through all matches itself, so this covers reports beyond the currently loaded page(s) when @@ -2657,6 +2669,8 @@ export { queueBulkHoldExpenses, queueBulkUnholdExpenses, queueBulkRejectExpenses, + queueBulkDeleteReports, + queueBulkDeleteExpenses, queueBulkMarkAsExported, updateAdvancedFilters, setSearchContext, diff --git a/src/types/onyx/BulkAction.ts b/src/types/onyx/BulkAction.ts index 4933fde8a89c..fc141880c2bf 100644 --- a/src/types/onyx/BulkAction.ts +++ b/src/types/onyx/BulkAction.ts @@ -12,7 +12,9 @@ type BulkActionType = | typeof CONST.SEARCH.BULK_ACTION_TYPES.PAY | typeof CONST.SEARCH.BULK_ACTION_TYPES.HOLD | typeof CONST.SEARCH.BULK_ACTION_TYPES.UNHOLD - | typeof CONST.SEARCH.BULK_ACTION_TYPES.REJECT; + | typeof CONST.SEARCH.BULK_ACTION_TYPES.REJECT + | typeof CONST.SEARCH.BULK_ACTION_TYPES.DELETE + | typeof CONST.BULK_ACTION.DELETE_EXPENSES; /** Model of a bulk action started from Search "Select all" */ type BulkAction = { From 77aa748d3b1e362b4b103c8848189b815b2a2a2e Mon Sep 17 00:00:00 2001 From: allgandaf Date: Sun, 4 Oct 2026 10:25:31 +0530 Subject: [PATCH 34/73] add bulk delete copy --- src/languages/en.ts | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/languages/en.ts b/src/languages/en.ts index 1f22c40eb5af..5e7543938d9f 100644 --- a/src/languages/en.ts +++ b/src/languages/en.ts @@ -11699,6 +11699,8 @@ const translations = { holdingTitle: 'Holding expenses...', unholdingTitle: 'Unholding expenses...', rejectingTitle: 'Rejecting expenses...', + deletingTitle: 'Deleting reports...', + deletingExpensesTitle: 'Deleting expenses...', runningBody: "This can take a few minutes. You can wait here, or Concierge can message you when it's done.", sendFromConcierge: "Message me when it's done", conciergeTitle: 'You bet!', @@ -11710,6 +11712,8 @@ const translations = { heldTitle: ({count, total}: {count: number; total: number}) => `Held expenses on ${count} of ${total} ${total === 1 ? 'report' : 'reports'}`, unheldTitle: ({count, total}: {count: number; total: number}) => `Unheld expenses on ${count} of ${total} ${total === 1 ? 'report' : 'reports'}`, rejectedTitle: ({count, total}: {count: number; total: number}) => `Rejected expenses on ${count} of ${total} ${total === 1 ? 'report' : 'reports'}`, + deletedTitle: ({count, total}: {count: number; total: number}) => `Deleted ${count} of ${total} ${total === 1 ? 'report' : 'reports'}`, + deletedExpensesTitle: ({count, total}: {count: number; total: number}) => `Deleted expenses on ${count} of ${total} ${total === 1 ? 'report' : 'reports'}`, noReportsTitle: 'No matching reports', noReportsBody: 'None of the reports you selected needed this action.', failedReportsBody: ({count}: {count: number}) => (count === 1 ? "1 report couldn't be updated." : `${count} reports couldn't be updated.`), From 88d60fe5a7faba7086491af4eb40ed75d343c4d1 Mon Sep 17 00:00:00 2001 From: allgandaf Date: Sun, 4 Oct 2026 10:25:32 +0530 Subject: [PATCH 35/73] translate bulk delete copy --- src/languages/de.ts | 4 ++++ src/languages/el.ts | 4 ++++ src/languages/es.ts | 4 ++++ src/languages/fr.ts | 4 ++++ src/languages/it.ts | 4 ++++ src/languages/ja.ts | 4 ++++ src/languages/nl.ts | 4 ++++ src/languages/pl.ts | 4 ++++ src/languages/pt-BR.ts | 4 ++++ src/languages/zh-hans.ts | 4 ++++ 10 files changed, 40 insertions(+) diff --git a/src/languages/de.ts b/src/languages/de.ts index ecea954cc94c..afa2178c5432 100644 --- a/src/languages/de.ts +++ b/src/languages/de.ts @@ -11715,6 +11715,8 @@ Hier ist ein *Testbeleg*, um dir zu zeigen, wie es funktioniert:`, holdingTitle: 'Ausgaben werden zurückgehalten …', unholdingTitle: 'Zurückhalten von Ausgaben wird aufgehoben …', rejectingTitle: 'Ausgaben werden abgelehnt …', + deletingTitle: 'Berichte werden gelöscht …', + deletingExpensesTitle: 'Ausgaben werden gelöscht …', runningBody: 'Dies kann einige Minuten dauern. Sie können hier warten, oder Concierge kann Ihnen eine Nachricht senden, wenn es fertig ist.', sendFromConcierge: 'Mir eine Nachricht senden, wenn es fertig ist', conciergeTitle: 'Auf jeden Fall!', @@ -11726,6 +11728,8 @@ Hier ist ein *Testbeleg*, um dir zu zeigen, wie es funktioniert:`, heldTitle: ({count, total}: {count: number; total: number}) => `Ausgaben in ${count} von ${total} ${total === 1 ? 'Bericht' : 'Berichten'} zurückgehalten`, unheldTitle: ({count, total}: {count: number; total: number}) => `Zurückhalten von Ausgaben in ${count} von ${total} ${total === 1 ? 'Bericht' : 'Berichten'} aufgehoben`, rejectedTitle: ({count, total}: {count: number; total: number}) => `Ausgaben in ${count} von ${total} ${total === 1 ? 'Bericht' : 'Berichten'} abgelehnt`, + deletedTitle: ({count, total}: {count: number; total: number}) => `${count} von ${total} ${total === 1 ? 'Bericht' : 'Berichte'} gelöscht`, + deletedExpensesTitle: ({count, total}: {count: number; total: number}) => `Ausgaben in ${count} von ${total} ${total === 1 ? 'Bericht' : 'Berichten'} gelöscht`, noReportsTitle: 'Keine übereinstimmenden Berichte', noReportsBody: 'Keiner der von Ihnen ausgewählten Berichte benötigte diese Aktion.', failedReportsBody: ({count}: {count: number}) => (count === 1 ? '1 Bericht konnte nicht aktualisiert werden.' : `${count} Berichte konnten nicht aktualisiert werden.`), diff --git a/src/languages/el.ts b/src/languages/el.ts index 492f2717e6a1..d2007f100930 100644 --- a/src/languages/el.ts +++ b/src/languages/el.ts @@ -11957,6 +11957,8 @@ ${reportName}`, holdingTitle: 'Τα έξοδα τίθενται σε αναμονή...', unholdingTitle: 'Αφαιρείται η κράτηση των εξόδων...', rejectingTitle: 'Απόρριψη εξόδων...', + deletingTitle: 'Γίνεται διαγραφή αναφορών...', + deletingExpensesTitle: 'Γίνεται διαγραφή εξόδων...', runningBody: 'Αυτό μπορεί να πάρει μερικά λεπτά. Μπορείτε να περιμένετε εδώ ή ο Concierge μπορεί να σας στείλει μήνυμα όταν ολοκληρωθεί.', sendFromConcierge: 'Στείλτε μου μήνυμα όταν τελειώσει', conciergeTitle: 'Βεβαίως!', @@ -11968,6 +11970,8 @@ ${reportName}`, heldTitle: ({count, total}: {count: number; total: number}) => `Τέθηκαν σε αναμονή έξοδα σε ${count} από ${total} ${total === 1 ? 'αναφορά' : 'αναφορές'}`, unheldTitle: ({count, total}: {count: number; total: number}) => `Αφαιρέθηκε η κράτηση εξόδων σε ${count} από ${total} ${total === 1 ? 'αναφορά' : 'αναφορές'}`, rejectedTitle: ({count, total}: {count: number; total: number}) => `Απορρίφθηκαν έξοδα σε ${count} από ${total} ${total === 1 ? 'αναφορά' : 'αναφορές'}`, + deletedTitle: ({count, total}: {count: number; total: number}) => `Διαγράφηκαν ${count} από ${total} ${total === 1 ? 'αναφορά' : 'αναφορές'}`, + deletedExpensesTitle: ({count, total}: {count: number; total: number}) => `Διαγράφηκαν έξοδα σε ${count} από ${total} ${total === 1 ? 'αναφορά' : 'αναφορές'}`, noReportsTitle: 'Δεν υπάρχουν αντιστοιχίες αναφορών', noReportsBody: 'Καμία από τις αναφορές που επιλέξατε δεν χρειαζόταν αυτή την ενέργεια.', failedReportsBody: ({count}: {count: number}) => (count === 1 ? '1 αναφορά δεν μπόρεσε να ενημερωθεί.' : `${count} αναφορές δεν ήταν δυνατό να ενημερωθούν.`), diff --git a/src/languages/es.ts b/src/languages/es.ts index 7ee0a1ca50eb..586bc99f5ddd 100644 --- a/src/languages/es.ts +++ b/src/languages/es.ts @@ -11984,6 +11984,8 @@ ${reportName}`, holdingTitle: 'Reteniendo gastos...', unholdingTitle: 'Desbloqueando gastos...', rejectingTitle: 'Rechazando gastos...', + deletingTitle: 'Eliminando informes...', + deletingExpensesTitle: 'Eliminando gastos...', runningBody: 'Esto puede tardar unos minutos. Puedes esperar aquí o Concierge puede enviarte un mensaje cuando haya terminado.', sendFromConcierge: 'Envíame un mensaje cuando esté listo', conciergeTitle: '¡Por supuesto!', @@ -11995,6 +11997,8 @@ ${reportName}`, heldTitle: ({count, total}: {count: number; total: number}) => `Gastos retenidos en ${count} de ${total} ${total === 1 ? 'informe' : 'informes'}`, unheldTitle: ({count, total}: {count: number; total: number}) => `Gastos desbloqueados en ${count} de ${total} ${total === 1 ? 'informe' : 'informes'}`, rejectedTitle: ({count, total}: {count: number; total: number}) => `Gastos rechazados en ${count} de ${total} ${total === 1 ? 'informe' : 'informes'}`, + deletedTitle: ({count, total}: {count: number; total: number}) => `Eliminados ${count} de ${total} ${total === 1 ? 'informe' : 'informes'}`, + deletedExpensesTitle: ({count, total}: {count: number; total: number}) => `Gastos eliminados en ${count} de ${total} ${total === 1 ? 'informe' : 'informes'}`, noReportsTitle: 'No hay informes coincidentes', noReportsBody: 'Ninguno de los informes que seleccionaste necesitaba esta acción.', failedReportsBody: ({count}: {count: number}) => (count === 1 ? 'No se pudo actualizar 1 informe.' : `No se pudieron actualizar ${count} informes.`), diff --git a/src/languages/fr.ts b/src/languages/fr.ts index 69be3e0452eb..5f45730b306b 100644 --- a/src/languages/fr.ts +++ b/src/languages/fr.ts @@ -11743,6 +11743,8 @@ Voici un *reçu test* pour vous montrer comment ça fonctionne :`, holdingTitle: 'Mise en attente des dépenses...', unholdingTitle: 'Suppression de la mise en attente des dépenses...', rejectingTitle: 'Rejet des dépenses...', + deletingTitle: 'Suppression des notes de frais...', + deletingExpensesTitle: 'Suppression des dépenses...', runningBody: 'Cela peut prendre quelques minutes. Vous pouvez attendre ici ou Concierge peut vous envoyer un message lorsque ce sera terminé.', sendFromConcierge: 'Envoyez-moi un message quand ce sera fait', conciergeTitle: 'Bien sûr !', @@ -11754,6 +11756,8 @@ Voici un *reçu test* pour vous montrer comment ça fonctionne :`, heldTitle: ({count, total}: {count: number; total: number}) => `Dépenses mises en attente pour ${count} sur ${total} ${total === 1 ? 'note de frais' : 'notes de frais'}`, unheldTitle: ({count, total}: {count: number; total: number}) => `Mise en attente supprimée pour ${count} sur ${total} ${total === 1 ? 'note de frais' : 'notes de frais'}`, rejectedTitle: ({count, total}: {count: number; total: number}) => `Dépenses rejetées pour ${count} sur ${total} ${total === 1 ? 'note de frais' : 'notes de frais'}`, + deletedTitle: ({count, total}: {count: number; total: number}) => `Supprimé ${count} sur ${total} ${total === 1 ? 'note de frais' : 'notes de frais'}`, + deletedExpensesTitle: ({count, total}: {count: number; total: number}) => `Dépenses supprimées pour ${count} sur ${total} ${total === 1 ? 'note de frais' : 'notes de frais'}`, noReportsTitle: 'Aucune note de frais correspondante', noReportsBody: 'Aucune des notes de frais que vous avez sélectionnées n’avait besoin de cette action.', failedReportsBody: ({count}: {count: number}) => (count === 1 ? "1 note de frais n'a pas pu être mise à jour." : `${count} notes de frais n'ont pas pu être mises à jour.`), diff --git a/src/languages/it.ts b/src/languages/it.ts index 8ee3b1d0d938..6f0b7c8f80ba 100644 --- a/src/languages/it.ts +++ b/src/languages/it.ts @@ -11666,6 +11666,8 @@ Ecco una *ricevuta di prova* per mostrarti come funziona:`, holdingTitle: 'Messa in attesa delle spese in corso...', unholdingTitle: 'Rimozione del blocco delle spese in corso...', rejectingTitle: 'Rifiuto delle spese in corso...', + deletingTitle: 'Eliminazione dei report in corso...', + deletingExpensesTitle: 'Eliminazione delle spese in corso...', runningBody: 'Questo può richiedere alcuni minuti. Puoi aspettare qui oppure Concierge può mandarti un messaggio quando è tutto pronto.', sendFromConcierge: 'Scrivimi quando hai finito', conciergeTitle: 'Ci puoi contare!', @@ -11677,6 +11679,8 @@ Ecco una *ricevuta di prova* per mostrarti come funziona:`, heldTitle: ({count, total}: {count: number; total: number}) => `Spese messe in attesa in ${count} su ${total} report`, unheldTitle: ({count, total}: {count: number; total: number}) => `Blocco rimosso dalle spese in ${count} su ${total} report`, rejectedTitle: ({count, total}: {count: number; total: number}) => `Spese rifiutate in ${count} su ${total} report`, + deletedTitle: ({count, total}: {count: number; total: number}) => `Eliminati ${count} su ${total} report`, + deletedExpensesTitle: ({count, total}: {count: number; total: number}) => `Spese eliminate in ${count} su ${total} report`, noReportsTitle: 'Nessun report corrispondente', noReportsBody: 'Nessuno dei report che hai selezionato richiedeva questa azione.', failedReportsBody: ({count}: {count: number}) => (count === 1 ? '1 report non può essere aggiornato.' : `${count} report non hanno potuto essere aggiornati.`), diff --git a/src/languages/ja.ts b/src/languages/ja.ts index f3b570f1b673..8ca85907a69e 100644 --- a/src/languages/ja.ts +++ b/src/languages/ja.ts @@ -11497,6 +11497,8 @@ ${reportName}`, holdingTitle: '経費を保留にしています…', unholdingTitle: '経費の保留を解除しています…', rejectingTitle: '経費を却下しています…', + deletingTitle: 'レポートを削除しています…', + deletingExpensesTitle: '経費を削除しています…', runningBody: '数分かかる場合があります。ここでお待ちいただくか、完了したときに Concierge からメッセージを受け取ることもできます。', sendFromConcierge: '完了したらメッセージを送ってください', conciergeTitle: 'もちろんです!', @@ -11508,6 +11510,8 @@ ${reportName}`, heldTitle: ({count, total}: {count: number; total: number}) => `${total} 件中 ${count} 件のレポートの経費を保留にしました`, unheldTitle: ({count, total}: {count: number; total: number}) => `${total} 件中 ${count} 件のレポートの経費の保留を解除しました`, rejectedTitle: ({count, total}: {count: number; total: number}) => `${total} 件中 ${count} 件のレポートの経費を却下しました`, + deletedTitle: ({count, total}: {count: number; total: number}) => `${total} 件中 ${count} 件のレポートを削除しました`, + deletedExpensesTitle: ({count, total}: {count: number; total: number}) => `${total} 件中 ${count} 件のレポートの経費を削除しました`, noReportsTitle: '一致するレポートはありません', noReportsBody: '選択したレポートには、いずれもこの操作は必要ありませんでした。', failedReportsBody: ({count}: {count: number}) => (count === 1 ? '1件のレポートを更新できませんでした。' : `${count} 件のレポートを更新できませんでした。`), diff --git a/src/languages/nl.ts b/src/languages/nl.ts index a13da6f609c6..8f0c5bd6d509 100644 --- a/src/languages/nl.ts +++ b/src/languages/nl.ts @@ -11630,6 +11630,8 @@ Hier is een *proefbon* om je te laten zien hoe het werkt:`, holdingTitle: 'Uitgaven vasthouden...', unholdingTitle: 'Blokkering van uitgaven opheffen...', rejectingTitle: 'Uitgaven afwijzen...', + deletingTitle: 'Rapporten verwijderen...', + deletingExpensesTitle: 'Uitgaven verwijderen...', runningBody: 'Dit kan een paar minuten duren. Je kunt hier wachten, of Concierge kan je een bericht sturen als het klaar is.', sendFromConcierge: 'Stuur me een bericht als het klaar is', conciergeTitle: 'Zeker weten!', @@ -11641,6 +11643,8 @@ Hier is een *proefbon* om je te laten zien hoe het werkt:`, heldTitle: ({count, total}: {count: number; total: number}) => `Uitgaven vastgehouden in ${count} van ${total} ${total === 1 ? 'rapport' : 'rapporten'}`, unheldTitle: ({count, total}: {count: number; total: number}) => `Blokkering van uitgaven opgeheven in ${count} van ${total} ${total === 1 ? 'rapport' : 'rapporten'}`, rejectedTitle: ({count, total}: {count: number; total: number}) => `Uitgaven afgewezen in ${count} van ${total} ${total === 1 ? 'rapport' : 'rapporten'}`, + deletedTitle: ({count, total}: {count: number; total: number}) => `${count} van ${total} ${total === 1 ? 'rapport' : 'rapporten'} verwijderd`, + deletedExpensesTitle: ({count, total}: {count: number; total: number}) => `Uitgaven verwijderd in ${count} van ${total} ${total === 1 ? 'rapport' : 'rapporten'}`, noReportsTitle: 'Geen overeenkomende rapporten', noReportsBody: 'Geen van de rapporten die je hebt geselecteerd had deze actie nodig.', failedReportsBody: ({count}: {count: number}) => (count === 1 ? '1 rapport kon niet worden bijgewerkt.' : `${count} rapporten konden niet worden bijgewerkt.`), diff --git a/src/languages/pl.ts b/src/languages/pl.ts index 2fdd4036842f..1aa29f1fb9f7 100644 --- a/src/languages/pl.ts +++ b/src/languages/pl.ts @@ -11645,6 +11645,8 @@ Oto *paragon testowy*, żeby pokazać Ci, jak to działa:`, holdingTitle: 'Wstrzymywanie wydatków...', unholdingTitle: 'Usuwanie blokady wydatków...', rejectingTitle: 'Odrzucanie wydatków...', + deletingTitle: 'Usuwanie raportów...', + deletingExpensesTitle: 'Usuwanie wydatków...', runningBody: 'To może potrwać kilka minut. Możesz poczekać tutaj albo Concierge napisze do ciebie, kiedy będzie gotowe.', sendFromConcierge: 'Napisz do mnie, kiedy będzie gotowe', conciergeTitle: 'No jasne!', @@ -11656,6 +11658,8 @@ Oto *paragon testowy*, żeby pokazać Ci, jak to działa:`, heldTitle: ({count, total}: {count: number; total: number}) => `Wstrzymano wydatki w ${count} z ${total} ${total === 1 ? 'raportu' : 'raportów'}`, unheldTitle: ({count, total}: {count: number; total: number}) => `Usunięto blokadę wydatków w ${count} z ${total} ${total === 1 ? 'raportu' : 'raportów'}`, rejectedTitle: ({count, total}: {count: number; total: number}) => `Odrzucono wydatki w ${count} z ${total} ${total === 1 ? 'raportu' : 'raportów'}`, + deletedTitle: ({count, total}: {count: number; total: number}) => `Usunięto ${count} z ${total} ${total === 1 ? 'raportu' : 'raportów'}`, + deletedExpensesTitle: ({count, total}: {count: number; total: number}) => `Usunięto wydatki w ${count} z ${total} ${total === 1 ? 'raportu' : 'raportów'}`, noReportsTitle: 'Brak pasujących raportów', noReportsBody: 'Żaden z wybranych raportów nie wymagał tej akcji.', failedReportsBody: ({count}: {count: number}) => (count === 1 ? 'Nie udało się zaktualizować 1 raportu.' : `Nie udało się zaktualizować ${count} raportów.`), diff --git a/src/languages/pt-BR.ts b/src/languages/pt-BR.ts index ffcc2ef09f87..b20503519e98 100644 --- a/src/languages/pt-BR.ts +++ b/src/languages/pt-BR.ts @@ -11622,6 +11622,8 @@ Aqui está um *comprovante de teste* para mostrar como funciona:`, holdingTitle: 'Retendo despesas...', unholdingTitle: 'Removendo bloqueio das despesas...', rejectingTitle: 'Rejeitando despesas...', + deletingTitle: 'Excluindo relatórios...', + deletingExpensesTitle: 'Excluindo despesas...', runningBody: 'Isso pode levar alguns minutos. Você pode esperar aqui ou o Concierge pode te mandar uma mensagem quando terminar.', sendFromConcierge: 'Me avise quando terminar', conciergeTitle: 'Pode apostar!', @@ -11633,6 +11635,8 @@ Aqui está um *comprovante de teste* para mostrar como funciona:`, heldTitle: ({count, total}: {count: number; total: number}) => `Despesas retidas em ${count} de ${total} ${total === 1 ? 'relatório' : 'relatórios'}`, unheldTitle: ({count, total}: {count: number; total: number}) => `Bloqueio removido das despesas em ${count} de ${total} ${total === 1 ? 'relatório' : 'relatórios'}`, rejectedTitle: ({count, total}: {count: number; total: number}) => `Despesas rejeitadas em ${count} de ${total} ${total === 1 ? 'relatório' : 'relatórios'}`, + deletedTitle: ({count, total}: {count: number; total: number}) => `Excluído(s) ${count} de ${total} ${total === 1 ? 'relatório' : 'relatórios'}`, + deletedExpensesTitle: ({count, total}: {count: number; total: number}) => `Despesas excluídas em ${count} de ${total} ${total === 1 ? 'relatório' : 'relatórios'}`, noReportsTitle: 'Nenhum relatório correspondente', noReportsBody: 'Nenhum dos relatórios que você selecionou precisava dessa ação.', failedReportsBody: ({count}: {count: number}) => (count === 1 ? '1 relatório não pôde ser atualizado.' : `${count} relatórios não puderam ser atualizados.`), diff --git a/src/languages/zh-hans.ts b/src/languages/zh-hans.ts index da5f5e1b9e7e..c1cff14ca92f 100644 --- a/src/languages/zh-hans.ts +++ b/src/languages/zh-hans.ts @@ -11206,6 +11206,8 @@ ${reportName}`, holdingTitle: '正在暂挂报销费用…', unholdingTitle: '正在解除报销费用的保留…', rejectingTitle: '正在拒绝报销费用…', + deletingTitle: '正在删除报表…', + deletingExpensesTitle: '正在删除报销费用…', runningBody: '这可能需要几分钟。你可以在这里等待,或者等完成后由 Concierge 给你发送消息。', sendFromConcierge: '完成后给我发消息', conciergeTitle: '当然!', @@ -11217,6 +11219,8 @@ ${reportName}`, heldTitle: ({count, total}: {count: number; total: number}) => `已暂挂 ${total} 份报表中 ${count} 份的报销费用`, unheldTitle: ({count, total}: {count: number; total: number}) => `已解除 ${total} 份报表中 ${count} 份的报销费用保留`, rejectedTitle: ({count, total}: {count: number; total: number}) => `已拒绝 ${total} 份报表中 ${count} 份的报销费用`, + deletedTitle: ({count, total}: {count: number; total: number}) => `已删除 ${total} 份报表中的 ${count} 份`, + deletedExpensesTitle: ({count, total}: {count: number; total: number}) => `已删除 ${total} 份报表中 ${count} 份的报销费用`, noReportsTitle: '没有匹配的报表', noReportsBody: '您选择的报表都不需要执行此操作。', failedReportsBody: ({count}: {count: number}) => (count === 1 ? '1 份报表无法更新。' : `${count} 份报表无法更新。`), From 617e3bd142e30fbe6964a1c0aa6aef9b45e23e54 Mon Sep 17 00:00:00 2001 From: allgandaf Date: Sun, 4 Oct 2026 10:25:32 +0530 Subject: [PATCH 36/73] show delete in the bulk action modal --- src/components/BulkActionStatusModal.tsx | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/components/BulkActionStatusModal.tsx b/src/components/BulkActionStatusModal.tsx index fd8818fe356b..bb9d4d227ac1 100644 --- a/src/components/BulkActionStatusModal.tsx +++ b/src/components/BulkActionStatusModal.tsx @@ -33,6 +33,8 @@ const RUNNING_TITLES = { [CONST.SEARCH.BULK_ACTION_TYPES.HOLD]: 'bulkAction.holdingTitle', [CONST.SEARCH.BULK_ACTION_TYPES.UNHOLD]: 'bulkAction.unholdingTitle', [CONST.SEARCH.BULK_ACTION_TYPES.REJECT]: 'bulkAction.rejectingTitle', + [CONST.SEARCH.BULK_ACTION_TYPES.DELETE]: 'bulkAction.deletingTitle', + [CONST.BULK_ACTION.DELETE_EXPENSES]: 'bulkAction.deletingExpensesTitle', } as const satisfies Record; const DONE_TITLES = { @@ -42,6 +44,8 @@ const DONE_TITLES = { [CONST.SEARCH.BULK_ACTION_TYPES.HOLD]: 'bulkAction.heldTitle', [CONST.SEARCH.BULK_ACTION_TYPES.UNHOLD]: 'bulkAction.unheldTitle', [CONST.SEARCH.BULK_ACTION_TYPES.REJECT]: 'bulkAction.rejectedTitle', + [CONST.SEARCH.BULK_ACTION_TYPES.DELETE]: 'bulkAction.deletedTitle', + [CONST.BULK_ACTION.DELETE_EXPENSES]: 'bulkAction.deletedExpensesTitle', } as const satisfies Record; type BulkActionStatusModalProps = { From 2bc0f7603cde37d1e90b126a07180d3620c53c81 Mon Sep 17 00:00:00 2001 From: allgandaf Date: Sun, 4 Oct 2026 10:25:33 +0530 Subject: [PATCH 37/73] offer delete under select all --- src/hooks/useSearchBulkActions.ts | 37 ++++++++++++++++++++++++++++++- 1 file changed, 36 insertions(+), 1 deletion(-) diff --git a/src/hooks/useSearchBulkActions.ts b/src/hooks/useSearchBulkActions.ts index 719ee3dfafb7..1ff94fc5a228 100644 --- a/src/hooks/useSearchBulkActions.ts +++ b/src/hooks/useSearchBulkActions.ts @@ -35,6 +35,8 @@ import { getTotalFormattedAmount, isCurrencySupportWalletBulkPay, queueBulkApproveReports, + queueBulkDeleteExpenses, + queueBulkDeleteReports, queueBulkMarkAsExported, queueBulkPayReports, queueBulkSubmitReports, @@ -1413,6 +1415,22 @@ function useSearchBulkActions({queryJSON}: UseSearchBulkActionsParams) { if (result.action !== ModalActions.CONFIRM) { return; } + // "Select all" can cover more than is loaded, so hand the search query to the backend to delete every match. + if (areAllMatchingItemsSelected) { + const allMatchingQuery = queryJSON ? getAllMatchingExpenseActionQuery(queryJSON, excludedTransactions, currentSearchResults?.data) : undefined; + if (!allMatchingQuery) { + Log.info('[BulkDelete] Dropping bulk delete: an excluded row could not be resolved'); + return; + } + if (isExpenseReportType) { + queueBulkDeleteReports(allMatchingQuery.jsonQuery); + } else { + queueBulkDeleteExpenses(allMatchingQuery.jsonQuery, allMatchingQuery.excludedTransactionIDList); + } + clearSelectedTransactions(); + return; + } + const validTransactions = Object.fromEntries(Object.entries(allTransactions ?? {}).filter((entry): entry is [string, Transaction] => entry[1] !== undefined)); const searchData = searchResults?.data; if (isExpenseReportType) { @@ -1496,7 +1514,10 @@ function useSearchBulkActions({queryJSON}: UseSearchBulkActionsParams) { showConfirmModal, deleteModalTitle, deleteModalPrompt, - queryJSON?.groupBy, + areAllMatchingItemsSelected, + queryJSON, + excludedTransactions, + currentSearchResults?.data, translate, allTransactions, allTransactionViolations, @@ -2732,6 +2753,20 @@ function useSearchBulkActions({queryJSON}: UseSearchBulkActionsParams) { if (!isOffline && selectedTransactionsKeys.some((id) => selectedTransactions[id].canUnhold)) { allMatchingOptions.push(unholdOption); } + // The backend only deletes what the user can delete, so one deletable loaded item is enough to offer it. + const hasLoadedDeletableItem = + selectedReports.length && isExpenseReportType + ? selectedReports.some((report) => shouldShowDeleteOption(selectedTransactions, currentSearchResults?.data, accountID, rules, [report], queryJSON?.type)) + : selectedTransactionsKeys.some((id) => shouldShowDeleteOption({[id]: selectedTransactions[id]}, currentSearchResults?.data, accountID, rules, [], queryJSON?.type)); + if (!isOffline && hasLoadedDeletableItem) { + allMatchingOptions.push({ + icon: expensifyIcons.Trashcan, + text: translate('search.bulkActions.delete'), + value: CONST.SEARCH.BULK_ACTION_TYPES.DELETE, + shouldCloseModalOnSelect: true, + onSelected: handleDeleteSelectedTransactions, + }); + } allMatchingOptions.push(exportButtonOption); if (isExpenseReportSearch) { allMatchingOptions.push(downloadPDFOption); From eb489fe11cec94e2255150d205e8b6b63c04b9e6 Mon Sep 17 00:00:00 2001 From: allgandaf Date: Sun, 4 Oct 2026 10:25:33 +0530 Subject: [PATCH 38/73] test delete under select all --- tests/unit/hooks/useSearchBulkActionsTest.ts | 101 ++++++++++++++++++- 1 file changed, 100 insertions(+), 1 deletion(-) diff --git a/tests/unit/hooks/useSearchBulkActionsTest.ts b/tests/unit/hooks/useSearchBulkActionsTest.ts index a09d05a14344..115c8002cc7d 100644 --- a/tests/unit/hooks/useSearchBulkActionsTest.ts +++ b/tests/unit/hooks/useSearchBulkActionsTest.ts @@ -1,5 +1,6 @@ import {act, renderHook, waitFor} from '@testing-library/react-native'; +import {ModalActions} from '@components/Modal/Global/ModalContext'; import OnyxListItemProvider from '@components/OnyxListItemProvider'; import type {SearchQueryJSON, SelectedReports, SelectedTransactions} from '@components/Search/types'; @@ -9,12 +10,15 @@ import {approveMoneyRequest} from '@libs/actions/IOU/ReportWorkflow'; import { getExportTemplates, queueBulkApproveReports, + queueBulkDeleteExpenses, + queueBulkDeleteReports, queueBulkSubmitReports, queueBulkUnholdExpenses, queueExportSearchItemsToCSV, queueExportSearchWithTemplate, submitMoneyRequestOnSearch, } from '@libs/actions/Search'; +import type * as SearchUIUtils from '@libs/SearchUIUtils'; import CONST from '@src/CONST'; import ONYXKEYS from '@src/ONYXKEYS'; @@ -35,6 +39,8 @@ jest.mock('@libs/actions/Search', () => ({ queueExportSearchItemsToCSV: jest.fn(() => 'mock-export-id'), queueExportSearchWithTemplate: jest.fn(() => 'mock-template-export-id'), queueBulkApproveReports: jest.fn(), + queueBulkDeleteExpenses: jest.fn(), + queueBulkDeleteReports: jest.fn(), queueBulkSubmitReports: jest.fn(), queueBulkUnholdExpenses: jest.fn(), getSearchApproveOnyxData: jest.fn(() => ({})), @@ -121,9 +127,19 @@ jest.mock('@components/DelegateNoAccessModalProvider', () => ({ useDelegateNoAccessActions: () => ({showDelegateNoAccessModal: jest.fn()}), })); +jest.mock('@libs/SearchUIUtils', () => ({ + ...jest.requireActual('@libs/SearchUIUtils'), + shouldShowDeleteOption: jest.fn(() => true), +})); + +const mockShowConfirmModal = jest.fn(); jest.mock('@hooks/useConfirmModal', () => ({ __esModule: true, - default: () => ({showConfirmModal: jest.fn()}), + default: () => ({showConfirmModal: mockShowConfirmModal}), +})); +jest.mock('@libs/showConfirmModalAfterMoreMenuDismiss', () => ({ + __esModule: true, + default: (showConfirmModal: (options: unknown) => Promise, options: unknown) => showConfirmModal(options), })); jest.mock('@hooks/usePermissions', () => ({ @@ -866,3 +882,86 @@ describe('useSearchBulkActions - Hold, Unhold and Reject under Select all', () = expect(result.current.headerButtonsOptions.some((option) => option.value === CONST.SEARCH.BULK_ACTION_TYPES.UNHOLD)).toBe(false); }); }); + +describe('useSearchBulkActions - Delete under Select all', () => { + beforeAll(() => { + Onyx.init({keys: ONYXKEYS}); + }); + + beforeEach(async () => { + jest.clearAllMocks(); + mockIsOffline = false; + mockAreAllMatchingItemsSelected = true; + await Onyx.clear(); + mockSelectedTransactions = {tx1: makeSelectedTransaction()}; + mockExcludedTransactions = {}; + mockSelectedReports = []; + mockCurrentSearchResults = undefined; + mockGetExportTemplates.mockReturnValue({customTemplates: [], defaultTemplates: []}); + + await Onyx.merge(ONYXKEYS.SESSION, {accountID: CURRENT_USER_ACCOUNT_ID, email: 'test@example.com'}); + }); + + afterEach(async () => { + await Onyx.clear(); + }); + + it('queues a server-side delete of every matching report once the user confirms', async () => { + // Given "Select all" on a reports search and a user who confirms the delete + mockShowConfirmModal.mockResolvedValue({action: ModalActions.CONFIRM}); + const {result} = renderHook(() => useSearchBulkActions({queryJSON: expenseReportQueryJSON}), {wrapper: OnyxListItemProvider}); + + // When the user deletes the selection + await waitFor(() => { + expect(result.current.headerButtonsOptions.some((option) => option.value === CONST.SEARCH.BULK_ACTION_TYPES.DELETE)).toBe(true); + }); + const deleteOption = result.current.headerButtonsOptions.find((option) => option.value === CONST.SEARCH.BULK_ACTION_TYPES.DELETE); + await act(async () => { + await deleteOption?.onSelected?.(); + }); + + // Then the search is handed to the backend to delete the reports, not looped per loaded report + expect(queueBulkDeleteReports).toHaveBeenCalledWith(expect.any(String)); + expect(queueBulkDeleteExpenses).not.toHaveBeenCalled(); + expect(mockClearSelectedTransactions).toHaveBeenCalled(); + }); + + it('queues a server-side delete of every matching expense without the ones the user deselected', async () => { + // Given "Select all" on an expenses search with one expense deselected, and a user who confirms the delete + mockExcludedTransactions = {tx2: makeSelectedTransaction()}; + mockShowConfirmModal.mockResolvedValue({action: ModalActions.CONFIRM}); + const {result} = renderHook(() => useSearchBulkActions({queryJSON: baseQueryJSON}), {wrapper: OnyxListItemProvider}); + + // When the user deletes the selection + await waitFor(() => { + expect(result.current.headerButtonsOptions.some((option) => option.value === CONST.SEARCH.BULK_ACTION_TYPES.DELETE)).toBe(true); + }); + const deleteOption = result.current.headerButtonsOptions.find((option) => option.value === CONST.SEARCH.BULK_ACTION_TYPES.DELETE); + await act(async () => { + await deleteOption?.onSelected?.(); + }); + + // Then the search is handed to the backend with the deselected expense listed, so it is kept + expect(queueBulkDeleteExpenses).toHaveBeenCalledWith(expect.any(String), ['tx2']); + expect(queueBulkDeleteReports).not.toHaveBeenCalled(); + }); + + it('deletes nothing when the user cancels the confirmation', async () => { + // Given "Select all" and a user who cancels the delete confirmation + mockShowConfirmModal.mockResolvedValue({action: ModalActions.CLOSE}); + const {result} = renderHook(() => useSearchBulkActions({queryJSON: baseQueryJSON}), {wrapper: OnyxListItemProvider}); + + // When the user backs out + await waitFor(() => { + expect(result.current.headerButtonsOptions.some((option) => option.value === CONST.SEARCH.BULK_ACTION_TYPES.DELETE)).toBe(true); + }); + const deleteOption = result.current.headerButtonsOptions.find((option) => option.value === CONST.SEARCH.BULK_ACTION_TYPES.DELETE); + await act(async () => { + await deleteOption?.onSelected?.(); + }); + + // Then nothing is queued + expect(queueBulkDeleteExpenses).not.toHaveBeenCalled(); + expect(queueBulkDeleteReports).not.toHaveBeenCalled(); + }); +}); From 8702e627590392bd3f2d6e2116530f434de88c3a Mon Sep 17 00:00:00 2001 From: allgandaf Date: Sat, 17 Oct 2026 11:02:45 +0530 Subject: [PATCH 39/73] restore main's action bundles --- .../isDeployChecklistLocked/index.js | 305 ++++++++++-------- .../javascript/proposalPoliceComment/index.js | 305 ++++++++++-------- 2 files changed, 330 insertions(+), 280 deletions(-) diff --git a/.github/actions/javascript/isDeployChecklistLocked/index.js b/.github/actions/javascript/isDeployChecklistLocked/index.js index 9321db05e6d7..cfe1ac778241 100644 --- a/.github/actions/javascript/isDeployChecklistLocked/index.js +++ b/.github/actions/javascript/isDeployChecklistLocked/index.js @@ -3432,6 +3432,7 @@ var require_CONST = __commonJS({ REPLACE_CARD: "replace_card", SHIP_CARD: "ship_card", REPORT_CARD_FRAUD: "report_card_fraud", + APPROVE_DIGITAL_WALLET: "approve_digital_wallet", ISSUE_CARD: "issue_card", UPDATE_CARD: "update_card", UPDATE_PERSONAL_DETAILS: "update_personal_details", @@ -22075,6 +22076,117 @@ var require_str = __commonJS({ } return parameter; } + function compare(strA, strB) { + if (strA < strB) { + return -1; + } + if (strA > strB) { + return 1; + } + return 0; + } + function caseInsensitiveCompare(strA, strB) { + const lowerCaseStrA = strA.toLocaleLowerCase(); + const lowerCaseStrB = strB.toLocaleLowerCase(); + return compare(lowerCaseStrA, lowerCaseStrB); + } + function contains(haystack, needle) { + return haystack.indexOf(needle) !== -1; + } + function cutAfter(str, substr) { + const index = str.indexOf(substr); + if (index !== -1) { + return str.substring(0, index); + } + return str; + } + function cutBefore(str, substr) { + const index = str.indexOf(substr); + if (index !== -1) { + return str.substring(index + substr.length); + } + return str; + } + function extractEmailDomain(email) { + return cutBefore(email, "@"); + } + function getExtension(url) { + var _a, _b; + if (typeof url !== "string") { + Log_1.default.warn("Str.getExtension: url is not a string", { url }); + return void 0; + } + return (_b = (_a = url.split(".").pop()) === null || _a === void 0 ? void 0 : _a.split("?")[0]) === null || _b === void 0 ? void 0 : _b.toLowerCase(); + } + function getRawByteSize(inputChar) { + const onlyChar = String(inputChar); + const c = onlyChar.charCodeAt(0); + if (c < 1 << 7) { + return 1; + } + if (c < 1 << 11) { + return 2; + } + if (c < 1 << 16) { + return 3; + } + if (c < 1 << 21) { + return 4; + } + if (c < 1 << 26) { + return 5; + } + if (c < 1 << 31) { + return 6; + } + return Number.NaN; + } + function htmlDecode(s) { + return HtmlEntities.decode(s); + } + function htmlEncode(s) { + return HtmlEntities.encode(s); + } + function isTypeOf(obj, type) { + return Object.prototype.toString.call(obj) === `[object ${type}]`; + } + function isNumber(obj) { + return isTypeOf(obj, "Number"); + } + function isString(obj) { + return isTypeOf(obj, "String"); + } + function isUndefined(obj) { + return obj === void 0; + } + function isValidE164Phone(phone) { + return Constants.CONST.SMS.E164_REGEX.test(phone); + } + function isValidEmail(str) { + if (!str || typeof str !== "string") { + return false; + } + const unicodeVersion = punycode_1.default.toUnicode(str); + if (String(unicodeVersion).match(Constants.CONST.REG_EXP.EMOJI_RULE)) { + return false; + } + return !!String(str).match(Constants.CONST.REG_EXP.EMAIL); + } + function maskFirstNCharacters(str, num, mask) { + if (!isString(str) || !isString(mask) || str.length === 0 || !isNumber(num)) { + return str; + } + return str.substring(0, num).replaceAll(/./g, mask) + str.substring(num); + } + function removeSMSDomain(text) { + return text.replaceAll(REMOVE_SMS_DOMAIN_PATTERN, ""); + } + function removeTrailingComma(str) { + return str.trim().replaceAll(/(,$)/g, ""); + } + function startsWith(haystack, needle) { + return isString(haystack) && isString(needle) && haystack.substring(0, needle.length) === needle; + } var Str2 = { /** * Return true if the string is ending with the provided suffix @@ -22132,18 +22244,14 @@ var require_str = __commonJS({ * @param s The string to decode. * @returns The decoded string. */ - htmlDecode(s) { - return HtmlEntities.decode(s); - }, + htmlDecode, /** * HTML encodes the given string. * * @param s The string to encode. * @return string @p s HTML encoded. */ - htmlEncode(s) { - return HtmlEntities.encode(s); - }, + htmlEncode, /** * Decodes the given HTML encoded string. * @@ -22185,7 +22293,7 @@ var require_str = __commonJS({ * @returns True when first === second, ignoring HTML encoding */ htmlEncodingInsensitiveEquals(first, second) { - return first === second || this.htmlDecode(first) === second || this.htmlEncode(first) === second; + return first === second || htmlDecode(first) === second || htmlEncode(first) === second; }, /** * Creates an ID that can be used as an HTML attribute from @p str. @@ -22268,36 +22376,14 @@ var require_str = __commonJS({ * one. * @returns Byte size of the character */ - getRawByteSize(inputChar) { - const onlyChar = String(inputChar); - const c = onlyChar.charCodeAt(0); - if (c < 1 << 7) { - return 1; - } - if (c < 1 << 11) { - return 2; - } - if (c < 1 << 16) { - return 3; - } - if (c < 1 << 21) { - return 4; - } - if (c < 1 << 26) { - return 5; - } - if (c < 1 << 31) { - return 6; - } - return Number.NaN; - }, + getRawByteSize, /** * Gets the length of a string in bytes, including non-ASCII characters * @returns The number of bytes used by string */ getByteLength(input) { const stringInput = String(input); - const byteLength = Array.from(stringInput).reduce((acc, char) => acc + this.getRawByteSize(char), 0); + const byteLength = Array.from(stringInput).reduce((acc, char) => acc + getRawByteSize(char), 0); return byteLength; }, /** @@ -22309,7 +22395,7 @@ var require_str = __commonJS({ const stringInput = String(input); let totalByteLength = 0; for (let i = 0; i < stringInput.length; i++) { - const charByteSize = this.getRawByteSize(stringInput[i]); + const charByteSize = getRawByteSize(stringInput[i]); if (charByteSize + totalByteLength > maxSize) { return `${stringInput.substr(0, i - 3)}...`; } @@ -22324,9 +22410,7 @@ var require_str = __commonJS({ * @param needle The case-sensitive string to search for * @returns True if the haystack starts with the needle. */ - startsWith(haystack, needle) { - return this.isString(haystack) && this.isString(needle) && haystack.substring(0, needle.length) === needle; - }, + startsWith, /** * Gets the textual value of the given string. * @@ -22334,7 +22418,7 @@ var require_str = __commonJS({ * @returns The text from within the HTML string. */ stripHTML(str) { - if (!this.isString(str)) { + if (!isString(str)) { return ""; } return str.replaceAll(/<[^>]*>?/gm, ""); @@ -22357,13 +22441,7 @@ var require_str = __commonJS({ * @param substr The substring to search for. * @returns The cut/trimmed string. */ - cutAfter(str, substr) { - const index = str.indexOf(substr); - if (index !== -1) { - return str.substring(0, index); - } - return str; - }, + cutAfter, /** * Returns a string containing all the characters str from after the first * occurrence of substr to the end of the string. @@ -22373,13 +22451,7 @@ var require_str = __commonJS({ * @param substr The substring to search for. * @returns The cut/trimmed string. */ - cutBefore(str, substr) { - const index = str.indexOf(substr); - if (index !== -1) { - return str.substring(index + substr.length); - } - return str; - }, + cutBefore, /** * Checks that the string is a domain name (e.g. example.com) * @@ -22406,16 +22478,7 @@ var require_str = __commonJS({ * * @returns True if the string is an email */ - isValidEmail(str) { - if (!str || typeof str !== "string") { - return false; - } - const unicodeVersion = punycode_1.default.toUnicode(str); - if (String(unicodeVersion).match(Constants.CONST.REG_EXP.EMOJI_RULE)) { - return false; - } - return !!String(str).match(Constants.CONST.REG_EXP.EMAIL); - }, + isValidEmail, /** * Checks if the string is an valid email address formed during comment markdown formation. * @@ -22433,9 +22496,7 @@ var require_str = __commonJS({ * * @returns string with the trailing comma removed */ - removeTrailingComma(str) { - return str.trim().replaceAll(/(,$)/g, ""); - }, + removeTrailingComma, /** * Checks that the string is a list of coma separated email addresss. * @@ -22444,12 +22505,12 @@ var require_str = __commonJS({ * @returns True if all emails are valid or if input is empty */ areValidEmails(str) { - const string = this.removeTrailingComma(str); + const string = removeTrailingComma(str); if (string === "") { return true; } const emails = string.split(","); - const result = emails.every((email) => this.isValidEmail(email.trim())); + const result = emails.every((email) => isValidEmail(email.trim())); return result; }, /** @@ -22466,9 +22527,7 @@ var require_str = __commonJS({ * * @returns The domain name in the email address. */ - extractEmailDomain(email) { - return this.cutBefore(email, "@"); - }, + extractEmailDomain, /** * Tries to extract the company name from the given email address * (e.g. "yelp" for "joe@yelp.co.uk"). @@ -22478,7 +22537,7 @@ var require_str = __commonJS({ * @returns The company name in the email address or null. */ extractCompanyNameFromEmailDomain(email) { - const domain = this.extractEmailDomain(email); + const domain = extractEmailDomain(email); if (!domain) { return null; } @@ -22497,7 +22556,7 @@ var require_str = __commonJS({ * @returns The local part in the email address. */ extractEmailLocalPart(email) { - return this.cutAfter(email, "@"); + return cutAfter(email, "@"); }, /** * Sanitize phone number to return only numbers. Return null if non valid phone number. @@ -22555,13 +22614,13 @@ var require_str = __commonJS({ * @returns true if the length is in the range, false otherwise */ isOfLength(str, minimumLength, maximumLength) { - if (!this.isString(str)) { + if (!isString(str)) { return false; } if (str.length < minimumLength) { return false; } - if (!this.isUndefined(maximumLength) && str.length > maximumLength) { + if (!isUndefined(maximumLength) && str.length > maximumLength) { return false; } return true; @@ -22614,9 +22673,7 @@ var require_str = __commonJS({ * * @returns Returns true if the haystack contains the needle */ - contains(haystack, needle) { - return haystack.indexOf(needle) !== -1; - }, + contains, /** * Returns true if the haystack contains the needle, ignoring case * @@ -22626,7 +22683,7 @@ var require_str = __commonJS({ * @returns Returns true if the haystack contains the needle, ignoring case */ caseInsensitiveContains(haystack, needle) { - return this.contains(haystack.toLowerCase(), needle.toLowerCase()); + return contains(haystack.toLowerCase(), needle.toLowerCase()); }, /** * Case insensitive compare function @@ -22638,11 +22695,7 @@ var require_str = __commonJS({ * 1 if first string > second string * 0 if first string = second string */ - caseInsensitiveCompare(strA, strB) { - const lowerCaseStrA = strA.toLocaleLowerCase(); - const lowerCaseStrB = strB.toLocaleLowerCase(); - return this.compare(lowerCaseStrA, lowerCaseStrB); - }, + caseInsensitiveCompare, /** * Case insensitive equals * @@ -22651,7 +22704,7 @@ var require_str = __commonJS({ * @returns true when first == second except for case */ caseInsensitiveEquals(strA, strB) { - return this.caseInsensitiveCompare(strA, strB) === 0; + return caseInsensitiveCompare(strA, strB) === 0; }, /** * Compare function @@ -22663,15 +22716,7 @@ var require_str = __commonJS({ * 1 if first string > second string * 0 if first string = second string */ - compare(strA, strB) { - if (strA < strB) { - return -1; - } - if (strA > strB) { - return 1; - } - return 0; - }, + compare, /** * Check if a file extension is supported by SmartReports */ @@ -22690,45 +22735,37 @@ var require_str = __commonJS({ const accountNumber = String(num); const len = accountNumber.length; if (len < 6 || len > 20) { - return this.maskFirstNCharacters(accountNumber, len, "X"); + return maskFirstNCharacters(accountNumber, len, "X"); } if (len < 14) { - return this.maskFirstNCharacters(accountNumber, len - 4, "X"); + return maskFirstNCharacters(accountNumber, len - 4, "X"); } const first = accountNumber.substr(0, 6); const last = accountNumber.substr(7); - const masked = this.maskFirstNCharacters(last, len - 11, "X"); + const masked = maskFirstNCharacters(last, len - 11, "X"); return `${first}${masked}`; }, /** * Checks if something is a string * Stolen from underscore */ - isString(obj) { - return this.isTypeOf(obj, "String"); - }, + isString, /** * Checks if something is a number * Stolen from underscore * @param obj */ - isNumber(obj) { - return this.isTypeOf(obj, "Number"); - }, + isNumber, /** * Checks if something is a certain type * Stolen from underscore */ - isTypeOf(obj, type) { - return Object.prototype.toString.call(obj) === `[object ${type}]`; - }, + isTypeOf, /** * Checks to see if something is undefined * Stolen from underscore */ - isUndefined(obj) { - return obj === void 0; - }, + isUndefined, /** * Replace first N characters of the string with maskChar * eg: maskFirstNCharacters( '1234567890', 6, 'X' ) yields XXXXXX7890 @@ -22737,12 +22774,7 @@ var require_str = __commonJS({ * @param mask String we want replace the first N chars with * @returns Masked string */ - maskFirstNCharacters(str, num, mask) { - if (!this.isString(str) || !this.isString(mask) || str.length === 0 || !this.isNumber(num)) { - return str; - } - return str.substring(0, num).replaceAll(/./g, mask) + str.substring(num); - }, + maskFirstNCharacters, /** * Trim a string */ @@ -22754,7 +22786,7 @@ var require_str = __commonJS({ * @param percentageString The percentage as a string */ percentageStringToNumber(percentageString) { - return Number(this.cutAfter(percentageString, "%")); + return Number(cutAfter(percentageString, "%")); }, /** * Remove all the spaces from a string @@ -22798,7 +22830,7 @@ var require_str = __commonJS({ * Converts a value to boolean, case-insensitive. */ toBool(value) { - if (this.isString(value)) { + if (isString(value)) { return value.toLowerCase() === "true"; } return !!value; @@ -22848,9 +22880,7 @@ var require_str = __commonJS({ /** * Check for whether a phone number is valid according to E.164 standard. */ - isValidE164Phone(phone) { - return Constants.CONST.SMS.E164_REGEX.test(phone); - }, + isValidE164Phone, /** * Check for whether a phone number is valid in different formats/standards. For example: * significant: 4404589784 @@ -22876,14 +22906,12 @@ var require_str = __commonJS({ /** * Returns text without our SMS domain */ - removeSMSDomain(text) { - return text.replaceAll(REMOVE_SMS_DOMAIN_PATTERN, ""); - }, + removeSMSDomain, /** * Returns true if the text is a valid E.164 phone number with our SMS domain removed */ isSMSLogin(text) { - return this.isValidE164Phone(this.removeSMSDomain(text)); + return isValidE164Phone(removeSMSDomain(text)); }, /** * This method will return all matches of a single regex like preg_match_all() in PHP. This is not a common part of @@ -22936,7 +22964,7 @@ var require_str = __commonJS({ return url; } const website = match[3] ? match[2] : `${defaultScheme}://${match[2]}`; - return website.toLowerCase() + this.cutBefore(match[1], match[2]); + return website.toLowerCase() + cutBefore(match[1], match[2]); }, /** * Checks if parameter is a string or function @@ -22948,14 +22976,7 @@ var require_str = __commonJS({ * Get file extension for a given url with or * without query parameters */ - getExtension(url) { - var _a, _b; - if (typeof url !== "string") { - Log_1.default.warn("Str.getExtension: url is not a string", { url }); - return void 0; - } - return (_b = (_a = url.split(".").pop()) === null || _a === void 0 ? void 0 : _a.split("?")[0]) === null || _b === void 0 ? void 0 : _b.toLowerCase(); - }, + getExtension, /** * Takes in a URL and checks if the file extension is PDF * @@ -22963,7 +22984,7 @@ var require_str = __commonJS({ * @returns Whether file path is PDF or not */ isPDF(url) { - return this.getExtension(url) === "pdf"; + return getExtension(url) === "pdf"; }, /** * Takes in a URL and checks if the file extension is an image @@ -22974,7 +22995,7 @@ var require_str = __commonJS({ * https://reactnative.dev/docs/image#source */ isImage(url) { - const extension = this.getExtension(url); + const extension = getExtension(url); if (!extension) { return false; } @@ -22990,7 +23011,7 @@ var require_str = __commonJS({ * https://developer.mozilla.org/en-US/docs/Web/Media/Formats/Video_codecs */ isVideo(url) { - const extension = this.getExtension(url); + const extension = getExtension(url); if (!extension) { return false; } @@ -23003,7 +23024,7 @@ var require_str = __commonJS({ * @returns True if is a domain account email, otherwise false. */ isDomainEmail(email) { - return this.startsWith(email, "+@"); + return startsWith(email, "+@"); }, /** * Find the minimum indentation of any line in the string, @@ -24141,13 +24162,17 @@ ${g2} }, { name: "anchor", - regex: /<(a)[^><]*href\s*=\s*(['"])(.*?)\2(?:".*?"|'.*?'|[^'"><])*>([\s\S]*?)<\/\1>(?![^<]*(<\/pre>|<\/code>))/gi, - replacement: (_extras, _match, _g1, _g2, g3, g4) => { - const email = g3.startsWith("mailto:") ? g3.slice(7) : ""; - if (email === g4) { - return email; + regex: /(\]\()?<(a)[^><]*href\s*=\s*(['"])(.*?)\3(?:".*?"|'.*?'|[^'"><])*>([\s\S]*?)<\/\2>(?![^<]*(<\/pre>|<\/code>))/gi, + replacement: (_extras, _match, g1, _g2, _g3, g4, g5) => { + const incompleteLinkStart = g1 !== null && g1 !== void 0 ? g1 : ""; + const email = g4.startsWith("mailto:") ? g4.slice(7) : ""; + if (email === g5) { + return `${incompleteLinkStart}${email}`; + } + if (incompleteLinkStart && (g4 === g5 || g4 === `https://${g5}`)) { + return `${incompleteLinkStart}${g5}`; } - return `[${g4}](${email || g3})`; + return `${incompleteLinkStart}[${g5}](${email || g4})`; } }, { diff --git a/.github/actions/javascript/proposalPoliceComment/index.js b/.github/actions/javascript/proposalPoliceComment/index.js index beb367dd3ebd..58a12c5fb27a 100644 --- a/.github/actions/javascript/proposalPoliceComment/index.js +++ b/.github/actions/javascript/proposalPoliceComment/index.js @@ -24691,6 +24691,7 @@ var require_CONST = __commonJS({ REPLACE_CARD: "replace_card", SHIP_CARD: "ship_card", REPORT_CARD_FRAUD: "report_card_fraud", + APPROVE_DIGITAL_WALLET: "approve_digital_wallet", ISSUE_CARD: "issue_card", UPDATE_CARD: "update_card", UPDATE_PERSONAL_DETAILS: "update_personal_details", @@ -43334,6 +43335,117 @@ var require_str = __commonJS({ } return parameter; } + function compare(strA, strB) { + if (strA < strB) { + return -1; + } + if (strA > strB) { + return 1; + } + return 0; + } + function caseInsensitiveCompare(strA, strB) { + const lowerCaseStrA = strA.toLocaleLowerCase(); + const lowerCaseStrB = strB.toLocaleLowerCase(); + return compare(lowerCaseStrA, lowerCaseStrB); + } + function contains(haystack, needle) { + return haystack.indexOf(needle) !== -1; + } + function cutAfter(str2, substr) { + const index = str2.indexOf(substr); + if (index !== -1) { + return str2.substring(0, index); + } + return str2; + } + function cutBefore(str2, substr) { + const index = str2.indexOf(substr); + if (index !== -1) { + return str2.substring(index + substr.length); + } + return str2; + } + function extractEmailDomain(email) { + return cutBefore(email, "@"); + } + function getExtension(url) { + var _a3, _b; + if (typeof url !== "string") { + Log_1.default.warn("Str.getExtension: url is not a string", { url }); + return void 0; + } + return (_b = (_a3 = url.split(".").pop()) === null || _a3 === void 0 ? void 0 : _a3.split("?")[0]) === null || _b === void 0 ? void 0 : _b.toLowerCase(); + } + function getRawByteSize(inputChar) { + const onlyChar = String(inputChar); + const c = onlyChar.charCodeAt(0); + if (c < 1 << 7) { + return 1; + } + if (c < 1 << 11) { + return 2; + } + if (c < 1 << 16) { + return 3; + } + if (c < 1 << 21) { + return 4; + } + if (c < 1 << 26) { + return 5; + } + if (c < 1 << 31) { + return 6; + } + return Number.NaN; + } + function htmlDecode(s) { + return HtmlEntities.decode(s); + } + function htmlEncode(s) { + return HtmlEntities.encode(s); + } + function isTypeOf(obj, type) { + return Object.prototype.toString.call(obj) === `[object ${type}]`; + } + function isNumber(obj) { + return isTypeOf(obj, "Number"); + } + function isString(obj) { + return isTypeOf(obj, "String"); + } + function isUndefined(obj) { + return obj === void 0; + } + function isValidE164Phone(phone) { + return Constants.CONST.SMS.E164_REGEX.test(phone); + } + function isValidEmail(str2) { + if (!str2 || typeof str2 !== "string") { + return false; + } + const unicodeVersion = punycode_1.default.toUnicode(str2); + if (String(unicodeVersion).match(Constants.CONST.REG_EXP.EMOJI_RULE)) { + return false; + } + return !!String(str2).match(Constants.CONST.REG_EXP.EMAIL); + } + function maskFirstNCharacters(str2, num, mask) { + if (!isString(str2) || !isString(mask) || str2.length === 0 || !isNumber(num)) { + return str2; + } + return str2.substring(0, num).replaceAll(/./g, mask) + str2.substring(num); + } + function removeSMSDomain(text) { + return text.replaceAll(REMOVE_SMS_DOMAIN_PATTERN, ""); + } + function removeTrailingComma(str2) { + return str2.trim().replaceAll(/(,$)/g, ""); + } + function startsWith(haystack, needle) { + return isString(haystack) && isString(needle) && haystack.substring(0, needle.length) === needle; + } var Str6 = { /** * Return true if the string is ending with the provided suffix @@ -43391,18 +43503,14 @@ var require_str = __commonJS({ * @param s The string to decode. * @returns The decoded string. */ - htmlDecode(s) { - return HtmlEntities.decode(s); - }, + htmlDecode, /** * HTML encodes the given string. * * @param s The string to encode. * @return string @p s HTML encoded. */ - htmlEncode(s) { - return HtmlEntities.encode(s); - }, + htmlEncode, /** * Decodes the given HTML encoded string. * @@ -43444,7 +43552,7 @@ var require_str = __commonJS({ * @returns True when first === second, ignoring HTML encoding */ htmlEncodingInsensitiveEquals(first, second) { - return first === second || this.htmlDecode(first) === second || this.htmlEncode(first) === second; + return first === second || htmlDecode(first) === second || htmlEncode(first) === second; }, /** * Creates an ID that can be used as an HTML attribute from @p str. @@ -43527,36 +43635,14 @@ var require_str = __commonJS({ * one. * @returns Byte size of the character */ - getRawByteSize(inputChar) { - const onlyChar = String(inputChar); - const c = onlyChar.charCodeAt(0); - if (c < 1 << 7) { - return 1; - } - if (c < 1 << 11) { - return 2; - } - if (c < 1 << 16) { - return 3; - } - if (c < 1 << 21) { - return 4; - } - if (c < 1 << 26) { - return 5; - } - if (c < 1 << 31) { - return 6; - } - return Number.NaN; - }, + getRawByteSize, /** * Gets the length of a string in bytes, including non-ASCII characters * @returns The number of bytes used by string */ getByteLength(input) { const stringInput = String(input); - const byteLength = Array.from(stringInput).reduce((acc, char) => acc + this.getRawByteSize(char), 0); + const byteLength = Array.from(stringInput).reduce((acc, char) => acc + getRawByteSize(char), 0); return byteLength; }, /** @@ -43568,7 +43654,7 @@ var require_str = __commonJS({ const stringInput = String(input); let totalByteLength = 0; for (let i = 0; i < stringInput.length; i++) { - const charByteSize = this.getRawByteSize(stringInput[i]); + const charByteSize = getRawByteSize(stringInput[i]); if (charByteSize + totalByteLength > maxSize) { return `${stringInput.substr(0, i - 3)}...`; } @@ -43583,9 +43669,7 @@ var require_str = __commonJS({ * @param needle The case-sensitive string to search for * @returns True if the haystack starts with the needle. */ - startsWith(haystack, needle) { - return this.isString(haystack) && this.isString(needle) && haystack.substring(0, needle.length) === needle; - }, + startsWith, /** * Gets the textual value of the given string. * @@ -43593,7 +43677,7 @@ var require_str = __commonJS({ * @returns The text from within the HTML string. */ stripHTML(str2) { - if (!this.isString(str2)) { + if (!isString(str2)) { return ""; } return str2.replaceAll(/<[^>]*>?/gm, ""); @@ -43616,13 +43700,7 @@ var require_str = __commonJS({ * @param substr The substring to search for. * @returns The cut/trimmed string. */ - cutAfter(str2, substr) { - const index = str2.indexOf(substr); - if (index !== -1) { - return str2.substring(0, index); - } - return str2; - }, + cutAfter, /** * Returns a string containing all the characters str from after the first * occurrence of substr to the end of the string. @@ -43632,13 +43710,7 @@ var require_str = __commonJS({ * @param substr The substring to search for. * @returns The cut/trimmed string. */ - cutBefore(str2, substr) { - const index = str2.indexOf(substr); - if (index !== -1) { - return str2.substring(index + substr.length); - } - return str2; - }, + cutBefore, /** * Checks that the string is a domain name (e.g. example.com) * @@ -43665,16 +43737,7 @@ var require_str = __commonJS({ * * @returns True if the string is an email */ - isValidEmail(str2) { - if (!str2 || typeof str2 !== "string") { - return false; - } - const unicodeVersion = punycode_1.default.toUnicode(str2); - if (String(unicodeVersion).match(Constants.CONST.REG_EXP.EMOJI_RULE)) { - return false; - } - return !!String(str2).match(Constants.CONST.REG_EXP.EMAIL); - }, + isValidEmail, /** * Checks if the string is an valid email address formed during comment markdown formation. * @@ -43692,9 +43755,7 @@ var require_str = __commonJS({ * * @returns string with the trailing comma removed */ - removeTrailingComma(str2) { - return str2.trim().replaceAll(/(,$)/g, ""); - }, + removeTrailingComma, /** * Checks that the string is a list of coma separated email addresss. * @@ -43703,12 +43764,12 @@ var require_str = __commonJS({ * @returns True if all emails are valid or if input is empty */ areValidEmails(str2) { - const string = this.removeTrailingComma(str2); + const string = removeTrailingComma(str2); if (string === "") { return true; } const emails = string.split(","); - const result = emails.every((email) => this.isValidEmail(email.trim())); + const result = emails.every((email) => isValidEmail(email.trim())); return result; }, /** @@ -43725,9 +43786,7 @@ var require_str = __commonJS({ * * @returns The domain name in the email address. */ - extractEmailDomain(email) { - return this.cutBefore(email, "@"); - }, + extractEmailDomain, /** * Tries to extract the company name from the given email address * (e.g. "yelp" for "joe@yelp.co.uk"). @@ -43737,7 +43796,7 @@ var require_str = __commonJS({ * @returns The company name in the email address or null. */ extractCompanyNameFromEmailDomain(email) { - const domain = this.extractEmailDomain(email); + const domain = extractEmailDomain(email); if (!domain) { return null; } @@ -43756,7 +43815,7 @@ var require_str = __commonJS({ * @returns The local part in the email address. */ extractEmailLocalPart(email) { - return this.cutAfter(email, "@"); + return cutAfter(email, "@"); }, /** * Sanitize phone number to return only numbers. Return null if non valid phone number. @@ -43814,13 +43873,13 @@ var require_str = __commonJS({ * @returns true if the length is in the range, false otherwise */ isOfLength(str2, minimumLength, maximumLength) { - if (!this.isString(str2)) { + if (!isString(str2)) { return false; } if (str2.length < minimumLength) { return false; } - if (!this.isUndefined(maximumLength) && str2.length > maximumLength) { + if (!isUndefined(maximumLength) && str2.length > maximumLength) { return false; } return true; @@ -43873,9 +43932,7 @@ var require_str = __commonJS({ * * @returns Returns true if the haystack contains the needle */ - contains(haystack, needle) { - return haystack.indexOf(needle) !== -1; - }, + contains, /** * Returns true if the haystack contains the needle, ignoring case * @@ -43885,7 +43942,7 @@ var require_str = __commonJS({ * @returns Returns true if the haystack contains the needle, ignoring case */ caseInsensitiveContains(haystack, needle) { - return this.contains(haystack.toLowerCase(), needle.toLowerCase()); + return contains(haystack.toLowerCase(), needle.toLowerCase()); }, /** * Case insensitive compare function @@ -43897,11 +43954,7 @@ var require_str = __commonJS({ * 1 if first string > second string * 0 if first string = second string */ - caseInsensitiveCompare(strA, strB) { - const lowerCaseStrA = strA.toLocaleLowerCase(); - const lowerCaseStrB = strB.toLocaleLowerCase(); - return this.compare(lowerCaseStrA, lowerCaseStrB); - }, + caseInsensitiveCompare, /** * Case insensitive equals * @@ -43910,7 +43963,7 @@ var require_str = __commonJS({ * @returns true when first == second except for case */ caseInsensitiveEquals(strA, strB) { - return this.caseInsensitiveCompare(strA, strB) === 0; + return caseInsensitiveCompare(strA, strB) === 0; }, /** * Compare function @@ -43922,15 +43975,7 @@ var require_str = __commonJS({ * 1 if first string > second string * 0 if first string = second string */ - compare(strA, strB) { - if (strA < strB) { - return -1; - } - if (strA > strB) { - return 1; - } - return 0; - }, + compare, /** * Check if a file extension is supported by SmartReports */ @@ -43949,45 +43994,37 @@ var require_str = __commonJS({ const accountNumber = String(num); const len = accountNumber.length; if (len < 6 || len > 20) { - return this.maskFirstNCharacters(accountNumber, len, "X"); + return maskFirstNCharacters(accountNumber, len, "X"); } if (len < 14) { - return this.maskFirstNCharacters(accountNumber, len - 4, "X"); + return maskFirstNCharacters(accountNumber, len - 4, "X"); } const first = accountNumber.substr(0, 6); const last = accountNumber.substr(7); - const masked = this.maskFirstNCharacters(last, len - 11, "X"); + const masked = maskFirstNCharacters(last, len - 11, "X"); return `${first}${masked}`; }, /** * Checks if something is a string * Stolen from underscore */ - isString(obj) { - return this.isTypeOf(obj, "String"); - }, + isString, /** * Checks if something is a number * Stolen from underscore * @param obj */ - isNumber(obj) { - return this.isTypeOf(obj, "Number"); - }, + isNumber, /** * Checks if something is a certain type * Stolen from underscore */ - isTypeOf(obj, type) { - return Object.prototype.toString.call(obj) === `[object ${type}]`; - }, + isTypeOf, /** * Checks to see if something is undefined * Stolen from underscore */ - isUndefined(obj) { - return obj === void 0; - }, + isUndefined, /** * Replace first N characters of the string with maskChar * eg: maskFirstNCharacters( '1234567890', 6, 'X' ) yields XXXXXX7890 @@ -43996,12 +44033,7 @@ var require_str = __commonJS({ * @param mask String we want replace the first N chars with * @returns Masked string */ - maskFirstNCharacters(str2, num, mask) { - if (!this.isString(str2) || !this.isString(mask) || str2.length === 0 || !this.isNumber(num)) { - return str2; - } - return str2.substring(0, num).replaceAll(/./g, mask) + str2.substring(num); - }, + maskFirstNCharacters, /** * Trim a string */ @@ -44013,7 +44045,7 @@ var require_str = __commonJS({ * @param percentageString The percentage as a string */ percentageStringToNumber(percentageString) { - return Number(this.cutAfter(percentageString, "%")); + return Number(cutAfter(percentageString, "%")); }, /** * Remove all the spaces from a string @@ -44057,7 +44089,7 @@ var require_str = __commonJS({ * Converts a value to boolean, case-insensitive. */ toBool(value) { - if (this.isString(value)) { + if (isString(value)) { return value.toLowerCase() === "true"; } return !!value; @@ -44107,9 +44139,7 @@ var require_str = __commonJS({ /** * Check for whether a phone number is valid according to E.164 standard. */ - isValidE164Phone(phone) { - return Constants.CONST.SMS.E164_REGEX.test(phone); - }, + isValidE164Phone, /** * Check for whether a phone number is valid in different formats/standards. For example: * significant: 4404589784 @@ -44135,14 +44165,12 @@ var require_str = __commonJS({ /** * Returns text without our SMS domain */ - removeSMSDomain(text) { - return text.replaceAll(REMOVE_SMS_DOMAIN_PATTERN, ""); - }, + removeSMSDomain, /** * Returns true if the text is a valid E.164 phone number with our SMS domain removed */ isSMSLogin(text) { - return this.isValidE164Phone(this.removeSMSDomain(text)); + return isValidE164Phone(removeSMSDomain(text)); }, /** * This method will return all matches of a single regex like preg_match_all() in PHP. This is not a common part of @@ -44195,7 +44223,7 @@ var require_str = __commonJS({ return url; } const website = match2[3] ? match2[2] : `${defaultScheme}://${match2[2]}`; - return website.toLowerCase() + this.cutBefore(match2[1], match2[2]); + return website.toLowerCase() + cutBefore(match2[1], match2[2]); }, /** * Checks if parameter is a string or function @@ -44207,14 +44235,7 @@ var require_str = __commonJS({ * Get file extension for a given url with or * without query parameters */ - getExtension(url) { - var _a3, _b; - if (typeof url !== "string") { - Log_1.default.warn("Str.getExtension: url is not a string", { url }); - return void 0; - } - return (_b = (_a3 = url.split(".").pop()) === null || _a3 === void 0 ? void 0 : _a3.split("?")[0]) === null || _b === void 0 ? void 0 : _b.toLowerCase(); - }, + getExtension, /** * Takes in a URL and checks if the file extension is PDF * @@ -44222,7 +44243,7 @@ var require_str = __commonJS({ * @returns Whether file path is PDF or not */ isPDF(url) { - return this.getExtension(url) === "pdf"; + return getExtension(url) === "pdf"; }, /** * Takes in a URL and checks if the file extension is an image @@ -44233,7 +44254,7 @@ var require_str = __commonJS({ * https://reactnative.dev/docs/image#source */ isImage(url) { - const extension = this.getExtension(url); + const extension = getExtension(url); if (!extension) { return false; } @@ -44249,7 +44270,7 @@ var require_str = __commonJS({ * https://developer.mozilla.org/en-US/docs/Web/Media/Formats/Video_codecs */ isVideo(url) { - const extension = this.getExtension(url); + const extension = getExtension(url); if (!extension) { return false; } @@ -44262,7 +44283,7 @@ var require_str = __commonJS({ * @returns True if is a domain account email, otherwise false. */ isDomainEmail(email) { - return this.startsWith(email, "+@"); + return startsWith(email, "+@"); }, /** * Find the minimum indentation of any line in the string, @@ -45400,13 +45421,17 @@ ${g2} }, { name: "anchor", - regex: /<(a)[^><]*href\s*=\s*(['"])(.*?)\2(?:".*?"|'.*?'|[^'"><])*>([\s\S]*?)<\/\1>(?![^<]*(<\/pre>|<\/code>))/gi, - replacement: (_extras, _match, _g1, _g2, g3, g4) => { - const email = g3.startsWith("mailto:") ? g3.slice(7) : ""; - if (email === g4) { - return email; + regex: /(\]\()?<(a)[^><]*href\s*=\s*(['"])(.*?)\3(?:".*?"|'.*?'|[^'"><])*>([\s\S]*?)<\/\2>(?![^<]*(<\/pre>|<\/code>))/gi, + replacement: (_extras, _match, g1, _g2, _g3, g4, g5) => { + const incompleteLinkStart = g1 !== null && g1 !== void 0 ? g1 : ""; + const email = g4.startsWith("mailto:") ? g4.slice(7) : ""; + if (email === g5) { + return `${incompleteLinkStart}${email}`; + } + if (incompleteLinkStart && (g4 === g5 || g4 === `https://${g5}`)) { + return `${incompleteLinkStart}${g5}`; } - return `[${g4}](${email || g3})`; + return `${incompleteLinkStart}[${g5}](${email || g4})`; } }, { From 43ccbc5ddae6e877a515c3c82f45ba5a762a310c Mon Sep 17 00:00:00 2001 From: allgandaf Date: Sat, 17 Oct 2026 11:03:48 +0530 Subject: [PATCH 40/73] pass the card list to shouldShowDeleteOption --- src/hooks/useSearchBulkActions.ts | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/hooks/useSearchBulkActions.ts b/src/hooks/useSearchBulkActions.ts index b04aaf02a945..ac5d4d7ea1c5 100644 --- a/src/hooks/useSearchBulkActions.ts +++ b/src/hooks/useSearchBulkActions.ts @@ -2881,8 +2881,10 @@ function useSearchBulkActions({queryJSON}: UseSearchBulkActionsParams) { // The backend only deletes what the user can delete, so one deletable loaded item is enough to offer it. const hasLoadedDeletableItem = selectedReports.length && isExpenseReportType - ? selectedReports.some((report) => shouldShowDeleteOption(selectedTransactions, currentSearchResults?.data, accountID, rules, [report], queryJSON?.type)) - : selectedTransactionsKeys.some((id) => shouldShowDeleteOption({[id]: selectedTransactions[id]}, currentSearchResults?.data, accountID, rules, [], queryJSON?.type)); + ? selectedReports.some((report) => shouldShowDeleteOption(selectedTransactions, currentSearchResults?.data, accountID, rules, cardList, [report], queryJSON?.type)) + : selectedTransactionsKeys.some((id) => + shouldShowDeleteOption({[id]: selectedTransactions[id]}, currentSearchResults?.data, accountID, rules, cardList, [], queryJSON?.type), + ); if (!isOffline && hasLoadedDeletableItem) { allMatchingOptions.push({ icon: expensifyIcons.Trashcan, From d67cd79dca461f70a89fbc4bb0d93958cc5666d4 Mon Sep 17 00:00:00 2001 From: allgandaf Date: Sat, 17 Oct 2026 11:07:33 +0530 Subject: [PATCH 41/73] offer the select all bulk actions only on expense and report searches --- src/hooks/useSearchBulkActions.ts | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/src/hooks/useSearchBulkActions.ts b/src/hooks/useSearchBulkActions.ts index ac5d4d7ea1c5..2c5309c9f88e 100644 --- a/src/hooks/useSearchBulkActions.ts +++ b/src/hooks/useSearchBulkActions.ts @@ -756,6 +756,8 @@ function useSearchBulkActions({queryJSON}: UseSearchBulkActionsParams) { const getPersonalDetailsByLogin = useGetPersonalDetailsByLogin(); const isExpenseReportType = queryJSON?.type === CONST.SEARCH.DATA_TYPES.EXPENSE_REPORT; + // The backend runs a Select all bulk action only on an expense or report search. + const isExpenseOrReportSearch = queryJSON?.type === CONST.SEARCH.DATA_TYPES.EXPENSE || isExpenseReportType; const expensifyIcons = useMemoizedLazyExpensifyIcons([ 'Download', 'Export', @@ -2817,13 +2819,14 @@ function useSearchBulkActions({queryJSON}: UseSearchBulkActionsParams) { const hasLoadedApprovableItem = selectedReports.length ? selectedReports.some((report) => report.canApprove) : selectedTransactionsKeys.some((id) => selectedTransactions[id].action === CONST.SEARCH.ACTION_TYPES.APPROVE); - const shouldShowApproveOptionForAllMatchingItems = !isOffline && !hasSubmitPolicyTransactions && hasLoadedApprovableItem; + const shouldShowApproveOptionForAllMatchingItems = !isOffline && isExpenseOrReportSearch && !hasSubmitPolicyTransactions && hasLoadedApprovableItem; // The backend only submits the matching reports the user can submit, so one submittable loaded item is enough to offer it. // Submit plan workspaces pick an approver per report and Mark as done is a different action, so neither is sent to the backend. const hasLoadedSubmittableItem = selectedReports.length ? selectedReports.some((report) => report.canSubmit) : selectedTransactionsKeys.some((id) => selectedTransactions[id].action === CONST.SEARCH.ACTION_TYPES.SUBMIT); - const shouldShowSubmitOptionForAllMatchingItems = !isOffline && !doSelectedItemsBelongToSubmitPolicy && noReportsShouldMarkAsDone && hasLoadedSubmittableItem; + const shouldShowSubmitOptionForAllMatchingItems = + !isOffline && isExpenseOrReportSearch && !doSelectedItemsBelongToSubmitPolicy && noReportsShouldMarkAsDone && hasLoadedSubmittableItem; const submitAllMatchingItemsOption: DropdownOption = { icon: expensifyIcons.Send, text: translate('common.submit'), @@ -2868,14 +2871,14 @@ function useSearchBulkActions({queryJSON}: UseSearchBulkActionsParams) { allMatchingOptions.push(payButtonOption); } // The backend only rejects expenses on reports the user can reject, so one loaded item is enough to offer it. - if (queryJSON?.type !== CONST.SEARCH.DATA_TYPES.EXPENSE_REPORT && !isOffline && selectedTransactionsKeys.some((id) => selectedTransactions[id].canReject)) { + if (queryJSON?.type === CONST.SEARCH.DATA_TYPES.EXPENSE && !isOffline && selectedTransactionsKeys.some((id) => selectedTransactions[id].canReject)) { allMatchingOptions.push(rejectOption); } // The backend only acts on the matching expenses the user can hold or unhold, so one loaded item is enough to offer it. - if (!isOffline && selectedTransactionsKeys.some((id) => selectedTransactions[id].canHold)) { + if (!isOffline && isExpenseOrReportSearch && selectedTransactionsKeys.some((id) => selectedTransactions[id].canHold)) { allMatchingOptions.push(holdOption); } - if (!isOffline && selectedTransactionsKeys.some((id) => selectedTransactions[id].canUnhold)) { + if (!isOffline && isExpenseOrReportSearch && selectedTransactionsKeys.some((id) => selectedTransactions[id].canUnhold)) { allMatchingOptions.push(unholdOption); } // The backend only deletes what the user can delete, so one deletable loaded item is enough to offer it. @@ -2885,7 +2888,7 @@ function useSearchBulkActions({queryJSON}: UseSearchBulkActionsParams) { : selectedTransactionsKeys.some((id) => shouldShowDeleteOption({[id]: selectedTransactions[id]}, currentSearchResults?.data, accountID, rules, cardList, [], queryJSON?.type), ); - if (!isOffline && hasLoadedDeletableItem) { + if (!isOffline && isExpenseOrReportSearch && hasLoadedDeletableItem) { allMatchingOptions.push({ icon: expensifyIcons.Trashcan, text: translate('search.bulkActions.delete'), From db034e488dbc7ccff1951dc5a429ad76b95e90f9 Mon Sep 17 00:00:00 2001 From: allgandaf Date: Sat, 17 Oct 2026 11:07:33 +0530 Subject: [PATCH 42/73] test that an invoice search offers no select all bulk actions --- tests/unit/hooks/useSearchBulkActionsTest.ts | 26 ++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/tests/unit/hooks/useSearchBulkActionsTest.ts b/tests/unit/hooks/useSearchBulkActionsTest.ts index e9e3a4b1bcbe..dc93eb9eb336 100644 --- a/tests/unit/hooks/useSearchBulkActionsTest.ts +++ b/tests/unit/hooks/useSearchBulkActionsTest.ts @@ -1030,6 +1030,32 @@ describe('useSearchBulkActions - Hold, Unhold and Reject under Select all', () = expect(mockClearSelectedTransactions).toHaveBeenCalled(); }); + it('does not offer the backend bulk actions on an invoice search', async () => { + // Given "Select all" on an invoice search with an expense that could be held, unheld, rejected or approved + mockSelectedTransactions = { + tx1: makeSelectedTransaction({canHold: true, canUnhold: true, canReject: true, action: CONST.SEARCH.ACTION_TYPES.APPROVE}), + }; + + // When the bulk actions are built + const {result} = renderHook(() => useSearchBulkActions({queryJSON: {...baseQueryJSON, type: CONST.SEARCH.DATA_TYPES.INVOICE}}), {wrapper: OnyxListItemProvider}); + + // Then none of them is offered, because the backend only runs them on expense and report searches + await waitFor(() => { + expect(result.current.headerButtonsOptions.some((option) => option.value === CONST.SEARCH.BULK_ACTION_TYPES.EXPORT)).toBe(true); + }); + const offeredValues = result.current.headerButtonsOptions.map((option) => option.value); + for (const value of [ + CONST.SEARCH.BULK_ACTION_TYPES.HOLD, + CONST.SEARCH.BULK_ACTION_TYPES.UNHOLD, + CONST.SEARCH.BULK_ACTION_TYPES.REJECT, + CONST.SEARCH.BULK_ACTION_TYPES.APPROVE, + CONST.SEARCH.BULK_ACTION_TYPES.SUBMIT, + CONST.SEARCH.BULK_ACTION_TYPES.DELETE, + ]) { + expect(offeredValues).not.toContain(value); + } + }); + it('offers Reject on an expenses search when one loaded expense can be rejected', async () => { // Given "Select all" on an expenses search with one rejectable expense and one that is not, which hides Reject for a normal selection mockSelectedTransactions = {tx1: makeSelectedTransaction({canReject: true}), tx2: makeSelectedTransaction({canReject: false})}; From 4bc4d857e259f5ea233ad691551a1478fc876851 Mon Sep 17 00:00:00 2001 From: allgandaf Date: Sat, 17 Oct 2026 11:08:51 +0530 Subject: [PATCH 43/73] add isExpenseOrReportSearch to the header options dependencies --- src/hooks/useSearchBulkActions.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/src/hooks/useSearchBulkActions.ts b/src/hooks/useSearchBulkActions.ts index 2c5309c9f88e..a9aaf5a4c042 100644 --- a/src/hooks/useSearchBulkActions.ts +++ b/src/hooks/useSearchBulkActions.ts @@ -3527,6 +3527,7 @@ function useSearchBulkActions({queryJSON}: UseSearchBulkActionsParams) { isDuplicateReportOptionVisible, invokeDuplicateReportHandler, isExpenseReportType, + isExpenseOrReportSearch, handleDeleteSelectedTransactions, undeleteTransactions, theme.icon, From 8604bb57f7b4a72a58fba967410217b79b779bbc Mon Sep 17 00:00:00 2001 From: allgandaf Date: Sat, 17 Oct 2026 12:00:26 +0530 Subject: [PATCH 44/73] use plural forms for the bulk action result titles --- src/components/BulkActionStatusModal.tsx | 2 +- src/languages/de.ts | 40 +++++++++++++++++++----- src/languages/el.ts | 40 +++++++++++++++++++----- src/languages/en.ts | 40 +++++++++++++++++++----- src/languages/es.ts | 40 +++++++++++++++++++----- src/languages/fr.ts | 40 +++++++++++++++++++----- src/languages/it.ts | 40 +++++++++++++++++++----- src/languages/ja.ts | 40 +++++++++++++++++++----- src/languages/nl.ts | 40 +++++++++++++++++++----- src/languages/pl.ts | 40 +++++++++++++++++++----- src/languages/pt-BR.ts | 40 +++++++++++++++++++----- src/languages/zh-hans.ts | 40 +++++++++++++++++++----- 12 files changed, 353 insertions(+), 89 deletions(-) diff --git a/src/components/BulkActionStatusModal.tsx b/src/components/BulkActionStatusModal.tsx index bb9d4d227ac1..1e8691552d9d 100644 --- a/src/components/BulkActionStatusModal.tsx +++ b/src/components/BulkActionStatusModal.tsx @@ -133,7 +133,7 @@ function BulkActionStatusModal({bulkActionID, isVisible, onClose}: BulkActionSta if (state === CONST.BULK_ACTION.STATE.DONE) { const count = total - failedReportIDs.length; - const doneTitle = total === 0 ? translate('bulkAction.noReportsTitle') : translate(DONE_TITLES[action ?? CONST.SEARCH.BULK_ACTION_TYPES.PAY], {count, total}); + const doneTitle = total === 0 ? translate('bulkAction.noReportsTitle') : translate(DONE_TITLES[action ?? CONST.SEARCH.BULK_ACTION_TYPES.PAY], {doneCount: count, count: total}); return ( <> {doneTitle} diff --git a/src/languages/de.ts b/src/languages/de.ts index 97c9bbc3cb1c..5b03910fbe4e 100644 --- a/src/languages/de.ts +++ b/src/languages/de.ts @@ -12131,14 +12131,38 @@ Hier ist ein *Testbeleg*, um dir zu zeigen, wie es funktioniert:`, conciergeTitle: 'Auf jeden Fall!', conciergeBody: 'Concierge wird Ihnen eine Nachricht senden, sobald es fertig ist.', goToConcierge: 'Zu Concierge', - approvedTitle: ({count, total}: {count: number; total: number}) => `${count} von ${total} ${total === 1 ? 'Bericht' : 'Berichte'} genehmigt`, - submittedTitle: ({count, total}: {count: number; total: number}) => `${count} von ${total} ${total === 1 ? 'Bericht' : 'Berichte'} eingereicht`, - paidTitle: ({count, total}: {count: number; total: number}) => `${count} von ${total} ${total === 1 ? 'Bericht' : 'Berichte'} als bezahlt markiert`, - heldTitle: ({count, total}: {count: number; total: number}) => `Ausgaben in ${count} von ${total} ${total === 1 ? 'Bericht' : 'Berichten'} zurückgehalten`, - unheldTitle: ({count, total}: {count: number; total: number}) => `Zurückhalten von Ausgaben in ${count} von ${total} ${total === 1 ? 'Bericht' : 'Berichten'} aufgehoben`, - rejectedTitle: ({count, total}: {count: number; total: number}) => `Ausgaben in ${count} von ${total} ${total === 1 ? 'Bericht' : 'Berichten'} abgelehnt`, - deletedTitle: ({count, total}: {count: number; total: number}) => `${count} von ${total} ${total === 1 ? 'Bericht' : 'Berichte'} gelöscht`, - deletedExpensesTitle: ({count, total}: {count: number; total: number}) => `Ausgaben in ${count} von ${total} ${total === 1 ? 'Bericht' : 'Berichten'} gelöscht`, + approvedTitle: ({doneCount, count}: {doneCount: number; count: number}) => ({ + one: `${doneCount} von ${count} Bericht genehmigt`, + other: `${doneCount} von ${count} Berichte genehmigt`, + }), + submittedTitle: ({doneCount, count}: {doneCount: number; count: number}) => ({ + one: `${doneCount} von ${count} Bericht eingereicht`, + other: `${doneCount} von ${count} Berichte eingereicht`, + }), + paidTitle: ({doneCount, count}: {doneCount: number; count: number}) => ({ + one: `${doneCount} von ${count} Bericht als bezahlt markiert`, + other: `${doneCount} von ${count} Berichte als bezahlt markiert`, + }), + heldTitle: ({doneCount, count}: {doneCount: number; count: number}) => ({ + one: `Ausgaben in ${doneCount} von ${count} Bericht zurückgehalten`, + other: `Ausgaben in ${doneCount} von ${count} Berichten zurückgehalten`, + }), + unheldTitle: ({doneCount, count}: {doneCount: number; count: number}) => ({ + one: `Zurückhalten von Ausgaben in ${doneCount} von ${count} Bericht aufgehoben`, + other: `Zurückhalten von Ausgaben in ${doneCount} von ${count} Berichten aufgehoben`, + }), + rejectedTitle: ({doneCount, count}: {doneCount: number; count: number}) => ({ + one: `Ausgaben in ${doneCount} von ${count} Bericht abgelehnt`, + other: `Ausgaben in ${doneCount} von ${count} Berichten abgelehnt`, + }), + deletedTitle: ({doneCount, count}: {doneCount: number; count: number}) => ({ + one: `${doneCount} von ${count} Bericht gelöscht`, + other: `${doneCount} von ${count} Berichte gelöscht`, + }), + deletedExpensesTitle: ({doneCount, count}: {doneCount: number; count: number}) => ({ + one: `Ausgaben in ${doneCount} von ${count} Bericht gelöscht`, + other: `Ausgaben in ${doneCount} von ${count} Berichten gelöscht`, + }), noReportsTitle: 'Keine übereinstimmenden Berichte', noReportsBody: 'Keiner der von Ihnen ausgewählten Berichte benötigte diese Aktion.', failedReportsBody: ({count}: {count: number}) => (count === 1 ? '1 Bericht konnte nicht aktualisiert werden.' : `${count} Berichte konnten nicht aktualisiert werden.`), diff --git a/src/languages/el.ts b/src/languages/el.ts index 43aacf671a30..8e17e98c65ab 100644 --- a/src/languages/el.ts +++ b/src/languages/el.ts @@ -12358,14 +12358,38 @@ ${reportName}`, conciergeTitle: 'Βεβαίως!', conciergeBody: 'Ο Concierge θα σας στείλει μήνυμα όταν ολοκληρωθεί.', goToConcierge: 'Μετάβαση στο Concierge', - approvedTitle: ({count, total}: {count: number; total: number}) => `Εγκρίθηκαν ${count} από ${total} ${total === 1 ? 'αναφορά' : 'αναφορές'}`, - submittedTitle: ({count, total}: {count: number; total: number}) => `Υποβλήθηκαν ${count} από ${total} ${total === 1 ? 'αναφορά' : 'αναφορές'}`, - paidTitle: ({count, total}: {count: number; total: number}) => `Σημειώθηκαν ως πληρωμένες ${count} από ${total} ${total === 1 ? 'αναφορά' : 'αναφορές'}`, - heldTitle: ({count, total}: {count: number; total: number}) => `Τέθηκαν σε αναμονή έξοδα σε ${count} από ${total} ${total === 1 ? 'αναφορά' : 'αναφορές'}`, - unheldTitle: ({count, total}: {count: number; total: number}) => `Αφαιρέθηκε η κράτηση εξόδων σε ${count} από ${total} ${total === 1 ? 'αναφορά' : 'αναφορές'}`, - rejectedTitle: ({count, total}: {count: number; total: number}) => `Απορρίφθηκαν έξοδα σε ${count} από ${total} ${total === 1 ? 'αναφορά' : 'αναφορές'}`, - deletedTitle: ({count, total}: {count: number; total: number}) => `Διαγράφηκαν ${count} από ${total} ${total === 1 ? 'αναφορά' : 'αναφορές'}`, - deletedExpensesTitle: ({count, total}: {count: number; total: number}) => `Διαγράφηκαν έξοδα σε ${count} από ${total} ${total === 1 ? 'αναφορά' : 'αναφορές'}`, + approvedTitle: ({doneCount, count}: {doneCount: number; count: number}) => ({ + one: `Εγκρίθηκαν ${doneCount} από ${count} αναφορά`, + other: `Εγκρίθηκαν ${doneCount} από ${count} αναφορές`, + }), + submittedTitle: ({doneCount, count}: {doneCount: number; count: number}) => ({ + one: `Υποβλήθηκαν ${doneCount} από ${count} αναφορά`, + other: `Υποβλήθηκαν ${doneCount} από ${count} αναφορές`, + }), + paidTitle: ({doneCount, count}: {doneCount: number; count: number}) => ({ + one: `Σημειώθηκαν ως πληρωμένες ${doneCount} από ${count} αναφορά`, + other: `Σημειώθηκαν ως πληρωμένες ${doneCount} από ${count} αναφορές`, + }), + heldTitle: ({doneCount, count}: {doneCount: number; count: number}) => ({ + one: `Τέθηκαν σε αναμονή έξοδα σε ${doneCount} από ${count} αναφορά`, + other: `Τέθηκαν σε αναμονή έξοδα σε ${doneCount} από ${count} αναφορές`, + }), + unheldTitle: ({doneCount, count}: {doneCount: number; count: number}) => ({ + one: `Αφαιρέθηκε η κράτηση εξόδων σε ${doneCount} από ${count} αναφορά`, + other: `Αφαιρέθηκε η κράτηση εξόδων σε ${doneCount} από ${count} αναφορές`, + }), + rejectedTitle: ({doneCount, count}: {doneCount: number; count: number}) => ({ + one: `Απορρίφθηκαν έξοδα σε ${doneCount} από ${count} αναφορά`, + other: `Απορρίφθηκαν έξοδα σε ${doneCount} από ${count} αναφορές`, + }), + deletedTitle: ({doneCount, count}: {doneCount: number; count: number}) => ({ + one: `Διαγράφηκαν ${doneCount} από ${count} αναφορά`, + other: `Διαγράφηκαν ${doneCount} από ${count} αναφορές`, + }), + deletedExpensesTitle: ({doneCount, count}: {doneCount: number; count: number}) => ({ + one: `Διαγράφηκαν έξοδα σε ${doneCount} από ${count} αναφορά`, + other: `Διαγράφηκαν έξοδα σε ${doneCount} από ${count} αναφορές`, + }), noReportsTitle: 'Δεν υπάρχουν αντιστοιχίες αναφορών', noReportsBody: 'Καμία από τις αναφορές που επιλέξατε δεν χρειαζόταν αυτή την ενέργεια.', failedReportsBody: ({count}: {count: number}) => (count === 1 ? '1 αναφορά δεν μπόρεσε να ενημερωθεί.' : `${count} αναφορές δεν ήταν δυνατό να ενημερωθούν.`), diff --git a/src/languages/en.ts b/src/languages/en.ts index 9c6ec910d82b..6fb7825b7b43 100644 --- a/src/languages/en.ts +++ b/src/languages/en.ts @@ -12141,14 +12141,38 @@ const translations = { conciergeTitle: 'You bet!', conciergeBody: "Concierge will message you when it's done.", goToConcierge: 'Go to Concierge', - approvedTitle: ({count, total}: {count: number; total: number}) => `Approved ${count} of ${total} ${total === 1 ? 'report' : 'reports'}`, - submittedTitle: ({count, total}: {count: number; total: number}) => `Submitted ${count} of ${total} ${total === 1 ? 'report' : 'reports'}`, - paidTitle: ({count, total}: {count: number; total: number}) => `Marked ${count} of ${total} ${total === 1 ? 'report' : 'reports'} as paid`, - heldTitle: ({count, total}: {count: number; total: number}) => `Held expenses on ${count} of ${total} ${total === 1 ? 'report' : 'reports'}`, - unheldTitle: ({count, total}: {count: number; total: number}) => `Unheld expenses on ${count} of ${total} ${total === 1 ? 'report' : 'reports'}`, - rejectedTitle: ({count, total}: {count: number; total: number}) => `Rejected expenses on ${count} of ${total} ${total === 1 ? 'report' : 'reports'}`, - deletedTitle: ({count, total}: {count: number; total: number}) => `Deleted ${count} of ${total} ${total === 1 ? 'report' : 'reports'}`, - deletedExpensesTitle: ({count, total}: {count: number; total: number}) => `Deleted expenses on ${count} of ${total} ${total === 1 ? 'report' : 'reports'}`, + approvedTitle: ({doneCount, count}: {doneCount: number; count: number}) => ({ + one: `Approved ${doneCount} of ${count} report`, + other: `Approved ${doneCount} of ${count} reports`, + }), + submittedTitle: ({doneCount, count}: {doneCount: number; count: number}) => ({ + one: `Submitted ${doneCount} of ${count} report`, + other: `Submitted ${doneCount} of ${count} reports`, + }), + paidTitle: ({doneCount, count}: {doneCount: number; count: number}) => ({ + one: `Marked ${doneCount} of ${count} report as paid`, + other: `Marked ${doneCount} of ${count} reports as paid`, + }), + heldTitle: ({doneCount, count}: {doneCount: number; count: number}) => ({ + one: `Held expenses on ${doneCount} of ${count} report`, + other: `Held expenses on ${doneCount} of ${count} reports`, + }), + unheldTitle: ({doneCount, count}: {doneCount: number; count: number}) => ({ + one: `Unheld expenses on ${doneCount} of ${count} report`, + other: `Unheld expenses on ${doneCount} of ${count} reports`, + }), + rejectedTitle: ({doneCount, count}: {doneCount: number; count: number}) => ({ + one: `Rejected expenses on ${doneCount} of ${count} report`, + other: `Rejected expenses on ${doneCount} of ${count} reports`, + }), + deletedTitle: ({doneCount, count}: {doneCount: number; count: number}) => ({ + one: `Deleted ${doneCount} of ${count} report`, + other: `Deleted ${doneCount} of ${count} reports`, + }), + deletedExpensesTitle: ({doneCount, count}: {doneCount: number; count: number}) => ({ + one: `Deleted expenses on ${doneCount} of ${count} report`, + other: `Deleted expenses on ${doneCount} of ${count} reports`, + }), noReportsTitle: 'No matching reports', noReportsBody: 'None of the reports you selected needed this action.', failedReportsBody: ({count}: {count: number}) => (count === 1 ? "1 report couldn't be updated." : `${count} reports couldn't be updated.`), diff --git a/src/languages/es.ts b/src/languages/es.ts index 27efc1a69bb5..650b4410a76f 100644 --- a/src/languages/es.ts +++ b/src/languages/es.ts @@ -12394,14 +12394,38 @@ ${reportName}`, conciergeTitle: '¡Por supuesto!', conciergeBody: 'Concierge te enviará un mensaje cuando haya terminado.', goToConcierge: 'Ir a Concierge', - approvedTitle: ({count, total}: {count: number; total: number}) => `Aprobados ${count} de ${total} ${total === 1 ? 'informe' : 'informes'}`, - submittedTitle: ({count, total}: {count: number; total: number}) => `Enviados ${count} de ${total} ${total === 1 ? 'informe' : 'informes'}`, - paidTitle: ({count, total}: {count: number; total: number}) => `Marcados ${count} de ${total} ${total === 1 ? 'informe' : 'informes'} como pagados`, - heldTitle: ({count, total}: {count: number; total: number}) => `Gastos retenidos en ${count} de ${total} ${total === 1 ? 'informe' : 'informes'}`, - unheldTitle: ({count, total}: {count: number; total: number}) => `Gastos desbloqueados en ${count} de ${total} ${total === 1 ? 'informe' : 'informes'}`, - rejectedTitle: ({count, total}: {count: number; total: number}) => `Gastos rechazados en ${count} de ${total} ${total === 1 ? 'informe' : 'informes'}`, - deletedTitle: ({count, total}: {count: number; total: number}) => `Eliminados ${count} de ${total} ${total === 1 ? 'informe' : 'informes'}`, - deletedExpensesTitle: ({count, total}: {count: number; total: number}) => `Gastos eliminados en ${count} de ${total} ${total === 1 ? 'informe' : 'informes'}`, + approvedTitle: ({doneCount, count}: {doneCount: number; count: number}) => ({ + one: `Aprobados ${doneCount} de ${count} informe`, + other: `Aprobados ${doneCount} de ${count} informes`, + }), + submittedTitle: ({doneCount, count}: {doneCount: number; count: number}) => ({ + one: `Enviados ${doneCount} de ${count} informe`, + other: `Enviados ${doneCount} de ${count} informes`, + }), + paidTitle: ({doneCount, count}: {doneCount: number; count: number}) => ({ + one: `Marcados ${doneCount} de ${count} informe como pagados`, + other: `Marcados ${doneCount} de ${count} informes como pagados`, + }), + heldTitle: ({doneCount, count}: {doneCount: number; count: number}) => ({ + one: `Gastos retenidos en ${doneCount} de ${count} informe`, + other: `Gastos retenidos en ${doneCount} de ${count} informes`, + }), + unheldTitle: ({doneCount, count}: {doneCount: number; count: number}) => ({ + one: `Gastos desbloqueados en ${doneCount} de ${count} informe`, + other: `Gastos desbloqueados en ${doneCount} de ${count} informes`, + }), + rejectedTitle: ({doneCount, count}: {doneCount: number; count: number}) => ({ + one: `Gastos rechazados en ${doneCount} de ${count} informe`, + other: `Gastos rechazados en ${doneCount} de ${count} informes`, + }), + deletedTitle: ({doneCount, count}: {doneCount: number; count: number}) => ({ + one: `Eliminados ${doneCount} de ${count} informe`, + other: `Eliminados ${doneCount} de ${count} informes`, + }), + deletedExpensesTitle: ({doneCount, count}: {doneCount: number; count: number}) => ({ + one: `Gastos eliminados en ${doneCount} de ${count} informe`, + other: `Gastos eliminados en ${doneCount} de ${count} informes`, + }), noReportsTitle: 'No hay informes coincidentes', noReportsBody: 'Ninguno de los informes que seleccionaste necesitaba esta acción.', failedReportsBody: ({count}: {count: number}) => (count === 1 ? 'No se pudo actualizar 1 informe.' : `No se pudieron actualizar ${count} informes.`), diff --git a/src/languages/fr.ts b/src/languages/fr.ts index 04fb0952cbd6..c05eed3009eb 100644 --- a/src/languages/fr.ts +++ b/src/languages/fr.ts @@ -12161,14 +12161,38 @@ Voici un *reçu test* pour vous montrer comment ça fonctionne :`, conciergeTitle: 'Bien sûr !', conciergeBody: 'Concierge vous enverra un message lorsque ce sera terminé.', goToConcierge: 'Aller à Concierge', - approvedTitle: ({count, total}: {count: number; total: number}) => `Approuvé ${count} sur ${total} ${total === 1 ? 'note de frais' : 'notes de frais'}`, - submittedTitle: ({count, total}: {count: number; total: number}) => `Soumis ${count} sur ${total} ${total === 1 ? 'note de frais' : 'notes de frais'}`, - paidTitle: ({count, total}: {count: number; total: number}) => `Marqué ${count} sur ${total} ${total === 1 ? 'note de frais' : 'notes de frais'} comme payé`, - heldTitle: ({count, total}: {count: number; total: number}) => `Dépenses mises en attente pour ${count} sur ${total} ${total === 1 ? 'note de frais' : 'notes de frais'}`, - unheldTitle: ({count, total}: {count: number; total: number}) => `Mise en attente supprimée pour ${count} sur ${total} ${total === 1 ? 'note de frais' : 'notes de frais'}`, - rejectedTitle: ({count, total}: {count: number; total: number}) => `Dépenses rejetées pour ${count} sur ${total} ${total === 1 ? 'note de frais' : 'notes de frais'}`, - deletedTitle: ({count, total}: {count: number; total: number}) => `Supprimé ${count} sur ${total} ${total === 1 ? 'note de frais' : 'notes de frais'}`, - deletedExpensesTitle: ({count, total}: {count: number; total: number}) => `Dépenses supprimées pour ${count} sur ${total} ${total === 1 ? 'note de frais' : 'notes de frais'}`, + approvedTitle: ({doneCount, count}: {doneCount: number; count: number}) => ({ + one: `Approuvé ${doneCount} sur ${count} note de frais`, + other: `Approuvé ${doneCount} sur ${count} notes de frais`, + }), + submittedTitle: ({doneCount, count}: {doneCount: number; count: number}) => ({ + one: `Soumis ${doneCount} sur ${count} note de frais`, + other: `Soumis ${doneCount} sur ${count} notes de frais`, + }), + paidTitle: ({doneCount, count}: {doneCount: number; count: number}) => ({ + one: `Marqué ${doneCount} sur ${count} note de frais comme payé`, + other: `Marqué ${doneCount} sur ${count} notes de frais comme payé`, + }), + heldTitle: ({doneCount, count}: {doneCount: number; count: number}) => ({ + one: `Dépenses mises en attente pour ${doneCount} sur ${count} note de frais`, + other: `Dépenses mises en attente pour ${doneCount} sur ${count} notes de frais`, + }), + unheldTitle: ({doneCount, count}: {doneCount: number; count: number}) => ({ + one: `Mise en attente supprimée pour ${doneCount} sur ${count} note de frais`, + other: `Mise en attente supprimée pour ${doneCount} sur ${count} notes de frais`, + }), + rejectedTitle: ({doneCount, count}: {doneCount: number; count: number}) => ({ + one: `Dépenses rejetées pour ${doneCount} sur ${count} note de frais`, + other: `Dépenses rejetées pour ${doneCount} sur ${count} notes de frais`, + }), + deletedTitle: ({doneCount, count}: {doneCount: number; count: number}) => ({ + one: `Supprimé ${doneCount} sur ${count} note de frais`, + other: `Supprimé ${doneCount} sur ${count} notes de frais`, + }), + deletedExpensesTitle: ({doneCount, count}: {doneCount: number; count: number}) => ({ + one: `Dépenses supprimées pour ${doneCount} sur ${count} note de frais`, + other: `Dépenses supprimées pour ${doneCount} sur ${count} notes de frais`, + }), noReportsTitle: 'Aucune note de frais correspondante', noReportsBody: 'Aucune des notes de frais que vous avez sélectionnées n’avait besoin de cette action.', failedReportsBody: ({count}: {count: number}) => (count === 1 ? "1 note de frais n'a pas pu être mise à jour." : `${count} notes de frais n'ont pas pu être mises à jour.`), diff --git a/src/languages/it.ts b/src/languages/it.ts index 739a6fd9992d..5fe2f4c2c371 100644 --- a/src/languages/it.ts +++ b/src/languages/it.ts @@ -12083,14 +12083,38 @@ Ecco una *ricevuta di prova* per mostrarti come funziona:`, conciergeTitle: 'Ci puoi contare!', conciergeBody: 'Concierge ti manderà un messaggio quando avrà finito.', goToConcierge: 'Vai a Concierge', - approvedTitle: ({count, total}: {count: number; total: number}) => `Approvati ${count} su ${total} report`, - submittedTitle: ({count, total}: {count: number; total: number}) => `Inviati ${count} su ${total} report`, - paidTitle: ({count, total}: {count: number; total: number}) => `Contrassegnati ${count} su ${total} report come pagati`, - heldTitle: ({count, total}: {count: number; total: number}) => `Spese messe in attesa in ${count} su ${total} report`, - unheldTitle: ({count, total}: {count: number; total: number}) => `Blocco rimosso dalle spese in ${count} su ${total} report`, - rejectedTitle: ({count, total}: {count: number; total: number}) => `Spese rifiutate in ${count} su ${total} report`, - deletedTitle: ({count, total}: {count: number; total: number}) => `Eliminati ${count} su ${total} report`, - deletedExpensesTitle: ({count, total}: {count: number; total: number}) => `Spese eliminate in ${count} su ${total} report`, + approvedTitle: ({doneCount, count}: {doneCount: number; count: number}) => ({ + one: `Approvati ${doneCount} su ${count} report`, + other: `Approvati ${doneCount} su ${count} report`, + }), + submittedTitle: ({doneCount, count}: {doneCount: number; count: number}) => ({ + one: `Inviati ${doneCount} su ${count} report`, + other: `Inviati ${doneCount} su ${count} report`, + }), + paidTitle: ({doneCount, count}: {doneCount: number; count: number}) => ({ + one: `Contrassegnati ${doneCount} su ${count} report come pagati`, + other: `Contrassegnati ${doneCount} su ${count} report come pagati`, + }), + heldTitle: ({doneCount, count}: {doneCount: number; count: number}) => ({ + one: `Spese messe in attesa in ${doneCount} su ${count} report`, + other: `Spese messe in attesa in ${doneCount} su ${count} report`, + }), + unheldTitle: ({doneCount, count}: {doneCount: number; count: number}) => ({ + one: `Blocco rimosso dalle spese in ${doneCount} su ${count} report`, + other: `Blocco rimosso dalle spese in ${doneCount} su ${count} report`, + }), + rejectedTitle: ({doneCount, count}: {doneCount: number; count: number}) => ({ + one: `Spese rifiutate in ${doneCount} su ${count} report`, + other: `Spese rifiutate in ${doneCount} su ${count} report`, + }), + deletedTitle: ({doneCount, count}: {doneCount: number; count: number}) => ({ + one: `Eliminati ${doneCount} su ${count} report`, + other: `Eliminati ${doneCount} su ${count} report`, + }), + deletedExpensesTitle: ({doneCount, count}: {doneCount: number; count: number}) => ({ + one: `Spese eliminate in ${doneCount} su ${count} report`, + other: `Spese eliminate in ${doneCount} su ${count} report`, + }), noReportsTitle: 'Nessun report corrispondente', noReportsBody: 'Nessuno dei report che hai selezionato richiedeva questa azione.', failedReportsBody: ({count}: {count: number}) => (count === 1 ? '1 report non può essere aggiornato.' : `${count} report non hanno potuto essere aggiornati.`), diff --git a/src/languages/ja.ts b/src/languages/ja.ts index d16f32e40621..621be9b942d1 100644 --- a/src/languages/ja.ts +++ b/src/languages/ja.ts @@ -11909,14 +11909,38 @@ ${reportName}`, conciergeTitle: 'もちろんです!', conciergeBody: '完了したら Concierge からメッセージが届きます。', goToConcierge: 'Concierge に移動', - approvedTitle: ({count, total}: {count: number; total: number}) => `${total} 件中 ${count} 件のレポートを承認しました`, - submittedTitle: ({count, total}: {count: number; total: number}) => `${total} 件中 ${count} 件のレポートを提出しました`, - paidTitle: ({count, total}: {count: number; total: number}) => `${total} 件中 ${count} 件のレポートを支払済みにしました`, - heldTitle: ({count, total}: {count: number; total: number}) => `${total} 件中 ${count} 件のレポートの経費を保留にしました`, - unheldTitle: ({count, total}: {count: number; total: number}) => `${total} 件中 ${count} 件のレポートの経費の保留を解除しました`, - rejectedTitle: ({count, total}: {count: number; total: number}) => `${total} 件中 ${count} 件のレポートの経費を却下しました`, - deletedTitle: ({count, total}: {count: number; total: number}) => `${total} 件中 ${count} 件のレポートを削除しました`, - deletedExpensesTitle: ({count, total}: {count: number; total: number}) => `${total} 件中 ${count} 件のレポートの経費を削除しました`, + approvedTitle: ({doneCount, count}: {doneCount: number; count: number}) => ({ + one: `${count} 件中 ${doneCount} 件のレポートを承認しました`, + other: `${count} 件中 ${doneCount} 件のレポートを承認しました`, + }), + submittedTitle: ({doneCount, count}: {doneCount: number; count: number}) => ({ + one: `${count} 件中 ${doneCount} 件のレポートを提出しました`, + other: `${count} 件中 ${doneCount} 件のレポートを提出しました`, + }), + paidTitle: ({doneCount, count}: {doneCount: number; count: number}) => ({ + one: `${count} 件中 ${doneCount} 件のレポートを支払済みにしました`, + other: `${count} 件中 ${doneCount} 件のレポートを支払済みにしました`, + }), + heldTitle: ({doneCount, count}: {doneCount: number; count: number}) => ({ + one: `${count} 件中 ${doneCount} 件のレポートの経費を保留にしました`, + other: `${count} 件中 ${doneCount} 件のレポートの経費を保留にしました`, + }), + unheldTitle: ({doneCount, count}: {doneCount: number; count: number}) => ({ + one: `${count} 件中 ${doneCount} 件のレポートの経費の保留を解除しました`, + other: `${count} 件中 ${doneCount} 件のレポートの経費の保留を解除しました`, + }), + rejectedTitle: ({doneCount, count}: {doneCount: number; count: number}) => ({ + one: `${count} 件中 ${doneCount} 件のレポートの経費を却下しました`, + other: `${count} 件中 ${doneCount} 件のレポートの経費を却下しました`, + }), + deletedTitle: ({doneCount, count}: {doneCount: number; count: number}) => ({ + one: `${count} 件中 ${doneCount} 件のレポートを削除しました`, + other: `${count} 件中 ${doneCount} 件のレポートを削除しました`, + }), + deletedExpensesTitle: ({doneCount, count}: {doneCount: number; count: number}) => ({ + one: `${count} 件中 ${doneCount} 件のレポートの経費を削除しました`, + other: `${count} 件中 ${doneCount} 件のレポートの経費を削除しました`, + }), noReportsTitle: '一致するレポートはありません', noReportsBody: '選択したレポートには、いずれもこの操作は必要ありませんでした。', failedReportsBody: ({count}: {count: number}) => (count === 1 ? '1件のレポートを更新できませんでした。' : `${count} 件のレポートを更新できませんでした。`), diff --git a/src/languages/nl.ts b/src/languages/nl.ts index 6f8c29071633..16db332cadce 100644 --- a/src/languages/nl.ts +++ b/src/languages/nl.ts @@ -12044,14 +12044,38 @@ Hier is een *proefbon* om je te laten zien hoe het werkt:`, conciergeTitle: 'Zeker weten!', conciergeBody: 'Concierge stuurt je een bericht zodra het klaar is.', goToConcierge: 'Ga naar Concierge', - approvedTitle: ({count, total}: {count: number; total: number}) => `${count} van ${total} ${total === 1 ? 'rapport' : 'rapporten'} goedgekeurd`, - submittedTitle: ({count, total}: {count: number; total: number}) => `${count} van ${total} ${total === 1 ? 'rapport' : 'rapporten'} ingediend`, - paidTitle: ({count, total}: {count: number; total: number}) => `${count} van ${total} ${total === 1 ? 'rapport' : 'rapporten'} als betaald gemarkeerd`, - heldTitle: ({count, total}: {count: number; total: number}) => `Uitgaven vastgehouden in ${count} van ${total} ${total === 1 ? 'rapport' : 'rapporten'}`, - unheldTitle: ({count, total}: {count: number; total: number}) => `Blokkering van uitgaven opgeheven in ${count} van ${total} ${total === 1 ? 'rapport' : 'rapporten'}`, - rejectedTitle: ({count, total}: {count: number; total: number}) => `Uitgaven afgewezen in ${count} van ${total} ${total === 1 ? 'rapport' : 'rapporten'}`, - deletedTitle: ({count, total}: {count: number; total: number}) => `${count} van ${total} ${total === 1 ? 'rapport' : 'rapporten'} verwijderd`, - deletedExpensesTitle: ({count, total}: {count: number; total: number}) => `Uitgaven verwijderd in ${count} van ${total} ${total === 1 ? 'rapport' : 'rapporten'}`, + approvedTitle: ({doneCount, count}: {doneCount: number; count: number}) => ({ + one: `${doneCount} van ${count} rapport goedgekeurd`, + other: `${doneCount} van ${count} rapporten goedgekeurd`, + }), + submittedTitle: ({doneCount, count}: {doneCount: number; count: number}) => ({ + one: `${doneCount} van ${count} rapport ingediend`, + other: `${doneCount} van ${count} rapporten ingediend`, + }), + paidTitle: ({doneCount, count}: {doneCount: number; count: number}) => ({ + one: `${doneCount} van ${count} rapport als betaald gemarkeerd`, + other: `${doneCount} van ${count} rapporten als betaald gemarkeerd`, + }), + heldTitle: ({doneCount, count}: {doneCount: number; count: number}) => ({ + one: `Uitgaven vastgehouden in ${doneCount} van ${count} rapport`, + other: `Uitgaven vastgehouden in ${doneCount} van ${count} rapporten`, + }), + unheldTitle: ({doneCount, count}: {doneCount: number; count: number}) => ({ + one: `Blokkering van uitgaven opgeheven in ${doneCount} van ${count} rapport`, + other: `Blokkering van uitgaven opgeheven in ${doneCount} van ${count} rapporten`, + }), + rejectedTitle: ({doneCount, count}: {doneCount: number; count: number}) => ({ + one: `Uitgaven afgewezen in ${doneCount} van ${count} rapport`, + other: `Uitgaven afgewezen in ${doneCount} van ${count} rapporten`, + }), + deletedTitle: ({doneCount, count}: {doneCount: number; count: number}) => ({ + one: `${doneCount} van ${count} rapport verwijderd`, + other: `${doneCount} van ${count} rapporten verwijderd`, + }), + deletedExpensesTitle: ({doneCount, count}: {doneCount: number; count: number}) => ({ + one: `Uitgaven verwijderd in ${doneCount} van ${count} rapport`, + other: `Uitgaven verwijderd in ${doneCount} van ${count} rapporten`, + }), noReportsTitle: 'Geen overeenkomende rapporten', noReportsBody: 'Geen van de rapporten die je hebt geselecteerd had deze actie nodig.', failedReportsBody: ({count}: {count: number}) => (count === 1 ? '1 rapport kon niet worden bijgewerkt.' : `${count} rapporten konden niet worden bijgewerkt.`), diff --git a/src/languages/pl.ts b/src/languages/pl.ts index a4352003ad3f..6b54bf9b3347 100644 --- a/src/languages/pl.ts +++ b/src/languages/pl.ts @@ -12062,14 +12062,38 @@ Oto *paragon testowy*, żeby pokazać Ci, jak to działa:`, conciergeTitle: 'No jasne!', conciergeBody: 'Gdy Concierge skończy, wyśle ci wiadomość.', goToConcierge: 'Przejdź do Concierge', - approvedTitle: ({count, total}: {count: number; total: number}) => `Zatwierdzono ${count} z ${total} ${total === 1 ? 'raportu' : 'raportów'}`, - submittedTitle: ({count, total}: {count: number; total: number}) => `Przesłano ${count} z ${total} ${total === 1 ? 'raportu' : 'raportów'}`, - paidTitle: ({count, total}: {count: number; total: number}) => `Oznaczono ${count} z ${total} ${total === 1 ? 'raportu' : 'raportów'} jako opłacone`, - heldTitle: ({count, total}: {count: number; total: number}) => `Wstrzymano wydatki w ${count} z ${total} ${total === 1 ? 'raportu' : 'raportów'}`, - unheldTitle: ({count, total}: {count: number; total: number}) => `Usunięto blokadę wydatków w ${count} z ${total} ${total === 1 ? 'raportu' : 'raportów'}`, - rejectedTitle: ({count, total}: {count: number; total: number}) => `Odrzucono wydatki w ${count} z ${total} ${total === 1 ? 'raportu' : 'raportów'}`, - deletedTitle: ({count, total}: {count: number; total: number}) => `Usunięto ${count} z ${total} ${total === 1 ? 'raportu' : 'raportów'}`, - deletedExpensesTitle: ({count, total}: {count: number; total: number}) => `Usunięto wydatki w ${count} z ${total} ${total === 1 ? 'raportu' : 'raportów'}`, + approvedTitle: ({doneCount, count}: {doneCount: number; count: number}) => ({ + one: `Zatwierdzono ${doneCount} z ${count} raportu`, + other: `Zatwierdzono ${doneCount} z ${count} raportów`, + }), + submittedTitle: ({doneCount, count}: {doneCount: number; count: number}) => ({ + one: `Przesłano ${doneCount} z ${count} raportu`, + other: `Przesłano ${doneCount} z ${count} raportów`, + }), + paidTitle: ({doneCount, count}: {doneCount: number; count: number}) => ({ + one: `Oznaczono ${doneCount} z ${count} raportu jako opłacone`, + other: `Oznaczono ${doneCount} z ${count} raportów jako opłacone`, + }), + heldTitle: ({doneCount, count}: {doneCount: number; count: number}) => ({ + one: `Wstrzymano wydatki w ${doneCount} z ${count} raportu`, + other: `Wstrzymano wydatki w ${doneCount} z ${count} raportów`, + }), + unheldTitle: ({doneCount, count}: {doneCount: number; count: number}) => ({ + one: `Usunięto blokadę wydatków w ${doneCount} z ${count} raportu`, + other: `Usunięto blokadę wydatków w ${doneCount} z ${count} raportów`, + }), + rejectedTitle: ({doneCount, count}: {doneCount: number; count: number}) => ({ + one: `Odrzucono wydatki w ${doneCount} z ${count} raportu`, + other: `Odrzucono wydatki w ${doneCount} z ${count} raportów`, + }), + deletedTitle: ({doneCount, count}: {doneCount: number; count: number}) => ({ + one: `Usunięto ${doneCount} z ${count} raportu`, + other: `Usunięto ${doneCount} z ${count} raportów`, + }), + deletedExpensesTitle: ({doneCount, count}: {doneCount: number; count: number}) => ({ + one: `Usunięto wydatki w ${doneCount} z ${count} raportu`, + other: `Usunięto wydatki w ${doneCount} z ${count} raportów`, + }), noReportsTitle: 'Brak pasujących raportów', noReportsBody: 'Żaden z wybranych raportów nie wymagał tej akcji.', failedReportsBody: ({count}: {count: number}) => (count === 1 ? 'Nie udało się zaktualizować 1 raportu.' : `Nie udało się zaktualizować ${count} raportów.`), diff --git a/src/languages/pt-BR.ts b/src/languages/pt-BR.ts index 6b8136faf9ab..dbb78856a37a 100644 --- a/src/languages/pt-BR.ts +++ b/src/languages/pt-BR.ts @@ -12035,14 +12035,38 @@ Aqui está um *comprovante de teste* para mostrar como funciona:`, conciergeTitle: 'Pode apostar!', conciergeBody: 'O Concierge vai te enviar uma mensagem quando terminar.', goToConcierge: 'Ir para o Concierge', - approvedTitle: ({count, total}: {count: number; total: number}) => `Aprovado(s) ${count} de ${total} ${total === 1 ? 'relatório' : 'relatórios'}`, - submittedTitle: ({count, total}: {count: number; total: number}) => `Enviado(s) ${count} de ${total} ${total === 1 ? 'relatório' : 'relatórios'}`, - paidTitle: ({count, total}: {count: number; total: number}) => `Marcado(s) ${count} de ${total} ${total === 1 ? 'relatório' : 'relatórios'} como pago(s)`, - heldTitle: ({count, total}: {count: number; total: number}) => `Despesas retidas em ${count} de ${total} ${total === 1 ? 'relatório' : 'relatórios'}`, - unheldTitle: ({count, total}: {count: number; total: number}) => `Bloqueio removido das despesas em ${count} de ${total} ${total === 1 ? 'relatório' : 'relatórios'}`, - rejectedTitle: ({count, total}: {count: number; total: number}) => `Despesas rejeitadas em ${count} de ${total} ${total === 1 ? 'relatório' : 'relatórios'}`, - deletedTitle: ({count, total}: {count: number; total: number}) => `Excluído(s) ${count} de ${total} ${total === 1 ? 'relatório' : 'relatórios'}`, - deletedExpensesTitle: ({count, total}: {count: number; total: number}) => `Despesas excluídas em ${count} de ${total} ${total === 1 ? 'relatório' : 'relatórios'}`, + approvedTitle: ({doneCount, count}: {doneCount: number; count: number}) => ({ + one: `Aprovado(s) ${doneCount} de ${count} relatório`, + other: `Aprovado(s) ${doneCount} de ${count} relatórios`, + }), + submittedTitle: ({doneCount, count}: {doneCount: number; count: number}) => ({ + one: `Enviado(s) ${doneCount} de ${count} relatório`, + other: `Enviado(s) ${doneCount} de ${count} relatórios`, + }), + paidTitle: ({doneCount, count}: {doneCount: number; count: number}) => ({ + one: `Marcado(s) ${doneCount} de ${count} relatório como pago(s)`, + other: `Marcado(s) ${doneCount} de ${count} relatórios como pago(s)`, + }), + heldTitle: ({doneCount, count}: {doneCount: number; count: number}) => ({ + one: `Despesas retidas em ${doneCount} de ${count} relatório`, + other: `Despesas retidas em ${doneCount} de ${count} relatórios`, + }), + unheldTitle: ({doneCount, count}: {doneCount: number; count: number}) => ({ + one: `Bloqueio removido das despesas em ${doneCount} de ${count} relatório`, + other: `Bloqueio removido das despesas em ${doneCount} de ${count} relatórios`, + }), + rejectedTitle: ({doneCount, count}: {doneCount: number; count: number}) => ({ + one: `Despesas rejeitadas em ${doneCount} de ${count} relatório`, + other: `Despesas rejeitadas em ${doneCount} de ${count} relatórios`, + }), + deletedTitle: ({doneCount, count}: {doneCount: number; count: number}) => ({ + one: `Excluído(s) ${doneCount} de ${count} relatório`, + other: `Excluído(s) ${doneCount} de ${count} relatórios`, + }), + deletedExpensesTitle: ({doneCount, count}: {doneCount: number; count: number}) => ({ + one: `Despesas excluídas em ${doneCount} de ${count} relatório`, + other: `Despesas excluídas em ${doneCount} de ${count} relatórios`, + }), noReportsTitle: 'Nenhum relatório correspondente', noReportsBody: 'Nenhum dos relatórios que você selecionou precisava dessa ação.', failedReportsBody: ({count}: {count: number}) => (count === 1 ? '1 relatório não pôde ser atualizado.' : `${count} relatórios não puderam ser atualizados.`), diff --git a/src/languages/zh-hans.ts b/src/languages/zh-hans.ts index d47bbd3b4b06..2f40be37b61e 100644 --- a/src/languages/zh-hans.ts +++ b/src/languages/zh-hans.ts @@ -11601,14 +11601,38 @@ ${reportName}`, conciergeTitle: '当然!', conciergeBody: '完成后,Concierge 会给你发送消息。', goToConcierge: '前往 Concierge', - approvedTitle: ({count, total}: {count: number; total: number}) => `已批准 ${total} 份报表中的 ${count} 份`, - submittedTitle: ({count, total}: {count: number; total: number}) => `已提交 ${total} 份报表中的 ${count} 份`, - paidTitle: ({count, total}: {count: number; total: number}) => `已将 ${total} 份报表中的 ${count} 份标记为已支付`, - heldTitle: ({count, total}: {count: number; total: number}) => `已暂挂 ${total} 份报表中 ${count} 份的报销费用`, - unheldTitle: ({count, total}: {count: number; total: number}) => `已解除 ${total} 份报表中 ${count} 份的报销费用保留`, - rejectedTitle: ({count, total}: {count: number; total: number}) => `已拒绝 ${total} 份报表中 ${count} 份的报销费用`, - deletedTitle: ({count, total}: {count: number; total: number}) => `已删除 ${total} 份报表中的 ${count} 份`, - deletedExpensesTitle: ({count, total}: {count: number; total: number}) => `已删除 ${total} 份报表中 ${count} 份的报销费用`, + approvedTitle: ({doneCount, count}: {doneCount: number; count: number}) => ({ + one: `已批准 ${count} 份报表中的 ${doneCount} 份`, + other: `已批准 ${count} 份报表中的 ${doneCount} 份`, + }), + submittedTitle: ({doneCount, count}: {doneCount: number; count: number}) => ({ + one: `已提交 ${count} 份报表中的 ${doneCount} 份`, + other: `已提交 ${count} 份报表中的 ${doneCount} 份`, + }), + paidTitle: ({doneCount, count}: {doneCount: number; count: number}) => ({ + one: `已将 ${count} 份报表中的 ${doneCount} 份标记为已支付`, + other: `已将 ${count} 份报表中的 ${doneCount} 份标记为已支付`, + }), + heldTitle: ({doneCount, count}: {doneCount: number; count: number}) => ({ + one: `已暂挂 ${count} 份报表中 ${doneCount} 份的报销费用`, + other: `已暂挂 ${count} 份报表中 ${doneCount} 份的报销费用`, + }), + unheldTitle: ({doneCount, count}: {doneCount: number; count: number}) => ({ + one: `已解除 ${count} 份报表中 ${doneCount} 份的报销费用保留`, + other: `已解除 ${count} 份报表中 ${doneCount} 份的报销费用保留`, + }), + rejectedTitle: ({doneCount, count}: {doneCount: number; count: number}) => ({ + one: `已拒绝 ${count} 份报表中 ${doneCount} 份的报销费用`, + other: `已拒绝 ${count} 份报表中 ${doneCount} 份的报销费用`, + }), + deletedTitle: ({doneCount, count}: {doneCount: number; count: number}) => ({ + one: `已删除 ${count} 份报表中的 ${doneCount} 份`, + other: `已删除 ${count} 份报表中的 ${doneCount} 份`, + }), + deletedExpensesTitle: ({doneCount, count}: {doneCount: number; count: number}) => ({ + one: `已删除 ${count} 份报表中 ${doneCount} 份的报销费用`, + other: `已删除 ${count} 份报表中 ${doneCount} 份的报销费用`, + }), noReportsTitle: '没有匹配的报表', noReportsBody: '您选择的报表都不需要执行此操作。', failedReportsBody: ({count}: {count: number}) => (count === 1 ? '1 份报表无法更新。' : `${count} 份报表无法更新。`), From 35d7ce8b88d55cb70af0271651375e57a687afa8 Mon Sep 17 00:00:00 2001 From: allgandaf Date: Sat, 17 Oct 2026 12:00:27 +0530 Subject: [PATCH 45/73] use plural forms for the failed reports text --- src/languages/de.ts | 5 ++++- src/languages/el.ts | 5 ++++- src/languages/en.ts | 5 ++++- src/languages/es.ts | 5 ++++- src/languages/fr.ts | 5 ++++- src/languages/it.ts | 5 ++++- src/languages/ja.ts | 5 ++++- src/languages/nl.ts | 5 ++++- src/languages/pl.ts | 5 ++++- src/languages/pt-BR.ts | 5 ++++- src/languages/zh-hans.ts | 5 ++++- 11 files changed, 44 insertions(+), 11 deletions(-) diff --git a/src/languages/de.ts b/src/languages/de.ts index 5b03910fbe4e..03add5467c8d 100644 --- a/src/languages/de.ts +++ b/src/languages/de.ts @@ -12165,7 +12165,10 @@ Hier ist ein *Testbeleg*, um dir zu zeigen, wie es funktioniert:`, }), noReportsTitle: 'Keine übereinstimmenden Berichte', noReportsBody: 'Keiner der von Ihnen ausgewählten Berichte benötigte diese Aktion.', - failedReportsBody: ({count}: {count: number}) => (count === 1 ? '1 Bericht konnte nicht aktualisiert werden.' : `${count} Berichte konnten nicht aktualisiert werden.`), + failedReportsBody: ({count}: {count: number}) => ({ + one: '1 Bericht konnte nicht aktualisiert werden.', + other: `${count} Berichte konnten nicht aktualisiert werden.`, + }), viewFailedReports: 'Berichte anzeigen', failedTitle: 'Es ist ein Fehler aufgetreten', failedBody: 'Diese Aktion konnte nicht gestartet werden. Bitte versuchen Sie es später noch einmal.', diff --git a/src/languages/el.ts b/src/languages/el.ts index 8e17e98c65ab..1594b1af80d1 100644 --- a/src/languages/el.ts +++ b/src/languages/el.ts @@ -12392,7 +12392,10 @@ ${reportName}`, }), noReportsTitle: 'Δεν υπάρχουν αντιστοιχίες αναφορών', noReportsBody: 'Καμία από τις αναφορές που επιλέξατε δεν χρειαζόταν αυτή την ενέργεια.', - failedReportsBody: ({count}: {count: number}) => (count === 1 ? '1 αναφορά δεν μπόρεσε να ενημερωθεί.' : `${count} αναφορές δεν ήταν δυνατό να ενημερωθούν.`), + failedReportsBody: ({count}: {count: number}) => ({ + one: '1 αναφορά δεν μπόρεσε να ενημερωθεί.', + other: `${count} αναφορές δεν ήταν δυνατό να ενημερωθούν.`, + }), viewFailedReports: 'Προβολή αναφορών', failedTitle: 'Κάτι πήγε στραβά', failedBody: 'Αυτή η ενέργεια δεν μπόρεσε να ξεκινήσει. Παρακαλούμε δοκιμάστε ξανά αργότερα.', diff --git a/src/languages/en.ts b/src/languages/en.ts index 6fb7825b7b43..e93a15d8f5a0 100644 --- a/src/languages/en.ts +++ b/src/languages/en.ts @@ -12175,7 +12175,10 @@ const translations = { }), noReportsTitle: 'No matching reports', noReportsBody: 'None of the reports you selected needed this action.', - failedReportsBody: ({count}: {count: number}) => (count === 1 ? "1 report couldn't be updated." : `${count} reports couldn't be updated.`), + failedReportsBody: ({count}: {count: number}) => ({ + one: "1 report couldn't be updated.", + other: `${count} reports couldn't be updated.`, + }), viewFailedReports: 'View reports', failedTitle: 'Something went wrong', failedBody: 'This action could not be started. Please try again later.', diff --git a/src/languages/es.ts b/src/languages/es.ts index 650b4410a76f..f40a4ea1c4c4 100644 --- a/src/languages/es.ts +++ b/src/languages/es.ts @@ -12428,7 +12428,10 @@ ${reportName}`, }), noReportsTitle: 'No hay informes coincidentes', noReportsBody: 'Ninguno de los informes que seleccionaste necesitaba esta acción.', - failedReportsBody: ({count}: {count: number}) => (count === 1 ? 'No se pudo actualizar 1 informe.' : `No se pudieron actualizar ${count} informes.`), + failedReportsBody: ({count}: {count: number}) => ({ + one: 'No se pudo actualizar 1 informe.', + other: `No se pudieron actualizar ${count} informes.`, + }), viewFailedReports: 'Ver informes', failedTitle: 'Algo salió mal', failedBody: 'No se pudo iniciar esta acción. Por favor, inténtalo de nuevo más tarde.', diff --git a/src/languages/fr.ts b/src/languages/fr.ts index c05eed3009eb..87ea5c8f80b5 100644 --- a/src/languages/fr.ts +++ b/src/languages/fr.ts @@ -12195,7 +12195,10 @@ Voici un *reçu test* pour vous montrer comment ça fonctionne :`, }), noReportsTitle: 'Aucune note de frais correspondante', noReportsBody: 'Aucune des notes de frais que vous avez sélectionnées n’avait besoin de cette action.', - failedReportsBody: ({count}: {count: number}) => (count === 1 ? "1 note de frais n'a pas pu être mise à jour." : `${count} notes de frais n'ont pas pu être mises à jour.`), + failedReportsBody: ({count}: {count: number}) => ({ + one: "1 note de frais n'a pas pu être mise à jour.", + other: `${count} notes de frais n'ont pas pu être mises à jour.`, + }), viewFailedReports: 'Afficher les notes de frais', failedTitle: 'Un problème est survenu', failedBody: 'Cette action n’a pas pu être démarrée. Veuillez réessayer plus tard.', diff --git a/src/languages/it.ts b/src/languages/it.ts index 5fe2f4c2c371..eefe93a83703 100644 --- a/src/languages/it.ts +++ b/src/languages/it.ts @@ -12117,7 +12117,10 @@ Ecco una *ricevuta di prova* per mostrarti come funziona:`, }), noReportsTitle: 'Nessun report corrispondente', noReportsBody: 'Nessuno dei report che hai selezionato richiedeva questa azione.', - failedReportsBody: ({count}: {count: number}) => (count === 1 ? '1 report non può essere aggiornato.' : `${count} report non hanno potuto essere aggiornati.`), + failedReportsBody: ({count}: {count: number}) => ({ + one: '1 report non può essere aggiornato.', + other: `${count} report non hanno potuto essere aggiornati.`, + }), viewFailedReports: 'Visualizza report', failedTitle: 'Qualcosa è andato storto', failedBody: 'Questa azione non può essere avviata. Riprova più tardi.', diff --git a/src/languages/ja.ts b/src/languages/ja.ts index 621be9b942d1..d8f4b9c32e5f 100644 --- a/src/languages/ja.ts +++ b/src/languages/ja.ts @@ -11943,7 +11943,10 @@ ${reportName}`, }), noReportsTitle: '一致するレポートはありません', noReportsBody: '選択したレポートには、いずれもこの操作は必要ありませんでした。', - failedReportsBody: ({count}: {count: number}) => (count === 1 ? '1件のレポートを更新できませんでした。' : `${count} 件のレポートを更新できませんでした。`), + failedReportsBody: ({count}: {count: number}) => ({ + one: '1件のレポートを更新できませんでした。', + other: `${count} 件のレポートを更新できませんでした。`, + }), viewFailedReports: 'レポートを表示', failedTitle: '問題が発生しました', failedBody: 'この操作を開始できませんでした。後でもう一度お試しください。', diff --git a/src/languages/nl.ts b/src/languages/nl.ts index 16db332cadce..4e0fa3d8c4a9 100644 --- a/src/languages/nl.ts +++ b/src/languages/nl.ts @@ -12078,7 +12078,10 @@ Hier is een *proefbon* om je te laten zien hoe het werkt:`, }), noReportsTitle: 'Geen overeenkomende rapporten', noReportsBody: 'Geen van de rapporten die je hebt geselecteerd had deze actie nodig.', - failedReportsBody: ({count}: {count: number}) => (count === 1 ? '1 rapport kon niet worden bijgewerkt.' : `${count} rapporten konden niet worden bijgewerkt.`), + failedReportsBody: ({count}: {count: number}) => ({ + one: '1 rapport kon niet worden bijgewerkt.', + other: `${count} rapporten konden niet worden bijgewerkt.`, + }), viewFailedReports: 'Rapporten bekijken', failedTitle: 'Er is iets misgegaan', failedBody: 'Deze actie kon niet worden gestart. Probeer het later opnieuw.', diff --git a/src/languages/pl.ts b/src/languages/pl.ts index 6b54bf9b3347..4405fe88dc76 100644 --- a/src/languages/pl.ts +++ b/src/languages/pl.ts @@ -12096,7 +12096,10 @@ Oto *paragon testowy*, żeby pokazać Ci, jak to działa:`, }), noReportsTitle: 'Brak pasujących raportów', noReportsBody: 'Żaden z wybranych raportów nie wymagał tej akcji.', - failedReportsBody: ({count}: {count: number}) => (count === 1 ? 'Nie udało się zaktualizować 1 raportu.' : `Nie udało się zaktualizować ${count} raportów.`), + failedReportsBody: ({count}: {count: number}) => ({ + one: 'Nie udało się zaktualizować 1 raportu.', + other: `Nie udało się zaktualizować ${count} raportów.`, + }), viewFailedReports: 'Wyświetl raporty', failedTitle: 'Coś poszło nie tak', failedBody: 'Nie udało się rozpocząć tej akcji. Spróbuj ponownie później.', diff --git a/src/languages/pt-BR.ts b/src/languages/pt-BR.ts index dbb78856a37a..45a1d56e7b36 100644 --- a/src/languages/pt-BR.ts +++ b/src/languages/pt-BR.ts @@ -12069,7 +12069,10 @@ Aqui está um *comprovante de teste* para mostrar como funciona:`, }), noReportsTitle: 'Nenhum relatório correspondente', noReportsBody: 'Nenhum dos relatórios que você selecionou precisava dessa ação.', - failedReportsBody: ({count}: {count: number}) => (count === 1 ? '1 relatório não pôde ser atualizado.' : `${count} relatórios não puderam ser atualizados.`), + failedReportsBody: ({count}: {count: number}) => ({ + one: '1 relatório não pôde ser atualizado.', + other: `${count} relatórios não puderam ser atualizados.`, + }), viewFailedReports: 'Ver relatórios', failedTitle: 'Algo deu errado', failedBody: 'Não foi possível iniciar esta ação. Tente novamente mais tarde.', diff --git a/src/languages/zh-hans.ts b/src/languages/zh-hans.ts index 2f40be37b61e..1f11a5b5fea7 100644 --- a/src/languages/zh-hans.ts +++ b/src/languages/zh-hans.ts @@ -11635,7 +11635,10 @@ ${reportName}`, }), noReportsTitle: '没有匹配的报表', noReportsBody: '您选择的报表都不需要执行此操作。', - failedReportsBody: ({count}: {count: number}) => (count === 1 ? '1 份报表无法更新。' : `${count} 份报表无法更新。`), + failedReportsBody: ({count}: {count: number}) => ({ + one: '1 份报表无法更新。', + other: `${count} 份报表无法更新。`, + }), viewFailedReports: '查看报表', failedTitle: '出现问题', failedBody: '无法开始此操作。请稍后重试。', From 67492091e80c552321a3fa1d5716444faf0f271e Mon Sep 17 00:00:00 2001 From: allgandaf Date: Sat, 17 Oct 2026 12:01:52 +0530 Subject: [PATCH 46/73] split the bulk action status modal states into components --- src/components/BulkActionStatusModal.tsx | 256 ++++++++++++++--------- 1 file changed, 156 insertions(+), 100 deletions(-) diff --git a/src/components/BulkActionStatusModal.tsx b/src/components/BulkActionStatusModal.tsx index 1e8691552d9d..ca86b7d1363e 100644 --- a/src/components/BulkActionStatusModal.tsx +++ b/src/components/BulkActionStatusModal.tsx @@ -48,40 +48,89 @@ const DONE_TITLES = { [CONST.BULK_ACTION.DELETE_EXPENSES]: 'bulkAction.deletedExpensesTitle', } as const satisfies Record; -type BulkActionStatusModalProps = { - /** The bulk action ID to subscribe to */ - bulkActionID: string; +type BulkActionRunningProps = { + /** The action that is running */ + action: BulkActionType | undefined; - isVisible: boolean; + /** Callback when the user asks Concierge to send the result */ + onSendFromConcierge: () => void; +}; +function BulkActionRunning({action, onSendFromConcierge}: BulkActionRunningProps) { + const styles = useThemeStyles(); + const {translate} = useLocalize(); + + return ( + <> + + {translate(RUNNING_TITLES[action ?? CONST.SEARCH.BULK_ACTION_TYPES.PAY])} + + + {translate('bulkAction.runningBody')} + + + ); +} + +type BulkActionConciergeProps = { /** Callback when the modal is closed */ onClose: () => void; }; -function BulkActionStatusModal({bulkActionID, isVisible, onClose}: BulkActionStatusModalProps) { +function BulkActionConcierge({onClose}: BulkActionConciergeProps) { const styles = useThemeStyles(); const {translate} = useLocalize(); - // isSmallScreenWidth is needed here because the modal type depends on actual screen width, not layout mode - // eslint-disable-next-line rulesdir/prefer-shouldUseNarrowLayout-instead-of-isSmallScreenWidth - const {isSmallScreenWidth} = useResponsiveLayout(); const {openConciergeAnywhere} = useOpenConciergeAnywhere(); - const bottomSafeAreaPaddingStyle = useBottomSafeSafeAreaPaddingStyle({addBottomSafeAreaPadding: isSmallScreenWidth, addOfflineIndicatorBottomSafeAreaPadding: false, style: styles.m5}); - const [bulkAction] = useOnyx(`${ONYXKEYS.COLLECTION.BULK_ACTION}${bulkActionID}`); - const displayedBulkAction = usePreviousDefined(bulkAction); - if (!bulkAction && !!displayedBulkAction) { - return null; - } + return ( + <> + {translate('bulkAction.conciergeTitle')} + {translate('bulkAction.conciergeBody')} + + + + ); +} - const state = displayedBulkAction?.state; - const action = displayedBulkAction?.action; - const shouldSendFromConcierge = !!displayedBulkAction?.shouldSendFromConcierge; - const total = displayedBulkAction?.total ?? 0; - const failedReportIDs = displayedBulkAction?.failedReportIDs ?? []; - const isRunning = state === CONST.BULK_ACTION.STATE.RUNNING && !shouldSendFromConcierge; - const isConcierge = shouldSendFromConcierge && state !== CONST.BULK_ACTION.STATE.DONE; +type BulkActionDoneProps = { + /** The action that finished */ + action: BulkActionType | undefined; + + /** How many reports the action ran on */ + total: number; + + /** The reports the action couldn't update */ + failedReportIDs: string[]; + + /** Callback when the modal is closed */ + onClose: () => void; +}; + +function BulkActionDone({action, total, failedReportIDs, onClose}: BulkActionDoneProps) { + const styles = useThemeStyles(); + const {translate} = useLocalize(); + const doneTitle = + total === 0 + ? translate('bulkAction.noReportsTitle') + : translate(DONE_TITLES[action ?? CONST.SEARCH.BULK_ACTION_TYPES.PAY], {doneCount: total - failedReportIDs.length, count: total}); - const handleViewFailedReports = () => { + const viewFailedReports = () => { const queryJSON = buildSearchQueryJSON(`type:${CONST.SEARCH.DATA_TYPES.EXPENSE_REPORT} ${CONST.SEARCH.SYNTAX_FILTER_KEYS.REPORT_ID}:${failedReportIDs.join(',')}`); onClose(); if (!queryJSON) { @@ -90,93 +139,83 @@ function BulkActionStatusModal({bulkActionID, isVisible, onClose}: BulkActionSta close(() => Navigation.navigate(ROUTES.SEARCH_ROOT.getRoute({query: buildSearchQueryString(queryJSON)}))); }; - const renderContent = () => { - if (isRunning) { - return ( - <> - - {translate(RUNNING_TITLES[action ?? CONST.SEARCH.BULK_ACTION_TYPES.PAY])} - - - {translate('bulkAction.runningBody')} - - - ); - } - - if (isConcierge) { - return ( + return ( + <> + {doneTitle} + {total === 0 && {translate('bulkAction.noReportsBody')}} + {failedReportIDs.length > 0 && ( <> - {translate('bulkAction.conciergeTitle')} - {translate('bulkAction.conciergeBody')} + {translate('bulkAction.failedReportsBody', {count: failedReportIDs.length})} - - ); - } + )} + + + ); +} - if (state === CONST.BULK_ACTION.STATE.DONE) { - const count = total - failedReportIDs.length; - const doneTitle = total === 0 ? translate('bulkAction.noReportsTitle') : translate(DONE_TITLES[action ?? CONST.SEARCH.BULK_ACTION_TYPES.PAY], {doneCount: count, count: total}); - return ( - <> - {doneTitle} - {total === 0 && {translate('bulkAction.noReportsBody')}} - {failedReportIDs.length > 0 && ( - <> - {translate('bulkAction.failedReportsBody', {count: failedReportIDs.length})} - - - )} - - - ); - } +type BulkActionFailedProps = { + /** Callback when the modal is closed */ + onClose: () => void; +}; - if (state === CONST.BULK_ACTION.STATE.FAILED) { - return ( - <> - {translate('bulkAction.failedTitle')} - {translate('bulkAction.failedBody')} - - - ); - } +function BulkActionFailed({onClose}: BulkActionFailedProps) { + const styles = useThemeStyles(); + const {translate} = useLocalize(); + return ( + <> + {translate('bulkAction.failedTitle')} + {translate('bulkAction.failedBody')} + + + ); +} + +type BulkActionStatusModalProps = { + /** The bulk action ID to subscribe to */ + bulkActionID: string; + + isVisible: boolean; + + /** Callback when the modal is closed */ + onClose: () => void; +}; + +function BulkActionStatusModal({bulkActionID, isVisible, onClose}: BulkActionStatusModalProps) { + const styles = useThemeStyles(); + // isSmallScreenWidth is needed here because the modal type depends on actual screen width, not layout mode + // eslint-disable-next-line rulesdir/prefer-shouldUseNarrowLayout-instead-of-isSmallScreenWidth + const {isSmallScreenWidth} = useResponsiveLayout(); + const bottomSafeAreaPaddingStyle = useBottomSafeSafeAreaPaddingStyle({addBottomSafeAreaPadding: isSmallScreenWidth, addOfflineIndicatorBottomSafeAreaPadding: false, style: styles.m5}); + + const [bulkAction] = useOnyx(`${ONYXKEYS.COLLECTION.BULK_ACTION}${bulkActionID}`); + const displayedBulkAction = usePreviousDefined(bulkAction); + if (!bulkAction && !!displayedBulkAction) { return null; - }; + } + + const state = displayedBulkAction?.state; + const action = displayedBulkAction?.action; + const shouldSendFromConcierge = !!displayedBulkAction?.shouldSendFromConcierge; + const isRunning = state === CONST.BULK_ACTION.STATE.RUNNING && !shouldSendFromConcierge; + const isConcierge = shouldSendFromConcierge && state !== CONST.BULK_ACTION.STATE.DONE; return ( - {renderContent()} + + {isRunning && ( + sendBulkActionSummaryFromConcierge(bulkActionID, displayedBulkAction ?? undefined)} + /> + )} + {isConcierge && } + {state === CONST.BULK_ACTION.STATE.DONE && ( + + )} + {!isConcierge && state === CONST.BULK_ACTION.STATE.FAILED && } + ); } From 60d86a8259a5f23c6496141667e9bf6c4e501d3f Mon Sep 17 00:00:00 2001 From: allgandaf Date: Sat, 17 Oct 2026 12:01:53 +0530 Subject: [PATCH 47/73] add a header comment to the bulk action status modal --- src/components/BulkActionStatusModal.tsx | 1 + 1 file changed, 1 insertion(+) diff --git a/src/components/BulkActionStatusModal.tsx b/src/components/BulkActionStatusModal.tsx index ca86b7d1363e..ef8b302b68bd 100644 --- a/src/components/BulkActionStatusModal.tsx +++ b/src/components/BulkActionStatusModal.tsx @@ -26,6 +26,7 @@ import Button from './Button'; import Modal from './Modal'; import Text from './Text'; +/** Shows the progress and result of a bulk action started from Search "Select all". */ const RUNNING_TITLES = { [CONST.SEARCH.BULK_ACTION_TYPES.APPROVE]: 'bulkAction.approvingTitle', [CONST.SEARCH.BULK_ACTION_TYPES.SUBMIT]: 'bulkAction.submittingTitle', From a14685ce74e02e6588b2d15cad5cd21a1624c1cc Mon Sep 17 00:00:00 2001 From: allgandaf Date: Sat, 17 Oct 2026 12:04:14 +0530 Subject: [PATCH 48/73] leave out reports with a deselected expense when approving or submitting all --- src/hooks/useSearchBulkActions.ts | 14 +++---- tests/unit/hooks/useSearchBulkActionsTest.ts | 42 ++++++++++++++++++++ 2 files changed, 48 insertions(+), 8 deletions(-) diff --git a/src/hooks/useSearchBulkActions.ts b/src/hooks/useSearchBulkActions.ts index a9aaf5a4c042..2661490b96be 100644 --- a/src/hooks/useSearchBulkActions.ts +++ b/src/hooks/useSearchBulkActions.ts @@ -1382,13 +1382,12 @@ function useSearchBulkActions({queryJSON}: UseSearchBulkActionsParams) { // "Select all" can cover more reports than are loaded, so hand the search query to the backend to approve every match. if (areAllMatchingItemsSelected) { - const allMatchingQuery = isExpenseReportType && queryJSON ? getAllMatchingReportQuery(queryJSON, excludedTransactions) : queryJSON; - if (isExpenseReportType && !allMatchingQuery) { + const allMatchingQuery = queryJSON ? getAllMatchingReportQuery(queryJSON, excludedTransactions) : undefined; + if (!allMatchingQuery) { Log.info('[BulkApprove] Dropping bulk approve: report exclusion has no reportID'); return; } - const serializedQuery = allMatchingQuery ? serializeQueryJSONForBackend(allMatchingQuery) : JSON.stringify(allMatchingQuery); - queueBulkApproveReports(serializedQuery); + queueBulkApproveReports(serializeQueryJSONForBackend(allMatchingQuery)); clearSelectedTransactions(); return; } @@ -2845,13 +2844,12 @@ function useSearchBulkActions({queryJSON}: UseSearchBulkActionsParams) { return; } - const allMatchingQuery = isExpenseReportType && queryJSON ? getAllMatchingReportQuery(queryJSON, excludedTransactions) : queryJSON; - if (isExpenseReportType && !allMatchingQuery) { + const allMatchingQuery = queryJSON ? getAllMatchingReportQuery(queryJSON, excludedTransactions) : undefined; + if (!allMatchingQuery) { Log.info('[BulkSubmit] Dropping bulk submit: report exclusion has no reportID'); return; } - const serializedQuery = allMatchingQuery ? serializeQueryJSONForBackend(allMatchingQuery) : JSON.stringify(allMatchingQuery); - queueBulkSubmitReports(serializedQuery); + queueBulkSubmitReports(serializeQueryJSONForBackend(allMatchingQuery)); clearSelectedTransactions(); }, }; diff --git a/tests/unit/hooks/useSearchBulkActionsTest.ts b/tests/unit/hooks/useSearchBulkActionsTest.ts index dc93eb9eb336..71883c529fdf 100644 --- a/tests/unit/hooks/useSearchBulkActionsTest.ts +++ b/tests/unit/hooks/useSearchBulkActionsTest.ts @@ -831,6 +831,27 @@ describe('useSearchBulkActions - Approve under Select all', () => { expect(queueBulkApproveReports).toHaveBeenCalledWith(expect.stringContaining('report2')); }); + it('leaves out the report of an expense the user deselected on an expenses search', async () => { + // Given "Select all" on an expenses search, with the expense on report2 deselected afterwards + mockSelectedTransactions = {tx1: makeSelectedTransaction({action: CONST.SEARCH.ACTION_TYPES.APPROVE, reportID: 'report1'})}; + mockExcludedTransactions = {tx2: makeSelectedTransaction({reportID: 'report2'})}; + + const {result} = renderHook(() => useSearchBulkActions({queryJSON: baseQueryJSON}), {wrapper: OnyxListItemProvider}); + + await waitFor(() => { + expect(result.current.headerButtonsOptions.some((option) => option.value === CONST.SEARCH.BULK_ACTION_TYPES.APPROVE)).toBe(true); + }); + + // When the user selects Approve + const approveOption = result.current.headerButtonsOptions.find((option) => option.value === CONST.SEARCH.BULK_ACTION_TYPES.APPROVE); + await act(async () => { + await approveOption?.onSelected?.(); + }); + + // Then the query sent to the backend excludes report2, since approving it would also approve the deselected expense + expect(queueBulkApproveReports).toHaveBeenCalledWith(expect.stringContaining('report2')); + }); + it('keeps the Approve option when a loaded expense is held', async () => { // Given a held expense on the loaded page, which hides Approve for a normal selection mockSelectedTransactions = {tx1: makeSelectedTransaction({action: CONST.SEARCH.ACTION_TYPES.APPROVE, isHeld: true})}; @@ -925,6 +946,27 @@ describe('useSearchBulkActions - Submit under Select all', () => { expect(queueBulkSubmitReports).toHaveBeenCalledWith(expect.stringContaining('report2')); }); + it('leaves out the report of an expense the user deselected on an expenses search', async () => { + // Given "Select all" on an expenses search, with the expense on report2 deselected afterwards + mockSelectedTransactions = {tx1: makeSelectedTransaction({action: CONST.SEARCH.ACTION_TYPES.SUBMIT, reportID: 'report1'})}; + mockExcludedTransactions = {tx2: makeSelectedTransaction({reportID: 'report2'})}; + + const {result} = renderHook(() => useSearchBulkActions({queryJSON: baseQueryJSON}), {wrapper: OnyxListItemProvider}); + + await waitFor(() => { + expect(result.current.headerButtonsOptions.some((option) => option.value === CONST.SEARCH.BULK_ACTION_TYPES.SUBMIT)).toBe(true); + }); + + // When the user selects Submit + const submitOption = result.current.headerButtonsOptions.find((option) => option.value === CONST.SEARCH.BULK_ACTION_TYPES.SUBMIT); + await act(async () => { + await submitOption?.onSelected?.(); + }); + + // Then the query sent to the backend excludes report2, since submitting it would also submit the deselected expense + expect(queueBulkSubmitReports).toHaveBeenCalledWith(expect.stringContaining('report2')); + }); + it('hides the Submit option when no loaded expense can be submitted', async () => { // Given nothing on the loaded page is waiting to be submitted mockSelectedTransactions = {tx1: makeSelectedTransaction({action: CONST.SEARCH.ACTION_TYPES.VIEW})}; From 7809c2033525bee911323c366cbf0177b9c5dbd3 Mon Sep 17 00:00:00 2001 From: allgandaf Date: Sat, 17 Oct 2026 12:04:18 +0530 Subject: [PATCH 49/73] leave out reports with a deselected expense when paying all --- src/hooks/useSearchBulkActions.ts | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/hooks/useSearchBulkActions.ts b/src/hooks/useSearchBulkActions.ts index 2661490b96be..c8c5cb065b2f 100644 --- a/src/hooks/useSearchBulkActions.ts +++ b/src/hooks/useSearchBulkActions.ts @@ -1685,13 +1685,12 @@ function useSearchBulkActions({queryJSON}: UseSearchBulkActionsParams) { } if (areAllMatchingItemsSelected) { - const allMatchingQuery = isExpenseReportType && queryJSON ? getAllMatchingReportQuery(queryJSON, excludedTransactions) : queryJSON; - if (isExpenseReportType && !allMatchingQuery) { + const allMatchingQuery = queryJSON ? getAllMatchingReportQuery(queryJSON, excludedTransactions) : undefined; + if (!allMatchingQuery) { Log.info('[BulkPay] Dropping bulk pay: report exclusion has no reportID'); return; } - const serializedQuery = allMatchingQuery ? serializeQueryJSONForBackend(allMatchingQuery) : JSON.stringify(allMatchingQuery); - queueBulkPayReports(serializedQuery); + queueBulkPayReports(serializeQueryJSONForBackend(allMatchingQuery)); clearSelectedTransactions(); return; } From 7046751b0748dfa4d021e5e31421776727e930cb Mon Sep 17 00:00:00 2001 From: allgandaf Date: Sat, 17 Oct 2026 12:07:14 +0530 Subject: [PATCH 50/73] recheck the connection after the select all delete confirmation --- src/hooks/useSearchBulkActions.ts | 7 +++++ tests/unit/hooks/useSearchBulkActionsTest.ts | 31 ++++++++++++++++++++ 2 files changed, 38 insertions(+) diff --git a/src/hooks/useSearchBulkActions.ts b/src/hooks/useSearchBulkActions.ts index c8c5cb065b2f..6f5e2edb18b7 100644 --- a/src/hooks/useSearchBulkActions.ts +++ b/src/hooks/useSearchBulkActions.ts @@ -58,6 +58,7 @@ import Log from '@libs/Log'; import {getTransactionsAndReportsFromSearch} from '@libs/MergeTransactionUtils'; import Navigation from '@libs/Navigation/Navigation'; import TransitionTracker from '@libs/Navigation/TransitionTracker'; +import {getIsOffline} from '@libs/NetworkState'; import Parser from '@libs/Parser'; import {getLoginByAccountID} from '@libs/PersonalDetailsUtils'; import {getConnectedIntegration, isAdminOfCardEnabledPolicy, isSubmitPolicy} from '@libs/PolicyUtils'; @@ -1535,6 +1536,11 @@ function useSearchBulkActions({queryJSON}: UseSearchBulkActionsParams) { } // "Select all" can cover more than is loaded, so hand the search query to the backend to delete every match. if (areAllMatchingItemsSelected) { + // The user can go offline while the confirmation is open. + if (getIsOffline()) { + showOfflineModal(); + return; + } const allMatchingQuery = queryJSON ? getAllMatchingExpenseActionQuery(queryJSON, excludedTransactions, currentSearchResults?.data) : undefined; if (!allMatchingQuery) { Log.info('[BulkDelete] Dropping bulk delete: an excluded row could not be resolved'); @@ -1633,6 +1639,7 @@ function useSearchBulkActions({queryJSON}: UseSearchBulkActionsParams) { deleteModalTitle, deleteModalPrompt, areAllMatchingItemsSelected, + showOfflineModal, queryJSON, excludedTransactions, currentSearchResults?.data, diff --git a/tests/unit/hooks/useSearchBulkActionsTest.ts b/tests/unit/hooks/useSearchBulkActionsTest.ts index 71883c529fdf..20056d9f1348 100644 --- a/tests/unit/hooks/useSearchBulkActionsTest.ts +++ b/tests/unit/hooks/useSearchBulkActionsTest.ts @@ -20,6 +20,7 @@ import { queueExportSearchWithTemplate, submitMoneyRequestOnSearch, } from '@libs/actions/Search'; +import type * as NetworkState from '@libs/NetworkState'; import type * as SearchUIUtils from '@libs/SearchUIUtils'; import CONST from '@src/CONST'; @@ -130,6 +131,12 @@ jest.mock('@hooks/useNetwork', () => ({ default: () => ({isOffline: mockIsOffline}), })); +let mockIsNetworkOffline = false; +jest.mock('@libs/NetworkState', () => ({ + ...jest.requireActual('@libs/NetworkState'), + getIsOffline: () => mockIsNetworkOffline, +})); + const mockShowDecisionModal = jest.fn(); jest.mock('@hooks/useDecisionModal', () => ({ __esModule: true, @@ -1151,6 +1158,7 @@ describe('useSearchBulkActions - Delete under Select all', () => { beforeEach(async () => { jest.clearAllMocks(); mockIsOffline = false; + mockIsNetworkOffline = false; mockAreAllMatchingItemsSelected = true; await Onyx.clear(); mockSelectedTransactions = {tx1: makeSelectedTransaction()}; @@ -1206,6 +1214,29 @@ describe('useSearchBulkActions - Delete under Select all', () => { expect(queueBulkDeleteReports).not.toHaveBeenCalled(); }); + it('deletes nothing when the user goes offline while the confirmation is open', async () => { + // Given "Select all" while online, and a user who loses connection before confirming the delete + mockShowConfirmModal.mockImplementation(() => { + mockIsNetworkOffline = true; + return Promise.resolve({action: ModalActions.CONFIRM}); + }); + const {result} = renderHook(() => useSearchBulkActions({queryJSON: baseQueryJSON}), {wrapper: OnyxListItemProvider}); + + // When the user confirms + await waitFor(() => { + expect(result.current.headerButtonsOptions.some((option) => option.value === CONST.SEARCH.BULK_ACTION_TYPES.DELETE)).toBe(true); + }); + const deleteOption = result.current.headerButtonsOptions.find((option) => option.value === CONST.SEARCH.BULK_ACTION_TYPES.DELETE); + await act(async () => { + await deleteOption?.onSelected?.(); + }); + + // Then nothing is queued, since the backend would delete whatever matches once the device reconnects + expect(queueBulkDeleteExpenses).not.toHaveBeenCalled(); + expect(queueBulkDeleteReports).not.toHaveBeenCalled(); + expect(mockShowDecisionModal).toHaveBeenCalled(); + }); + it('deletes nothing when the user cancels the confirmation', async () => { // Given "Select all" and a user who cancels the delete confirmation mockShowConfirmModal.mockResolvedValue({action: ModalActions.CLOSE}); From 3d901ef6ae701e3de27cf5efbcfe8ddf9646f58c Mon Sep 17 00:00:00 2001 From: allgandaf Date: Sat, 17 Oct 2026 12:07:50 +0530 Subject: [PATCH 51/73] drop isExpenseReportType from the approve and pay dependencies --- src/hooks/useSearchBulkActions.ts | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/hooks/useSearchBulkActions.ts b/src/hooks/useSearchBulkActions.ts index 6f5e2edb18b7..8313f786e37b 100644 --- a/src/hooks/useSearchBulkActions.ts +++ b/src/hooks/useSearchBulkActions.ts @@ -1459,7 +1459,6 @@ function useSearchBulkActions({queryJSON}: UseSearchBulkActionsParams) { hash, areAllMatchingItemsSelected, queryJSON, - isExpenseReportType, excludedTransactions, clearSelectedTransactions, userBillingGracePeriodEnds, @@ -1954,7 +1953,6 @@ function useSearchBulkActions({queryJSON}: UseSearchBulkActionsParams) { areAllMatchingItemsSelected, queryJSON, excludedTransactions, - isExpenseReportType, isOffline, isBetaEnabled, isDelegateAccessRestricted, From 8031ba07de72d8b9a547e2fe91ea20b0925ba61e Mon Sep 17 00:00:00 2001 From: allgandaf Date: Sat, 17 Oct 2026 12:08:19 +0530 Subject: [PATCH 52/73] block the select all hold while offline --- src/pages/Search/SearchHoldReasonPage.tsx | 1 + src/pages/iou/HoldReasonFormView.tsx | 7 +++++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/pages/Search/SearchHoldReasonPage.tsx b/src/pages/Search/SearchHoldReasonPage.tsx index e1bc6ac966b5..b75032b18a2a 100644 --- a/src/pages/Search/SearchHoldReasonPage.tsx +++ b/src/pages/Search/SearchHoldReasonPage.tsx @@ -200,6 +200,7 @@ function SearchHoldReasonPage({route}: SearchHoldReasonPageProps) { expenseCount={expenseCount} backTo={backTo} isSubmitter={isSubmitter} + enabledWhenOffline={isBulkHold || !areAllMatchingItemsSelected} /> ); } diff --git a/src/pages/iou/HoldReasonFormView.tsx b/src/pages/iou/HoldReasonFormView.tsx index 5c653dcb05b9..abaa1667cba3 100644 --- a/src/pages/iou/HoldReasonFormView.tsx +++ b/src/pages/iou/HoldReasonFormView.tsx @@ -31,9 +31,12 @@ type HoldReasonFormViewProps = { /** Whether the current user is the submitter of the expense */ isSubmitter?: boolean; + + /** Whether the form can be submitted while offline (defaults to true) */ + enabledWhenOffline?: boolean; }; -function HoldReasonFormView({backTo, validate, onSubmit, expenseCount = 1, isSubmitter = true}: HoldReasonFormViewProps) { +function HoldReasonFormView({backTo, validate, onSubmit, expenseCount = 1, isSubmitter = true, enabledWhenOffline = true}: HoldReasonFormViewProps) { const styles = useThemeStyles(); const {translate} = useLocalize(); const {inputCallbackRef} = useAutoFocusInput(); @@ -54,7 +57,7 @@ function HoldReasonFormView({backTo, validate, onSubmit, expenseCount = 1, isSub style={[styles.flexGrow1, styles.ph5]} onSubmit={onSubmit} validate={validate} - enabledWhenOffline + enabledWhenOffline={enabledWhenOffline} shouldHideFixErrorsAlert > {translate(isSubmitter ? 'iou.explainHold' : 'iou.explainHoldApprover', {count: expenseCount})} From 760e7a7a4cfada5e577096476b8ce3eecfec17c0 Mon Sep 17 00:00:00 2001 From: allgandaf Date: Sat, 17 Oct 2026 12:08:36 +0530 Subject: [PATCH 53/73] block the select all reject while offline --- src/pages/Search/SearchRejectReasonPage.tsx | 1 + src/pages/iou/RejectReasonFormView.tsx | 7 +++++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/pages/Search/SearchRejectReasonPage.tsx b/src/pages/Search/SearchRejectReasonPage.tsx index ce7891a4069b..c86023ab86e3 100644 --- a/src/pages/Search/SearchRejectReasonPage.tsx +++ b/src/pages/Search/SearchRejectReasonPage.tsx @@ -147,6 +147,7 @@ function SearchRejectReasonPage({route}: SearchRejectReasonPageProps) { ); } diff --git a/src/pages/iou/RejectReasonFormView.tsx b/src/pages/iou/RejectReasonFormView.tsx index 96d4670f0541..e7d231fc4fcb 100644 --- a/src/pages/iou/RejectReasonFormView.tsx +++ b/src/pages/iou/RejectReasonFormView.tsx @@ -26,9 +26,12 @@ type RejectReasonFormViewProps = { /** Link to previous page */ backTo?: Route; + + /** Whether the form can be submitted while offline (defaults to true) */ + enabledWhenOffline?: boolean; }; -function RejectReasonFormView({backTo, validate, onSubmit}: RejectReasonFormViewProps) { +function RejectReasonFormView({backTo, validate, onSubmit, enabledWhenOffline = true}: RejectReasonFormViewProps) { const {translate} = useLocalize(); const styles = useThemeStyles(); const {inputCallbackRef} = useAutoFocusInput(); @@ -49,7 +52,7 @@ function RejectReasonFormView({backTo, validate, onSubmit}: RejectReasonFormView style={[styles.flexGrow1, styles.ph5]} onSubmit={onSubmit} validate={validate} - enabledWhenOffline + enabledWhenOffline={enabledWhenOffline} shouldHideFixErrorsAlert buttonVariant={CONST.BUTTON_VARIANT.DANGER} > From 429d3388c9a237c63611fffe4ffcb967271fc500 Mon Sep 17 00:00:00 2001 From: allgandaf Date: Sat, 17 Oct 2026 12:09:23 +0530 Subject: [PATCH 54/73] test that the select all hold form is blocked offline --- tests/unit/SearchHoldReasonPageTest.tsx | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/tests/unit/SearchHoldReasonPageTest.tsx b/tests/unit/SearchHoldReasonPageTest.tsx index 4495145ab674..9beda89dd96e 100644 --- a/tests/unit/SearchHoldReasonPageTest.tsx +++ b/tests/unit/SearchHoldReasonPageTest.tsx @@ -31,10 +31,12 @@ const mockQueryJSON: SearchQueryJSON = { const mockClearSelectedTransactions = jest.fn(); let mockAreAllMatchingItemsSelected = false; let mockSubmitHoldReason: ((values: {comment: string}) => void) | undefined; +let mockEnabledWhenOffline: boolean | undefined; jest.mock('@pages/iou/HoldReasonFormView', () => { - function MockHoldReasonFormView({onSubmit}: {onSubmit: (values: {comment: string}) => void}) { + function MockHoldReasonFormView({onSubmit, enabledWhenOffline}: {onSubmit: (values: {comment: string}) => void; enabledWhenOffline?: boolean}) { mockSubmitHoldReason = onSubmit; + mockEnabledWhenOffline = enabledWhenOffline; return null; } return MockHoldReasonFormView; @@ -81,6 +83,7 @@ describe('SearchHoldReasonPage', () => { beforeEach(async () => { jest.clearAllMocks(); mockSubmitHoldReason = undefined; + mockEnabledWhenOffline = undefined; await Onyx.clear(); }); @@ -110,4 +113,22 @@ describe('SearchHoldReasonPage', () => { expect(putOnHold).toHaveBeenCalledTimes(1); expect(queueBulkHoldExpenses).not.toHaveBeenCalled(); }); + + it('keeps the reason form from submitting offline when Select all is checked', async () => { + // Given the hold reason page opened with "Select all" checked + renderPage(true); + await waitForBatchedUpdatesWithAct(); + + // Then the form is disabled offline, since the backend would hold whatever matches once the device reconnects + expect(mockEnabledWhenOffline).toBe(false); + }); + + it('lets the reason form submit offline when Select all is not checked', async () => { + // Given the hold reason page opened with a manual selection + renderPage(false); + await waitForBatchedUpdatesWithAct(); + + // Then the form still works offline, since each selected expense is updated optimistically + expect(mockEnabledWhenOffline).toBe(true); + }); }); From a00158e24b7330eaaa222aee0d30b5d0d05137fe Mon Sep 17 00:00:00 2001 From: allgandaf Date: Sat, 17 Oct 2026 12:09:23 +0530 Subject: [PATCH 55/73] test that the select all reject form is blocked offline --- tests/unit/SearchRejectReasonPageTest.tsx | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/tests/unit/SearchRejectReasonPageTest.tsx b/tests/unit/SearchRejectReasonPageTest.tsx index d7d90b602e54..7ef7eb98a1cc 100644 --- a/tests/unit/SearchRejectReasonPageTest.tsx +++ b/tests/unit/SearchRejectReasonPageTest.tsx @@ -31,10 +31,12 @@ const mockQueryJSON: SearchQueryJSON = { const mockClearSelectedTransactions = jest.fn(); let mockAreAllMatchingItemsSelected = false; let mockSubmitRejectReason: ((values: {comment: string}) => void) | undefined; +let mockEnabledWhenOffline: boolean | undefined; jest.mock('@pages/iou/RejectReasonFormView', () => { - function MockRejectReasonFormView({onSubmit}: {onSubmit: (values: {comment: string}) => void}) { + function MockRejectReasonFormView({onSubmit, enabledWhenOffline}: {onSubmit: (values: {comment: string}) => void; enabledWhenOffline?: boolean}) { mockSubmitRejectReason = onSubmit; + mockEnabledWhenOffline = enabledWhenOffline; return null; } return MockRejectReasonFormView; @@ -79,6 +81,7 @@ describe('SearchRejectReasonPage', () => { beforeEach(async () => { jest.clearAllMocks(); mockSubmitRejectReason = undefined; + mockEnabledWhenOffline = undefined; await Onyx.clear(); }); @@ -108,4 +111,22 @@ describe('SearchRejectReasonPage', () => { expect(rejectMoneyRequestsOnSearch).toHaveBeenCalledTimes(1); expect(queueBulkRejectExpenses).not.toHaveBeenCalled(); }); + + it('keeps the reason form from submitting offline when Select all is checked', async () => { + // Given the reject reason page opened with "Select all" checked + renderPage(true); + await waitForBatchedUpdatesWithAct(); + + // Then the form is disabled offline, since the backend would reject whatever matches once the device reconnects + expect(mockEnabledWhenOffline).toBe(false); + }); + + it('lets the reason form submit offline when Select all is not checked', async () => { + // Given the reject reason page opened with a manual selection + renderPage(false); + await waitForBatchedUpdatesWithAct(); + + // Then the form still works offline, since each selected expense is updated optimistically + expect(mockEnabledWhenOffline).toBe(true); + }); }); From bfa9c487e271420033a37abbaab7b9df48d4f8a7 Mon Sep 17 00:00:00 2001 From: allgandaf Date: Tue, 20 Oct 2026 09:50:55 +0530 Subject: [PATCH 56/73] move approve and submit to their own PR --- src/hooks/useSearchBulkActions.ts | 85 +----- .../QueueBulkApproveReportsParams.ts | 11 - .../QueueBulkSubmitReportsParams.ts | 11 - src/libs/API/parameters/index.ts | 2 - src/libs/API/types.ts | 4 - src/libs/actions/Search.ts | 20 -- tests/unit/hooks/useSearchBulkActionsTest.ts | 258 ------------------ 7 files changed, 10 insertions(+), 381 deletions(-) delete mode 100644 src/libs/API/parameters/QueueBulkApproveReportsParams.ts delete mode 100644 src/libs/API/parameters/QueueBulkSubmitReportsParams.ts diff --git a/src/hooks/useSearchBulkActions.ts b/src/hooks/useSearchBulkActions.ts index 14dc3c3e8f27..3a9011cdc52a 100644 --- a/src/hooks/useSearchBulkActions.ts +++ b/src/hooks/useSearchBulkActions.ts @@ -35,12 +35,10 @@ import { getSearchPayOnyxData, getTotalFormattedAmount, isCurrencySupportWalletBulkPay, - queueBulkApproveReports, queueBulkDeleteExpenses, queueBulkDeleteReports, queueBulkMarkAsExported, queueBulkPayReports, - queueBulkSubmitReports, queueBulkUnholdExpenses, queueExportSearchItemsToCSV, queueExportSearchWithTemplate, @@ -1396,18 +1394,6 @@ function useSearchBulkActions({queryJSON}: UseSearchBulkActionsParams) { return; } - // "Select all" can cover more reports than are loaded, so hand the search query to the backend to approve every match. - if (areAllMatchingItemsSelected) { - const allMatchingQuery = queryJSON ? getAllMatchingReportQuery(queryJSON, excludedTransactions) : undefined; - if (!allMatchingQuery) { - Log.info('[BulkApprove] Dropping bulk approve: report exclusion has no reportID'); - return; - } - queueBulkApproveReports(serializeQueryJSONForBackend(allMatchingQuery)); - clearSelectedTransactions(); - return; - } - const reportIDList = !selectedReports.length ? Object.values(selectedTransactions).map((transaction) => transaction.reportID) : (selectedReports?.filter((report) => !!report).map((report) => report.reportID) ?? []); @@ -1472,9 +1458,6 @@ function useSearchBulkActions({queryJSON}: UseSearchBulkActionsParams) { selectedReports, selectedTransactions, hash, - areAllMatchingItemsSelected, - queryJSON, - excludedTransactions, clearSelectedTransactions, userBillingGracePeriodEnds, ownerBillingGracePeriodEnd, @@ -2674,17 +2657,6 @@ function useSearchBulkActions({queryJSON}: UseSearchBulkActionsParams) { onSelected: () => onBulkPaySelected(undefined), }; - const hasSubmitPolicyTransactions = areIncludedSubmitPolicyTransactions(selectedTransactions, selectedReports, policies); - const approveButtonOption: DropdownOption = { - icon: expensifyIcons.ThumbsUp, - text: translate('search.bulkActions.approve'), - value: CONST.SEARCH.BULK_ACTION_TYPES.APPROVE, - shouldCloseModalOnSelect: true, - onSelected: () => { - handleApproveWithDEWCheck(); - }, - }; - const rejectOption: DropdownOption = { icon: expensifyIcons.ThumbsDown, text: translate('search.bulkActions.reject'), @@ -2833,57 +2805,11 @@ function useSearchBulkActions({queryJSON}: UseSearchBulkActionsParams) { }; if (areAllMatchingItemsSelected) { - // The backend only approves the matching reports the user can approve, so one approvable loaded item is enough to offer it. - const hasLoadedApprovableItem = selectedReports.length - ? selectedReports.some((report) => report.canApprove) - : selectedTransactionsKeys.some((id) => selectedTransactions[id].action === CONST.SEARCH.ACTION_TYPES.APPROVE); - const shouldShowApproveOptionForAllMatchingItems = !isOffline && isExpenseOrReportSearch && !hasSubmitPolicyTransactions && hasLoadedApprovableItem; - // The backend only submits the matching reports the user can submit, so one submittable loaded item is enough to offer it. - // Submit plan workspaces pick an approver per report and Mark as done is a different action, so neither is sent to the backend. - const hasLoadedSubmittableItem = selectedReports.length - ? selectedReports.some((report) => report.canSubmit) - : selectedTransactionsKeys.some((id) => selectedTransactions[id].action === CONST.SEARCH.ACTION_TYPES.SUBMIT); - const shouldShowSubmitOptionForAllMatchingItems = - !isOffline && isExpenseOrReportSearch && !doSelectedItemsBelongToSubmitPolicy && noReportsShouldMarkAsDone && hasLoadedSubmittableItem; - const submitAllMatchingItemsOption: DropdownOption = { - icon: expensifyIcons.Send, - text: translate('common.submit'), - value: CONST.SEARCH.BULK_ACTION_TYPES.SUBMIT, - shouldCloseModalOnSelect: true, - onSelected: () => { - if (isOffline) { - showOfflineModal(); - return; - } - - const itemList = selectedReports.length ? selectedReports : Object.values(selectedTransactions); - const restrictedPolicyID = getRestrictedPolicyID(itemList, userBillingGracePeriodEnds, ownerBillingGracePeriodEnd, amountOwed, policies, accountID); - if (restrictedPolicyID) { - Navigation.navigate(ROUTES.RESTRICTED_ACTION.getRoute(restrictedPolicyID)); - return; - } - - const allMatchingQuery = queryJSON ? getAllMatchingReportQuery(queryJSON, excludedTransactions) : undefined; - if (!allMatchingQuery) { - Log.info('[BulkSubmit] Dropping bulk submit: report exclusion has no reportID'); - return; - } - queueBulkSubmitReports(serializeQueryJSONForBackend(allMatchingQuery)); - clearSelectedTransactions(); - }, - }; - // Offer an all-matching move only when no rows are excluded and unloaded matches are unreported. // The backend rejects the entire move if any matching expense is invalid const isAllMatchingSelectionMovable = isEmptyObject(excludedTransactions) && (!hasUnloadedMatchingExpenses || isUnreportedOnlyQuery); const allMatchingOptions: Array> = []; - if (shouldShowApproveOptionForAllMatchingItems) { - allMatchingOptions.push(approveButtonOption); - } - if (shouldShowSubmitOptionForAllMatchingItems) { - allMatchingOptions.push(submitAllMatchingItemsOption); - } if (shouldShowPayOption) { allMatchingOptions.push(payButtonOption); } @@ -2987,6 +2913,7 @@ function useSearchBulkActions({queryJSON}: UseSearchBulkActionsParams) { const areSelectedTransactionsIncludedInReports = selectedTransactionsKeys.every((id) => selectedTransactions[id].reportID ? selectedReportIDs.includes(selectedTransactions[id].reportID) : true, ); + const hasSubmitPolicyTransactions = areIncludedSubmitPolicyTransactions(selectedTransactions, selectedReports, policies); const shouldShowApproveOption = !isOffline && !isAnyTransactionOnHold && @@ -2997,7 +2924,15 @@ function useSearchBulkActions({queryJSON}: UseSearchBulkActionsParams) { : selectedTransactionsKeys.every((id) => selectedTransactions[id].action === CONST.SEARCH.ACTION_TYPES.APPROVE)); if (shouldShowApproveOption) { - options.push(approveButtonOption); + options.push({ + icon: expensifyIcons.ThumbsUp, + text: translate('search.bulkActions.approve'), + value: CONST.SEARCH.BULK_ACTION_TYPES.APPROVE, + shouldCloseModalOnSelect: true, + onSelected: () => { + handleApproveWithDEWCheck(); + }, + }); } const hasNoRejectedTransaction = selectedTransactionsKeys.every( diff --git a/src/libs/API/parameters/QueueBulkApproveReportsParams.ts b/src/libs/API/parameters/QueueBulkApproveReportsParams.ts deleted file mode 100644 index ca63571d96fe..000000000000 --- a/src/libs/API/parameters/QueueBulkApproveReportsParams.ts +++ /dev/null @@ -1,11 +0,0 @@ -import type {SearchQueryString} from '@components/Search/types'; - -type QueueBulkApproveReportsParams = { - /** Serialized search query describing every report to approve, so the backend can page through all matches instead of relying on a client-side list */ - jsonQuery: SearchQueryString; - - /** ID of the bulk action record the backend updates as the approvals finish */ - bulkActionID: string; -}; - -export default QueueBulkApproveReportsParams; diff --git a/src/libs/API/parameters/QueueBulkSubmitReportsParams.ts b/src/libs/API/parameters/QueueBulkSubmitReportsParams.ts deleted file mode 100644 index 6b49003c2a02..000000000000 --- a/src/libs/API/parameters/QueueBulkSubmitReportsParams.ts +++ /dev/null @@ -1,11 +0,0 @@ -import type {SearchQueryString} from '@components/Search/types'; - -type QueueBulkSubmitReportsParams = { - /** Serialized search query describing every report to submit, so the backend can page through all matches instead of relying on a client-side list */ - jsonQuery: SearchQueryString; - - /** ID of the bulk action record the backend updates as the submissions finish */ - bulkActionID: string; -}; - -export default QueueBulkSubmitReportsParams; diff --git a/src/libs/API/parameters/index.ts b/src/libs/API/parameters/index.ts index 8af5d1f07d5c..1ca3b12b5e62 100644 --- a/src/libs/API/parameters/index.ts +++ b/src/libs/API/parameters/index.ts @@ -659,8 +659,6 @@ export type {default as ExportSearchWithTemplateParams} from './ExportSearchWith export type {default as QueueExportSearchItemsToCSVParams} from './QueueExportSearchItemsToCSVParams'; export type {default as QueueExportSearchWithTemplateParams} from './QueueExportSearchWithTemplateParams'; export type {default as QueueBulkPayReportsParams} from './QueueBulkPayReportsParams'; -export type {default as QueueBulkApproveReportsParams} from './QueueBulkApproveReportsParams'; -export type {default as QueueBulkSubmitReportsParams} from './QueueBulkSubmitReportsParams'; export type {default as QueueBulkHoldExpensesParams} from './QueueBulkHoldExpensesParams'; export type {default as QueueBulkUnholdExpensesParams} from './QueueBulkUnholdExpensesParams'; export type {default as QueueBulkRejectExpensesParams} from './QueueBulkRejectExpensesParams'; diff --git a/src/libs/API/types.ts b/src/libs/API/types.ts index 7f9cc281b02a..55593aa3b9cd 100644 --- a/src/libs/API/types.ts +++ b/src/libs/API/types.ts @@ -660,8 +660,6 @@ const WRITE_COMMANDS = { QUEUE_EXPORT_SEARCH_ITEMS_TO_CSV: 'QueueExportSearchToCSV', QUEUE_EXPORT_SEARCH_WITH_TEMPLATE: 'QueueExportSearchWithTemplate', QUEUE_BULK_PAY_REPORTS: 'QueueBulkPayReports', - QUEUE_BULK_APPROVE_REPORTS: 'QueueBulkApproveReports', - QUEUE_BULK_SUBMIT_REPORTS: 'QueueBulkSubmitReports', QUEUE_BULK_HOLD_EXPENSES: 'QueueBulkHoldExpenses', QUEUE_BULK_UNHOLD_EXPENSES: 'QueueBulkUnholdExpenses', QUEUE_BULK_REJECT_EXPENSES: 'QueueBulkRejectExpenses', @@ -1511,8 +1509,6 @@ type WriteCommandParameters = { [WRITE_COMMANDS.QUEUE_EXPORT_SEARCH_ITEMS_TO_CSV]: Parameters.QueueExportSearchItemsToCSVParams; [WRITE_COMMANDS.QUEUE_EXPORT_SEARCH_WITH_TEMPLATE]: Parameters.QueueExportSearchWithTemplateParams; [WRITE_COMMANDS.QUEUE_BULK_PAY_REPORTS]: Parameters.QueueBulkPayReportsParams; - [WRITE_COMMANDS.QUEUE_BULK_APPROVE_REPORTS]: Parameters.QueueBulkApproveReportsParams; - [WRITE_COMMANDS.QUEUE_BULK_SUBMIT_REPORTS]: Parameters.QueueBulkSubmitReportsParams; [WRITE_COMMANDS.QUEUE_BULK_HOLD_EXPENSES]: Parameters.QueueBulkHoldExpensesParams; [WRITE_COMMANDS.QUEUE_BULK_UNHOLD_EXPENSES]: Parameters.QueueBulkUnholdExpensesParams; [WRITE_COMMANDS.QUEUE_BULK_REJECT_EXPENSES]: Parameters.QueueBulkRejectExpensesParams; diff --git a/src/libs/actions/Search.ts b/src/libs/actions/Search.ts index 78a07b044cea..7c033eabfb94 100644 --- a/src/libs/actions/Search.ts +++ b/src/libs/actions/Search.ts @@ -2261,24 +2261,6 @@ function queueBulkPayReports(jsonQuery: string) { write(WRITE_COMMANDS.QUEUE_BULK_PAY_REPORTS, {jsonQuery, bulkActionID}, onyxData); } -/** - * Queues a bulk approval for every report matching the given search query. The backend pages through all matches itself, - * so this covers reports beyond the currently loaded page(s) when "Select all" is checked in Search. - */ -function queueBulkApproveReports(jsonQuery: string) { - const {bulkActionID, onyxData} = buildBulkActionOnyxData(CONST.SEARCH.BULK_ACTION_TYPES.APPROVE); - write(WRITE_COMMANDS.QUEUE_BULK_APPROVE_REPORTS, {jsonQuery, bulkActionID}, onyxData); -} - -/** - * Queues a bulk submit for every report matching the given search query. The backend pages through all matches itself, - * so this covers reports beyond the currently loaded page(s) when "Select all" is checked in Search. - */ -function queueBulkSubmitReports(jsonQuery: string) { - const {bulkActionID, onyxData} = buildBulkActionOnyxData(CONST.SEARCH.BULK_ACTION_TYPES.SUBMIT); - write(WRITE_COMMANDS.QUEUE_BULK_SUBMIT_REPORTS, {jsonQuery, bulkActionID}, onyxData); -} - /** Queues a hold, with the given reason, for every expense matching the search query that the user can hold. */ function queueBulkHoldExpenses(jsonQuery: string, comment: string, excludedTransactionIDList: string[]) { const {bulkActionID, onyxData} = buildBulkActionOnyxData(CONST.SEARCH.BULK_ACTION_TYPES.HOLD); @@ -2760,8 +2742,6 @@ export { queueExportSearchItemsToCSV, queueExportSearchWithTemplate, queueBulkPayReports, - queueBulkApproveReports, - queueBulkSubmitReports, queueBulkHoldExpenses, queueBulkUnholdExpenses, queueBulkRejectExpenses, diff --git a/tests/unit/hooks/useSearchBulkActionsTest.ts b/tests/unit/hooks/useSearchBulkActionsTest.ts index 20056d9f1348..7b2c641b0f7c 100644 --- a/tests/unit/hooks/useSearchBulkActionsTest.ts +++ b/tests/unit/hooks/useSearchBulkActionsTest.ts @@ -7,18 +7,14 @@ import type {SearchQueryJSON, SelectedReports, SelectedTransactions} from '@comp import useSearchBulkActions from '@hooks/useSearchBulkActions'; import {unholdRequest} from '@libs/actions/IOU/Hold'; -import {approveMoneyRequest} from '@libs/actions/IOU/ReportWorkflow'; import { exportSearchItemsToCSV, getExportTemplates, - queueBulkApproveReports, queueBulkDeleteExpenses, queueBulkDeleteReports, - queueBulkSubmitReports, queueBulkUnholdExpenses, queueExportSearchItemsToCSV, queueExportSearchWithTemplate, - submitMoneyRequestOnSearch, } from '@libs/actions/Search'; import type * as NetworkState from '@libs/NetworkState'; import type * as SearchUIUtils from '@libs/SearchUIUtils'; @@ -47,10 +43,8 @@ jest.mock('@libs/actions/Search', () => ({ exportSearchItemsToCSV: jest.fn(), queueExportSearchItemsToCSV: jest.fn(() => 'mock-export-id'), queueExportSearchWithTemplate: jest.fn(() => 'mock-template-export-id'), - queueBulkApproveReports: jest.fn(), queueBulkDeleteExpenses: jest.fn(), queueBulkDeleteReports: jest.fn(), - queueBulkSubmitReports: jest.fn(), queueBulkUnholdExpenses: jest.fn(), getSearchApproveOnyxData: jest.fn(() => ({})), getSearchPayOnyxData: jest.fn(() => ({})), @@ -72,10 +66,6 @@ jest.mock('@libs/actions/IOU/Hold', () => ({ unholdRequest: jest.fn(), })); -jest.mock('@libs/actions/IOU/ReportWorkflow', () => ({ - approveMoneyRequest: jest.fn(), -})); - jest.mock('@libs/actions/MergeTransaction', () => ({ setupMergeTransactionDataAndNavigate: jest.fn(), })); @@ -771,254 +761,6 @@ describe('useSearchBulkActions - CSV export flow', () => { }); }); -describe('useSearchBulkActions - Approve under Select all', () => { - beforeAll(() => { - Onyx.init({keys: ONYXKEYS}); - }); - - beforeEach(async () => { - jest.clearAllMocks(); - mockIsOffline = false; - mockAreAllMatchingItemsSelected = true; - await Onyx.clear(); - mockSelectedTransactions = {}; - mockExcludedTransactions = {}; - mockSelectedReports = []; - mockCurrentSearchResults = undefined; - mockGetExportTemplates.mockReturnValue({customTemplates: [], defaultTemplates: []}); - - await Onyx.merge(ONYXKEYS.SESSION, {accountID: CURRENT_USER_ACCOUNT_ID, email: 'test@example.com'}); - }); - - afterEach(async () => { - await Onyx.clear(); - }); - - it('queues a server-side bulk approval instead of approving per report', async () => { - // Given "Select all" is checked with an approvable expense loaded, so the selection can span more reports than are on the page - mockSelectedTransactions = {tx1: makeSelectedTransaction({action: CONST.SEARCH.ACTION_TYPES.APPROVE})}; - - const {result} = renderHook(() => useSearchBulkActions({queryJSON: baseQueryJSON}), {wrapper: OnyxListItemProvider}); - - await waitFor(() => { - expect(result.current.headerButtonsOptions.some((option) => option.value === CONST.SEARCH.BULK_ACTION_TYPES.APPROVE)).toBe(true); - }); - - // When the user selects Approve - const approveOption = result.current.headerButtonsOptions.find((option) => option.value === CONST.SEARCH.BULK_ACTION_TYPES.APPROVE); - await act(async () => { - await approveOption?.onSelected?.(); - }); - - // Then the approval is handed to the backend via the search query, not looped per loaded report - expect(queueBulkApproveReports).toHaveBeenCalledTimes(1); - expect(queueBulkApproveReports).toHaveBeenCalledWith(expect.any(String)); - expect(approveMoneyRequest).not.toHaveBeenCalled(); - expect(mockClearSelectedTransactions).toHaveBeenCalled(); - }); - - it('leaves out reports the user deselected from the bulk approval', async () => { - // Given "Select all" on a reports search, with one report deselected afterwards - mockSelectedTransactions = {tx1: makeSelectedTransaction({action: CONST.SEARCH.ACTION_TYPES.APPROVE, reportID: 'report1'})}; - mockExcludedTransactions = {tx2: makeSelectedTransaction({reportID: 'report2'})}; - - const {result} = renderHook(() => useSearchBulkActions({queryJSON: expenseReportQueryJSON}), {wrapper: OnyxListItemProvider}); - - await waitFor(() => { - expect(result.current.headerButtonsOptions.some((option) => option.value === CONST.SEARCH.BULK_ACTION_TYPES.APPROVE)).toBe(true); - }); - - // When the user selects Approve - const approveOption = result.current.headerButtonsOptions.find((option) => option.value === CONST.SEARCH.BULK_ACTION_TYPES.APPROVE); - await act(async () => { - await approveOption?.onSelected?.(); - }); - - // Then the query sent to the backend excludes the deselected report, so it isn't approved - expect(queueBulkApproveReports).toHaveBeenCalledWith(expect.stringContaining('report2')); - }); - - it('leaves out the report of an expense the user deselected on an expenses search', async () => { - // Given "Select all" on an expenses search, with the expense on report2 deselected afterwards - mockSelectedTransactions = {tx1: makeSelectedTransaction({action: CONST.SEARCH.ACTION_TYPES.APPROVE, reportID: 'report1'})}; - mockExcludedTransactions = {tx2: makeSelectedTransaction({reportID: 'report2'})}; - - const {result} = renderHook(() => useSearchBulkActions({queryJSON: baseQueryJSON}), {wrapper: OnyxListItemProvider}); - - await waitFor(() => { - expect(result.current.headerButtonsOptions.some((option) => option.value === CONST.SEARCH.BULK_ACTION_TYPES.APPROVE)).toBe(true); - }); - - // When the user selects Approve - const approveOption = result.current.headerButtonsOptions.find((option) => option.value === CONST.SEARCH.BULK_ACTION_TYPES.APPROVE); - await act(async () => { - await approveOption?.onSelected?.(); - }); - - // Then the query sent to the backend excludes report2, since approving it would also approve the deselected expense - expect(queueBulkApproveReports).toHaveBeenCalledWith(expect.stringContaining('report2')); - }); - - it('keeps the Approve option when a loaded expense is held', async () => { - // Given a held expense on the loaded page, which hides Approve for a normal selection - mockSelectedTransactions = {tx1: makeSelectedTransaction({action: CONST.SEARCH.ACTION_TYPES.APPROVE, isHeld: true})}; - - const {result} = renderHook(() => useSearchBulkActions({queryJSON: baseQueryJSON}), {wrapper: OnyxListItemProvider}); - - // Then Approve is still offered, because the backend skips reports it cannot approve - await waitFor(() => { - expect(result.current.headerButtonsOptions.some((option) => option.value === CONST.SEARCH.BULK_ACTION_TYPES.APPROVE)).toBe(true); - }); - }); - - it('hides the Approve option when no loaded expense can be approved', async () => { - // Given nothing on the loaded page is awaiting the user's approval - mockSelectedTransactions = {tx1: makeSelectedTransaction({action: CONST.SEARCH.ACTION_TYPES.VIEW})}; - - const {result} = renderHook(() => useSearchBulkActions({queryJSON: baseQueryJSON}), {wrapper: OnyxListItemProvider}); - - await waitFor(() => { - expect(result.current.headerButtonsOptions.length).toBeGreaterThan(0); - }); - - // Then Approve is not offered - expect(result.current.headerButtonsOptions.some((option) => option.value === CONST.SEARCH.BULK_ACTION_TYPES.APPROVE)).toBe(false); - }); -}); - -describe('useSearchBulkActions - Submit under Select all', () => { - beforeAll(() => { - Onyx.init({keys: ONYXKEYS}); - }); - - beforeEach(async () => { - jest.clearAllMocks(); - mockIsOffline = false; - mockAreAllMatchingItemsSelected = true; - await Onyx.clear(); - mockSelectedTransactions = {}; - mockExcludedTransactions = {}; - mockSelectedReports = []; - mockCurrentSearchResults = undefined; - mockGetExportTemplates.mockReturnValue({customTemplates: [], defaultTemplates: []}); - - await Onyx.merge(ONYXKEYS.SESSION, {accountID: CURRENT_USER_ACCOUNT_ID, email: 'test@example.com'}); - }); - - afterEach(async () => { - await Onyx.clear(); - }); - - it('queues a server-side bulk submit instead of submitting per report', async () => { - // Given "Select all" is checked with a submittable expense loaded, so the selection can span more reports than are on the page - mockSelectedTransactions = {tx1: makeSelectedTransaction({action: CONST.SEARCH.ACTION_TYPES.SUBMIT})}; - - const {result} = renderHook(() => useSearchBulkActions({queryJSON: baseQueryJSON}), {wrapper: OnyxListItemProvider}); - - await waitFor(() => { - expect(result.current.headerButtonsOptions.some((option) => option.value === CONST.SEARCH.BULK_ACTION_TYPES.SUBMIT)).toBe(true); - }); - - // When the user selects Submit - const submitOption = result.current.headerButtonsOptions.find((option) => option.value === CONST.SEARCH.BULK_ACTION_TYPES.SUBMIT); - await act(async () => { - await submitOption?.onSelected?.(); - }); - - // Then the submit is handed to the backend via the search query, not looped per loaded report - expect(queueBulkSubmitReports).toHaveBeenCalledTimes(1); - expect(queueBulkSubmitReports).toHaveBeenCalledWith(expect.any(String)); - expect(submitMoneyRequestOnSearch).not.toHaveBeenCalled(); - expect(mockClearSelectedTransactions).toHaveBeenCalled(); - }); - - it('leaves out reports the user deselected from the bulk submit', async () => { - // Given "Select all" on a reports search, with one report deselected afterwards - mockSelectedTransactions = {tx1: makeSelectedTransaction({action: CONST.SEARCH.ACTION_TYPES.SUBMIT, reportID: 'report1'})}; - mockExcludedTransactions = {tx2: makeSelectedTransaction({reportID: 'report2'})}; - - const {result} = renderHook(() => useSearchBulkActions({queryJSON: expenseReportQueryJSON}), {wrapper: OnyxListItemProvider}); - - await waitFor(() => { - expect(result.current.headerButtonsOptions.some((option) => option.value === CONST.SEARCH.BULK_ACTION_TYPES.SUBMIT)).toBe(true); - }); - - // When the user selects Submit - const submitOption = result.current.headerButtonsOptions.find((option) => option.value === CONST.SEARCH.BULK_ACTION_TYPES.SUBMIT); - await act(async () => { - await submitOption?.onSelected?.(); - }); - - // Then the query sent to the backend excludes the deselected report, so it isn't submitted - expect(queueBulkSubmitReports).toHaveBeenCalledWith(expect.stringContaining('report2')); - }); - - it('leaves out the report of an expense the user deselected on an expenses search', async () => { - // Given "Select all" on an expenses search, with the expense on report2 deselected afterwards - mockSelectedTransactions = {tx1: makeSelectedTransaction({action: CONST.SEARCH.ACTION_TYPES.SUBMIT, reportID: 'report1'})}; - mockExcludedTransactions = {tx2: makeSelectedTransaction({reportID: 'report2'})}; - - const {result} = renderHook(() => useSearchBulkActions({queryJSON: baseQueryJSON}), {wrapper: OnyxListItemProvider}); - - await waitFor(() => { - expect(result.current.headerButtonsOptions.some((option) => option.value === CONST.SEARCH.BULK_ACTION_TYPES.SUBMIT)).toBe(true); - }); - - // When the user selects Submit - const submitOption = result.current.headerButtonsOptions.find((option) => option.value === CONST.SEARCH.BULK_ACTION_TYPES.SUBMIT); - await act(async () => { - await submitOption?.onSelected?.(); - }); - - // Then the query sent to the backend excludes report2, since submitting it would also submit the deselected expense - expect(queueBulkSubmitReports).toHaveBeenCalledWith(expect.stringContaining('report2')); - }); - - it('hides the Submit option when no loaded expense can be submitted', async () => { - // Given nothing on the loaded page is waiting to be submitted - mockSelectedTransactions = {tx1: makeSelectedTransaction({action: CONST.SEARCH.ACTION_TYPES.VIEW})}; - - const {result} = renderHook(() => useSearchBulkActions({queryJSON: baseQueryJSON}), {wrapper: OnyxListItemProvider}); - - await waitFor(() => { - expect(result.current.headerButtonsOptions.length).toBeGreaterThan(0); - }); - - // Then Submit is not offered - expect(result.current.headerButtonsOptions.some((option) => option.value === CONST.SEARCH.BULK_ACTION_TYPES.SUBMIT)).toBe(false); - }); - - it('hides the Submit option when offline', async () => { - // Given a submittable expense is loaded but the user is offline - mockIsOffline = true; - mockSelectedTransactions = {tx1: makeSelectedTransaction({action: CONST.SEARCH.ACTION_TYPES.SUBMIT})}; - - const {result} = renderHook(() => useSearchBulkActions({queryJSON: baseQueryJSON}), {wrapper: OnyxListItemProvider}); - - await waitFor(() => { - expect(result.current.headerButtonsOptions.length).toBeGreaterThan(0); - }); - - // Then Submit is not offered - expect(result.current.headerButtonsOptions.some((option) => option.value === CONST.SEARCH.BULK_ACTION_TYPES.SUBMIT)).toBe(false); - }); - - it('hides the Submit option for a Submit plan workspace, where the approver is picked per report', async () => { - // Given the loaded submittable expense belongs to a Submit plan workspace - await Onyx.merge(`${ONYXKEYS.COLLECTION.POLICY}policy1`, {id: 'policy1', type: CONST.POLICY.TYPE.SUBMIT}); - mockSelectedTransactions = {tx1: makeSelectedTransaction({action: CONST.SEARCH.ACTION_TYPES.SUBMIT, policyID: 'policy1'})}; - - const {result} = renderHook(() => useSearchBulkActions({queryJSON: baseQueryJSON}), {wrapper: OnyxListItemProvider}); - - await waitFor(() => { - expect(result.current.headerButtonsOptions.length).toBeGreaterThan(0); - }); - - // Then Submit is not offered, because the backend cannot ask which approver to send each report to - expect(result.current.headerButtonsOptions.some((option) => option.value === CONST.SEARCH.BULK_ACTION_TYPES.SUBMIT)).toBe(false); - }); -}); - describe('useSearchBulkActions - Hold, Unhold and Reject under Select all', () => { beforeAll(() => { Onyx.init({keys: ONYXKEYS}); From 2d5379f6a0ad2d246e5810a0c46e784ee02065a2 Mon Sep 17 00:00:00 2001 From: allgandaf Date: Tue, 20 Oct 2026 09:50:56 +0530 Subject: [PATCH 57/73] move hold, unhold and reject to their own PR --- src/hooks/useSearchBulkActions.ts | 199 ++++++++---------- .../parameters/QueueBulkHoldExpensesParams.ts | 17 -- .../QueueBulkRejectExpensesParams.ts | 17 -- .../QueueBulkUnholdExpensesParams.ts | 14 -- src/libs/API/parameters/index.ts | 3 - src/libs/API/types.ts | 6 - src/libs/actions/Search.ts | 21 -- src/pages/Search/SearchHoldReasonPage.tsx | 25 +-- src/pages/Search/SearchRejectReasonPage.tsx | 29 +-- src/pages/iou/HoldReasonFormView.tsx | 7 +- src/pages/iou/RejectReasonFormView.tsx | 7 +- tests/unit/SearchHoldReasonPageTest.tsx | 134 ------------ tests/unit/SearchRejectReasonPageTest.tsx | 132 ------------ tests/unit/hooks/useSearchBulkActionsTest.ts | 142 +------------ 14 files changed, 97 insertions(+), 656 deletions(-) delete mode 100644 src/libs/API/parameters/QueueBulkHoldExpensesParams.ts delete mode 100644 src/libs/API/parameters/QueueBulkRejectExpensesParams.ts delete mode 100644 src/libs/API/parameters/QueueBulkUnholdExpensesParams.ts delete mode 100644 tests/unit/SearchHoldReasonPageTest.tsx delete mode 100644 tests/unit/SearchRejectReasonPageTest.tsx diff --git a/src/hooks/useSearchBulkActions.ts b/src/hooks/useSearchBulkActions.ts index 3a9011cdc52a..3a9ad74dd692 100644 --- a/src/hooks/useSearchBulkActions.ts +++ b/src/hooks/useSearchBulkActions.ts @@ -39,7 +39,6 @@ import { queueBulkDeleteReports, queueBulkMarkAsExported, queueBulkPayReports, - queueBulkUnholdExpenses, queueExportSearchItemsToCSV, queueExportSearchWithTemplate, resolveSearchPayPaymentMethod, @@ -2657,105 +2656,6 @@ function useSearchBulkActions({queryJSON}: UseSearchBulkActionsParams) { onSelected: () => onBulkPaySelected(undefined), }; - const rejectOption: DropdownOption = { - icon: expensifyIcons.ThumbsDown, - text: translate('search.bulkActions.reject'), - value: CONST.SEARCH.BULK_ACTION_TYPES.REJECT, - shouldCloseModalOnSelect: true, - onSelected: () => { - if (isOffline) { - showOfflineModal(); - return; - } - - if (isDelegateAccessRestricted) { - showDelegateNoAccessModal(); - return; - } - - if (dismissedRejectUseExplanation) { - Navigation.navigate(ROUTES.SEARCH_REJECT_REASON_RHP); - } else { - setRejectModalAction(CONST.REPORT.TRANSACTION_SECONDARY_ACTIONS.REJECT); - } - }, - }; - - const holdOption: DropdownOption = { - icon: expensifyIcons.Stopwatch, - text: translate('search.bulkActions.hold'), - value: CONST.SEARCH.BULK_ACTION_TYPES.HOLD, - shouldCloseModalOnSelect: true, - onSelected: () => { - if (isOffline) { - showOfflineModal(); - return; - } - - if (isDelegateAccessRestricted) { - showDelegateNoAccessModal(); - return; - } - - const shouldShowHoldEducationalModal = areAllTransactionsFromSubmitter || areAllTransactionsFromDMReports; - const isDismissed = shouldShowHoldEducationalModal ? dismissedHoldUseExplanation : dismissedRejectUseExplanation; - - if (isDismissed) { - navigateToSearchRHP(ROUTES.TRANSACTION_HOLD_REASON_SEARCH, ROUTES.TRANSACTION_HOLD_REASON_RHP); - } else if (shouldShowHoldEducationalModal) { - setIsHoldEducationalModalVisible(true); - } else { - setRejectModalAction(CONST.REPORT.TRANSACTION_SECONDARY_ACTIONS.HOLD); - } - }, - }; - - const unholdOption: DropdownOption = { - icon: expensifyIcons.Stopwatch, - text: translate('search.bulkActions.unhold'), - value: CONST.SEARCH.BULK_ACTION_TYPES.UNHOLD, - shouldCloseModalOnSelect: true, - onSelected: () => { - if (isDelegateAccessRestricted) { - showDelegateNoAccessModal(); - return; - } - - if (areAllMatchingItemsSelected) { - const allMatchingQuery = queryJSON ? getAllMatchingExpenseActionQuery(queryJSON, excludedTransactions, currentSearchResults?.data) : undefined; - if (!allMatchingQuery) { - Log.info('[BulkUnhold] Dropping bulk unhold: an excluded row could not be resolved'); - return; - } - queueBulkUnholdExpenses(allMatchingQuery.jsonQuery, allMatchingQuery.excludedTransactionIDList); - clearSelectedTransactions(); - return; - } - - for (const transactionID of selectedTransactionsKeys) { - if (!selectedTransactions[transactionID].reportAction?.childReportID) { - Log.info('[BulkUnhold] Skipping transaction: report action has no childReportID', false, {transactionID}); - continue; - } - const transactionViolations = allTransactionViolations?.[`${ONYXKEYS.COLLECTION.TRANSACTION_VIOLATIONS}${transactionID}`]; - unholdRequest({ - transactionID, - transaction: allTransactions?.[`${ONYXKEYS.COLLECTION.TRANSACTION}${transactionID}`] ?? selectedTransactions[transactionID].transaction, - reportID: selectedTransactions[transactionID].reportAction?.childReportID, - policy: policies?.[`${ONYXKEYS.COLLECTION.POLICY}${selectedTransactions[transactionID].policyID}`], - isOffline, - currentUserLogin: currentUserLogin ?? '', - currentUserAccountID: accountID, - transactionViolations, - isTrackIntentUser, - delegateAccountID, - rules, - }); - } - clearSelectedTransactions(); - }, - }; - const isExpenseReportSearch = isExpenseReportType || searchResults?.search.type === CONST.SEARCH.DATA_TYPES.EXPENSE_REPORT; const downloadPDFOption: DropdownOption = { @@ -2813,17 +2713,6 @@ function useSearchBulkActions({queryJSON}: UseSearchBulkActionsParams) { if (shouldShowPayOption) { allMatchingOptions.push(payButtonOption); } - // The backend only rejects expenses on reports the user can reject, so one loaded item is enough to offer it. - if (queryJSON?.type === CONST.SEARCH.DATA_TYPES.EXPENSE && !isOffline && selectedTransactionsKeys.some((id) => selectedTransactions[id].canReject)) { - allMatchingOptions.push(rejectOption); - } - // The backend only acts on the matching expenses the user can hold or unhold, so one loaded item is enough to offer it. - if (!isOffline && isExpenseOrReportSearch && selectedTransactionsKeys.some((id) => selectedTransactions[id].canHold)) { - allMatchingOptions.push(holdOption); - } - if (!isOffline && isExpenseOrReportSearch && selectedTransactionsKeys.some((id) => selectedTransactions[id].canUnhold)) { - allMatchingOptions.push(unholdOption); - } // The backend only deletes what the user can delete, so one deletable loaded item is enough to offer it. const hasLoadedDeletableItem = selectedReports.length && isExpenseReportType @@ -2947,7 +2836,29 @@ function useSearchBulkActions({queryJSON}: UseSearchBulkActionsParams) { hasNoRejectedTransaction; if (shouldShowRejectOption) { - options.push(rejectOption); + options.push({ + icon: expensifyIcons.ThumbsDown, + text: translate('search.bulkActions.reject'), + value: CONST.SEARCH.BULK_ACTION_TYPES.REJECT, + shouldCloseModalOnSelect: true, + onSelected: () => { + if (isOffline) { + showOfflineModal(); + return; + } + + if (isDelegateAccessRestricted) { + showDelegateNoAccessModal(); + return; + } + + if (dismissedRejectUseExplanation) { + Navigation.navigate(ROUTES.SEARCH_REJECT_REASON_RHP); + } else { + setRejectModalAction(CONST.REPORT.TRANSACTION_SECONDARY_ACTIONS.REJECT); + } + }, + }); } const shouldShowChangeApproverOption = @@ -3290,13 +3201,73 @@ function useSearchBulkActions({queryJSON}: UseSearchBulkActionsParams) { const shouldShowHoldOption = !isOffline && selectedTransactionsKeys.every((id) => selectedTransactions[id].canHold); if (shouldShowHoldOption) { - options.push(holdOption); + options.push({ + icon: expensifyIcons.Stopwatch, + text: translate('search.bulkActions.hold'), + value: CONST.SEARCH.BULK_ACTION_TYPES.HOLD, + shouldCloseModalOnSelect: true, + onSelected: () => { + if (isOffline) { + showOfflineModal(); + return; + } + + if (isDelegateAccessRestricted) { + showDelegateNoAccessModal(); + return; + } + + const shouldShowHoldEducationalModal = areAllTransactionsFromSubmitter || areAllTransactionsFromDMReports; + const isDismissed = shouldShowHoldEducationalModal ? dismissedHoldUseExplanation : dismissedRejectUseExplanation; + + if (isDismissed) { + navigateToSearchRHP(ROUTES.TRANSACTION_HOLD_REASON_SEARCH, ROUTES.TRANSACTION_HOLD_REASON_RHP); + } else if (shouldShowHoldEducationalModal) { + setIsHoldEducationalModalVisible(true); + } else { + setRejectModalAction(CONST.REPORT.TRANSACTION_SECONDARY_ACTIONS.HOLD); + } + }, + }); } const shouldShowUnholdOption = selectedTransactionsKeys.every((id) => selectedTransactions[id].canUnhold); if (shouldShowUnholdOption) { - options.push(unholdOption); + options.push({ + icon: expensifyIcons.Stopwatch, + text: translate('search.bulkActions.unhold'), + value: CONST.SEARCH.BULK_ACTION_TYPES.UNHOLD, + shouldCloseModalOnSelect: true, + onSelected: () => { + if (isDelegateAccessRestricted) { + showDelegateNoAccessModal(); + return; + } + + for (const transactionID of selectedTransactionsKeys) { + if (!selectedTransactions[transactionID].reportAction?.childReportID) { + Log.info('[BulkUnhold] Skipping transaction: report action has no childReportID', false, {transactionID}); + continue; + } + const transactionViolations = allTransactionViolations?.[`${ONYXKEYS.COLLECTION.TRANSACTION_VIOLATIONS}${transactionID}`]; + unholdRequest({ + transactionID, + transaction: allTransactions?.[`${ONYXKEYS.COLLECTION.TRANSACTION}${transactionID}`] ?? selectedTransactions[transactionID].transaction, + reportID: selectedTransactions[transactionID].reportAction?.childReportID, + policy: policies?.[`${ONYXKEYS.COLLECTION.POLICY}${selectedTransactions[transactionID].policyID}`], + isOffline, + currentUserLogin: currentUserLogin ?? '', + currentUserAccountID: accountID, + transactionViolations, + isTrackIntentUser, + delegateAccountID, + rules, + }); + } + clearSelectedTransactions(); + }, + }); } if (selectedTransactionsKeys.length < 3 && searchResults?.search.type !== CONST.SEARCH.DATA_TYPES.EXPENSE_REPORT && searchResults?.data) { diff --git a/src/libs/API/parameters/QueueBulkHoldExpensesParams.ts b/src/libs/API/parameters/QueueBulkHoldExpensesParams.ts deleted file mode 100644 index 65568c911945..000000000000 --- a/src/libs/API/parameters/QueueBulkHoldExpensesParams.ts +++ /dev/null @@ -1,17 +0,0 @@ -import type {SearchQueryString} from '@components/Search/types'; - -type QueueBulkHoldExpensesParams = { - /** Serialized search query describing every expense to hold, so the backend can page through all matches instead of relying on a client-side list */ - jsonQuery: SearchQueryString; - - /** Why the expenses are being held */ - comment: string; - - /** ID of the bulk action record the backend updates as the holds finish */ - bulkActionID: string; - - /** Comma-separated expenses the user deselected after "Select all" */ - excludedTransactionIDList: string; -}; - -export default QueueBulkHoldExpensesParams; diff --git a/src/libs/API/parameters/QueueBulkRejectExpensesParams.ts b/src/libs/API/parameters/QueueBulkRejectExpensesParams.ts deleted file mode 100644 index 09d7bce054f4..000000000000 --- a/src/libs/API/parameters/QueueBulkRejectExpensesParams.ts +++ /dev/null @@ -1,17 +0,0 @@ -import type {SearchQueryString} from '@components/Search/types'; - -type QueueBulkRejectExpensesParams = { - /** Serialized search query describing every expense to reject, so the backend can page through all matches instead of relying on a client-side list */ - jsonQuery: SearchQueryString; - - /** Why the expenses are being rejected */ - comment: string; - - /** ID of the bulk action record the backend updates as the rejections finish */ - bulkActionID: string; - - /** Comma-separated expenses the user deselected after "Select all" */ - excludedTransactionIDList: string; -}; - -export default QueueBulkRejectExpensesParams; diff --git a/src/libs/API/parameters/QueueBulkUnholdExpensesParams.ts b/src/libs/API/parameters/QueueBulkUnholdExpensesParams.ts deleted file mode 100644 index 6b251fdd2196..000000000000 --- a/src/libs/API/parameters/QueueBulkUnholdExpensesParams.ts +++ /dev/null @@ -1,14 +0,0 @@ -import type {SearchQueryString} from '@components/Search/types'; - -type QueueBulkUnholdExpensesParams = { - /** Serialized search query describing every expense to unhold, so the backend can page through all matches instead of relying on a client-side list */ - jsonQuery: SearchQueryString; - - /** ID of the bulk action record the backend updates as each expense comes off hold */ - bulkActionID: string; - - /** Comma-separated expenses the user deselected after "Select all" */ - excludedTransactionIDList: string; -}; - -export default QueueBulkUnholdExpensesParams; diff --git a/src/libs/API/parameters/index.ts b/src/libs/API/parameters/index.ts index 1ca3b12b5e62..299decc2df21 100644 --- a/src/libs/API/parameters/index.ts +++ b/src/libs/API/parameters/index.ts @@ -659,9 +659,6 @@ export type {default as ExportSearchWithTemplateParams} from './ExportSearchWith export type {default as QueueExportSearchItemsToCSVParams} from './QueueExportSearchItemsToCSVParams'; export type {default as QueueExportSearchWithTemplateParams} from './QueueExportSearchWithTemplateParams'; export type {default as QueueBulkPayReportsParams} from './QueueBulkPayReportsParams'; -export type {default as QueueBulkHoldExpensesParams} from './QueueBulkHoldExpensesParams'; -export type {default as QueueBulkUnholdExpensesParams} from './QueueBulkUnholdExpensesParams'; -export type {default as QueueBulkRejectExpensesParams} from './QueueBulkRejectExpensesParams'; export type {default as QueueBulkDeleteReportsParams} from './QueueBulkDeleteReportsParams'; export type {default as QueueBulkDeleteExpensesParams} from './QueueBulkDeleteExpensesParams'; export type {default as QueueBulkMarkAsExportedParams} from './QueueBulkMarkAsExportedParams'; diff --git a/src/libs/API/types.ts b/src/libs/API/types.ts index 55593aa3b9cd..2757a521ab70 100644 --- a/src/libs/API/types.ts +++ b/src/libs/API/types.ts @@ -660,9 +660,6 @@ const WRITE_COMMANDS = { QUEUE_EXPORT_SEARCH_ITEMS_TO_CSV: 'QueueExportSearchToCSV', QUEUE_EXPORT_SEARCH_WITH_TEMPLATE: 'QueueExportSearchWithTemplate', QUEUE_BULK_PAY_REPORTS: 'QueueBulkPayReports', - QUEUE_BULK_HOLD_EXPENSES: 'QueueBulkHoldExpenses', - QUEUE_BULK_UNHOLD_EXPENSES: 'QueueBulkUnholdExpenses', - QUEUE_BULK_REJECT_EXPENSES: 'QueueBulkRejectExpenses', QUEUE_BULK_DELETE_REPORTS: 'QueueBulkDeleteReports', QUEUE_BULK_DELETE_EXPENSES: 'QueueBulkDeleteExpenses', QUEUE_BULK_MARK_AS_EXPORTED: 'QueueBulkMarkAsExported', @@ -1509,9 +1506,6 @@ type WriteCommandParameters = { [WRITE_COMMANDS.QUEUE_EXPORT_SEARCH_ITEMS_TO_CSV]: Parameters.QueueExportSearchItemsToCSVParams; [WRITE_COMMANDS.QUEUE_EXPORT_SEARCH_WITH_TEMPLATE]: Parameters.QueueExportSearchWithTemplateParams; [WRITE_COMMANDS.QUEUE_BULK_PAY_REPORTS]: Parameters.QueueBulkPayReportsParams; - [WRITE_COMMANDS.QUEUE_BULK_HOLD_EXPENSES]: Parameters.QueueBulkHoldExpensesParams; - [WRITE_COMMANDS.QUEUE_BULK_UNHOLD_EXPENSES]: Parameters.QueueBulkUnholdExpensesParams; - [WRITE_COMMANDS.QUEUE_BULK_REJECT_EXPENSES]: Parameters.QueueBulkRejectExpensesParams; [WRITE_COMMANDS.QUEUE_BULK_DELETE_REPORTS]: Parameters.QueueBulkDeleteReportsParams; [WRITE_COMMANDS.QUEUE_BULK_DELETE_EXPENSES]: Parameters.QueueBulkDeleteExpensesParams; [WRITE_COMMANDS.QUEUE_BULK_MARK_AS_EXPORTED]: Parameters.QueueBulkMarkAsExportedParams; diff --git a/src/libs/actions/Search.ts b/src/libs/actions/Search.ts index 7c033eabfb94..5b5d3ed10537 100644 --- a/src/libs/actions/Search.ts +++ b/src/libs/actions/Search.ts @@ -2261,24 +2261,6 @@ function queueBulkPayReports(jsonQuery: string) { write(WRITE_COMMANDS.QUEUE_BULK_PAY_REPORTS, {jsonQuery, bulkActionID}, onyxData); } -/** Queues a hold, with the given reason, for every expense matching the search query that the user can hold. */ -function queueBulkHoldExpenses(jsonQuery: string, comment: string, excludedTransactionIDList: string[]) { - const {bulkActionID, onyxData} = buildBulkActionOnyxData(CONST.SEARCH.BULK_ACTION_TYPES.HOLD); - write(WRITE_COMMANDS.QUEUE_BULK_HOLD_EXPENSES, {jsonQuery, comment, bulkActionID, excludedTransactionIDList: excludedTransactionIDList.join(',')}, onyxData); -} - -/** Queues an unhold for every held expense matching the search query that the user can unhold. */ -function queueBulkUnholdExpenses(jsonQuery: string, excludedTransactionIDList: string[]) { - const {bulkActionID, onyxData} = buildBulkActionOnyxData(CONST.SEARCH.BULK_ACTION_TYPES.UNHOLD); - write(WRITE_COMMANDS.QUEUE_BULK_UNHOLD_EXPENSES, {jsonQuery, bulkActionID, excludedTransactionIDList: excludedTransactionIDList.join(',')}, onyxData); -} - -/** Queues a rejection, with the given reason, for every expense matching the search query on reports the user can reject. */ -function queueBulkRejectExpenses(jsonQuery: string, comment: string, excludedTransactionIDList: string[]) { - const {bulkActionID, onyxData} = buildBulkActionOnyxData(CONST.SEARCH.BULK_ACTION_TYPES.REJECT); - write(WRITE_COMMANDS.QUEUE_BULK_REJECT_EXPENSES, {jsonQuery, comment: getParsedComment(comment), bulkActionID, excludedTransactionIDList: excludedTransactionIDList.join(',')}, onyxData); -} - /** Queues a delete for every report matching the search query that the user can delete. */ function queueBulkDeleteReports(jsonQuery: string) { const {bulkActionID, onyxData} = buildBulkActionOnyxData(CONST.SEARCH.BULK_ACTION_TYPES.DELETE); @@ -2742,9 +2724,6 @@ export { queueExportSearchItemsToCSV, queueExportSearchWithTemplate, queueBulkPayReports, - queueBulkHoldExpenses, - queueBulkUnholdExpenses, - queueBulkRejectExpenses, queueBulkDeleteReports, queueBulkDeleteExpenses, queueBulkMarkAsExported, diff --git a/src/pages/Search/SearchHoldReasonPage.tsx b/src/pages/Search/SearchHoldReasonPage.tsx index b75032b18a2a..d3744d4e8951 100644 --- a/src/pages/Search/SearchHoldReasonPage.tsx +++ b/src/pages/Search/SearchHoldReasonPage.tsx @@ -1,6 +1,6 @@ import {useDelegateNoAccessActions, useDelegateNoAccessState} from '@components/DelegateNoAccessModalProvider'; import type {FormInputErrors, FormOnyxValues} from '@components/Form/types'; -import {useSearchQueryContext, useSearchResultsContext, useSearchSelectionActions, useSearchSelectionContext} from '@components/Search/SearchContext'; +import {useSearchSelectionActions, useSearchSelectionContext} from '@components/Search/SearchContext'; import useAncestors from '@hooks/useAncestors'; import useCurrentUserPersonalDetails from '@hooks/useCurrentUserPersonalDetails'; @@ -9,13 +9,10 @@ import useDynamicBackPath from '@hooks/useDynamicBackPath'; import useLocalize from '@hooks/useLocalize'; import useNetwork from '@hooks/useNetwork'; import useOnyx from '@hooks/useOnyx'; -import {getAllMatchingExpenseActionQuery} from '@hooks/useSearchBulkActions'; import useTransactionsByID from '@hooks/useTransactionsByID'; import {clearErrorFields, clearErrors} from '@libs/actions/FormActions'; import {putOnHold, putTransactionsOnHold} from '@libs/actions/IOU/Hold'; -import {queueBulkHoldExpenses} from '@libs/actions/Search'; -import Log from '@libs/Log'; import Navigation from '@libs/Navigation/Navigation'; import type {PlatformStackScreenProps} from '@libs/Navigation/PlatformStackNavigation/types'; import {getIOUActionForTransactionID} from '@libs/ReportActionsUtils'; @@ -45,9 +42,7 @@ function SearchHoldReasonPage({route}: SearchHoldReasonPageProps) { const {reportID} = route.params ?? {}; const dynamicBackPath = useDynamicBackPath(DYNAMIC_ROUTES.HOLD_TRANSACTIONS.path); const backTo = isBulkHold ? dynamicBackPath : route.params.backTo; - const {selectedTransactionIDs, selectedTransactions, excludedTransactions, areAllMatchingItemsSelected} = useSearchSelectionContext(); - const {currentSearchQueryJSON} = useSearchQueryContext(); - const {currentSearchResults} = useSearchResultsContext(); + const {selectedTransactionIDs, selectedTransactions} = useSearchSelectionContext(); const {clearSelectedTransactions} = useSearchSelectionActions(); const {accountID: currentUserAccountID, login: currentUserLogin} = useCurrentUserPersonalDetails(); const delegateAccountID = useDelegateAccountID(); @@ -93,16 +88,7 @@ function SearchHoldReasonPage({route}: SearchHoldReasonPageProps) { showDelegateNoAccessModal(); return; } - if (!isBulkHold && areAllMatchingItemsSelected) { - // "Select all" can cover more expenses than are loaded, so hand the search query to the backend to hold every match. - const allMatchingQuery = currentSearchQueryJSON ? getAllMatchingExpenseActionQuery(currentSearchQueryJSON, excludedTransactions, currentSearchResults?.data) : undefined; - if (!allMatchingQuery) { - Log.info('[BulkHold] Dropping bulk hold: an excluded row could not be resolved'); - return; - } - queueBulkHoldExpenses(allMatchingQuery.jsonQuery, comment, allMatchingQuery.excludedTransactionIDList); - clearSelectedTransactions(); - } else if (isBulkHold) { + if (isBulkHold) { putTransactionsOnHold({ transactionsID: selectedTransactionIDs, allReports: relevantReports, @@ -166,10 +152,6 @@ function SearchHoldReasonPage({route}: SearchHoldReasonPageProps) { ancestors, clearSelectedTransactions, selectedTransactions, - areAllMatchingItemsSelected, - currentSearchQueryJSON, - excludedTransactions, - currentSearchResults?.data, ], ); @@ -200,7 +182,6 @@ function SearchHoldReasonPage({route}: SearchHoldReasonPageProps) { expenseCount={expenseCount} backTo={backTo} isSubmitter={isSubmitter} - enabledWhenOffline={isBulkHold || !areAllMatchingItemsSelected} /> ); } diff --git a/src/pages/Search/SearchRejectReasonPage.tsx b/src/pages/Search/SearchRejectReasonPage.tsx index c86023ab86e3..846b25079a36 100644 --- a/src/pages/Search/SearchRejectReasonPage.tsx +++ b/src/pages/Search/SearchRejectReasonPage.tsx @@ -1,7 +1,7 @@ import {useDelegateNoAccessActions, useDelegateNoAccessState} from '@components/DelegateNoAccessModalProvider'; import type {FormInputErrors, FormOnyxValues} from '@components/Form/types'; import {useAllReportsTransactionsAndViolations} from '@components/OnyxListItemProvider'; -import {useSearchQueryContext, useSearchResultsContext, useSearchSelectionActions, useSearchSelectionContext} from '@components/Search/SearchContext'; +import {useSearchQueryContext, useSearchSelectionActions, useSearchSelectionContext} from '@components/Search/SearchContext'; import {useCurrencyListActions} from '@hooks/useCurrencyList'; import useCurrentUserPersonalDetails from '@hooks/useCurrentUserPersonalDetails'; @@ -9,11 +9,9 @@ import useDelegateAccountID from '@hooks/useDelegateAccountID'; import useLocalize from '@hooks/useLocalize'; import useOnyx from '@hooks/useOnyx'; import usePermissions from '@hooks/usePermissions'; -import {getAllMatchingExpenseActionQuery} from '@hooks/useSearchBulkActions'; import {clearErrorFields, clearErrors} from '@libs/actions/FormActions'; -import {queueBulkRejectExpenses, rejectMoneyRequestsOnSearch} from '@libs/actions/Search'; -import Log from '@libs/Log'; +import {rejectMoneyRequestsOnSearch} from '@libs/actions/Search'; import Navigation from '@libs/Navigation/Navigation'; import type {PlatformStackScreenProps} from '@libs/Navigation/PlatformStackNavigation/types'; import {getFieldRequiredErrors} from '@libs/ValidationUtils'; @@ -35,9 +33,8 @@ type SearchRejectReasonPageProps = | PlatformStackScreenProps; function SearchRejectReasonPage({route}: SearchRejectReasonPageProps) { - const {selectedTransactionIDs, selectedTransactions, excludedTransactions, areAllMatchingItemsSelected} = useSearchSelectionContext(); - const {currentSearchHash, currentSearchQueryJSON} = useSearchQueryContext(); - const {currentSearchResults} = useSearchResultsContext(); + const {selectedTransactionIDs, selectedTransactions} = useSearchSelectionContext(); + const {currentSearchHash} = useSearchQueryContext(); const {clearSelectedTransactions} = useSearchSelectionActions(); const {reportID} = route.params ?? {}; const [allPolicies] = useOnyx(ONYXKEYS.COLLECTION.POLICY); @@ -70,19 +67,6 @@ function SearchRejectReasonPage({route}: SearchRejectReasonPageProps) { return; } - // "Select all" can cover more expenses than are loaded, so hand the search query to the backend to reject every match. - if (route.name === SCREENS.SEARCH.SEARCH_REJECT_REASON_RHP && areAllMatchingItemsSelected) { - const allMatchingQuery = currentSearchQueryJSON ? getAllMatchingExpenseActionQuery(currentSearchQueryJSON, excludedTransactions, currentSearchResults?.data) : undefined; - if (!allMatchingQuery) { - Log.info('[BulkReject] Dropping bulk reject: an excluded row could not be resolved'); - return; - } - queueBulkRejectExpenses(allMatchingQuery.jsonQuery, comment, allMatchingQuery.excludedTransactionIDList); - clearSelectedTransactions(); - Navigation.dismissToSuperWideRHP(); - return; - } - const urlToNavigateBack = rejectMoneyRequestsOnSearch({ hash: currentSearchHash, selectedTransactions: selectedTransactionsForReject, @@ -123,10 +107,6 @@ function SearchRejectReasonPage({route}: SearchRejectReasonPageProps) { route.name, showDelegateNoAccessModal, clearSelectedTransactions, - areAllMatchingItemsSelected, - currentSearchQueryJSON, - excludedTransactions, - currentSearchResults?.data, ], ); @@ -147,7 +127,6 @@ function SearchRejectReasonPage({route}: SearchRejectReasonPageProps) { ); } diff --git a/src/pages/iou/HoldReasonFormView.tsx b/src/pages/iou/HoldReasonFormView.tsx index abaa1667cba3..5c653dcb05b9 100644 --- a/src/pages/iou/HoldReasonFormView.tsx +++ b/src/pages/iou/HoldReasonFormView.tsx @@ -31,12 +31,9 @@ type HoldReasonFormViewProps = { /** Whether the current user is the submitter of the expense */ isSubmitter?: boolean; - - /** Whether the form can be submitted while offline (defaults to true) */ - enabledWhenOffline?: boolean; }; -function HoldReasonFormView({backTo, validate, onSubmit, expenseCount = 1, isSubmitter = true, enabledWhenOffline = true}: HoldReasonFormViewProps) { +function HoldReasonFormView({backTo, validate, onSubmit, expenseCount = 1, isSubmitter = true}: HoldReasonFormViewProps) { const styles = useThemeStyles(); const {translate} = useLocalize(); const {inputCallbackRef} = useAutoFocusInput(); @@ -57,7 +54,7 @@ function HoldReasonFormView({backTo, validate, onSubmit, expenseCount = 1, isSub style={[styles.flexGrow1, styles.ph5]} onSubmit={onSubmit} validate={validate} - enabledWhenOffline={enabledWhenOffline} + enabledWhenOffline shouldHideFixErrorsAlert > {translate(isSubmitter ? 'iou.explainHold' : 'iou.explainHoldApprover', {count: expenseCount})} diff --git a/src/pages/iou/RejectReasonFormView.tsx b/src/pages/iou/RejectReasonFormView.tsx index e7d231fc4fcb..96d4670f0541 100644 --- a/src/pages/iou/RejectReasonFormView.tsx +++ b/src/pages/iou/RejectReasonFormView.tsx @@ -26,12 +26,9 @@ type RejectReasonFormViewProps = { /** Link to previous page */ backTo?: Route; - - /** Whether the form can be submitted while offline (defaults to true) */ - enabledWhenOffline?: boolean; }; -function RejectReasonFormView({backTo, validate, onSubmit, enabledWhenOffline = true}: RejectReasonFormViewProps) { +function RejectReasonFormView({backTo, validate, onSubmit}: RejectReasonFormViewProps) { const {translate} = useLocalize(); const styles = useThemeStyles(); const {inputCallbackRef} = useAutoFocusInput(); @@ -52,7 +49,7 @@ function RejectReasonFormView({backTo, validate, onSubmit, enabledWhenOffline = style={[styles.flexGrow1, styles.ph5]} onSubmit={onSubmit} validate={validate} - enabledWhenOffline={enabledWhenOffline} + enabledWhenOffline shouldHideFixErrorsAlert buttonVariant={CONST.BUTTON_VARIANT.DANGER} > diff --git a/tests/unit/SearchHoldReasonPageTest.tsx b/tests/unit/SearchHoldReasonPageTest.tsx deleted file mode 100644 index 9beda89dd96e..000000000000 --- a/tests/unit/SearchHoldReasonPageTest.tsx +++ /dev/null @@ -1,134 +0,0 @@ -import {render} from '@testing-library/react-native'; - -import type {SearchQueryJSON} from '@components/Search/types'; - -import {putOnHold} from '@libs/actions/IOU/Hold'; -import {queueBulkHoldExpenses} from '@libs/actions/Search'; - -import SearchHoldReasonPage from '@pages/Search/SearchHoldReasonPage'; - -import CONST from '@src/CONST'; -import ONYXKEYS from '@src/ONYXKEYS'; -import SCREENS from '@src/SCREENS'; - -import React from 'react'; -import Onyx from 'react-native-onyx'; - -import waitForBatchedUpdatesWithAct from '../utils/waitForBatchedUpdatesWithAct'; - -const mockQueryJSON: SearchQueryJSON = { - inputQuery: 'type:expense status:all', - hash: 12345, - recentSearchHash: 12345, - similarSearchHash: 12345, - flatFilters: [], - type: CONST.SEARCH.DATA_TYPES.EXPENSE, - sortBy: CONST.SEARCH.TABLE_COLUMNS.DATE, - sortOrder: CONST.SEARCH.SORT_ORDER.DESC, - view: CONST.SEARCH.VIEW.TABLE, - filters: {operator: CONST.SEARCH.SYNTAX_OPERATORS.AND, left: 'type', right: 'expense'}, -}; -const mockClearSelectedTransactions = jest.fn(); -let mockAreAllMatchingItemsSelected = false; -let mockSubmitHoldReason: ((values: {comment: string}) => void) | undefined; -let mockEnabledWhenOffline: boolean | undefined; - -jest.mock('@pages/iou/HoldReasonFormView', () => { - function MockHoldReasonFormView({onSubmit, enabledWhenOffline}: {onSubmit: (values: {comment: string}) => void; enabledWhenOffline?: boolean}) { - mockSubmitHoldReason = onSubmit; - mockEnabledWhenOffline = enabledWhenOffline; - return null; - } - return MockHoldReasonFormView; -}); -jest.mock('@components/Search/SearchContext', () => ({ - useSearchQueryContext: () => ({currentSearchQueryJSON: mockQueryJSON}), - useSearchResultsContext: () => ({currentSearchResults: undefined}), - useSearchSelectionActions: () => ({clearSelectedTransactions: mockClearSelectedTransactions}), - useSearchSelectionContext: () => ({ - selectedTransactionIDs: [], - selectedTransactions: {tx1: {reportID: 'report1'}}, - excludedTransactions: {tx2: {reportID: 'report1'}}, - areAllMatchingItemsSelected: mockAreAllMatchingItemsSelected, - }), -})); -jest.mock('@libs/actions/Search', () => ({ - queueBulkHoldExpenses: jest.fn(), -})); -jest.mock('@libs/actions/IOU/Hold', () => ({ - putOnHold: jest.fn(), - putTransactionsOnHold: jest.fn(), -})); -jest.mock('@libs/Navigation/Navigation', () => ({ - goBack: jest.fn(), - isNavigationReady: jest.fn(() => Promise.resolve()), -})); -jest.mock('@hooks/useDynamicBackPath', () => ({ - __esModule: true, - default: () => '', -})); - -function renderPage(areAllMatchingItemsSelected: boolean) { - mockAreAllMatchingItemsSelected = areAllMatchingItemsSelected; - const route = {name: SCREENS.SEARCH.TRANSACTION_HOLD_REASON_RHP, key: 'hold', params: {backTo: ''}}; - // @ts-expect-error the page only reads route.name and route.params - render(); -} - -describe('SearchHoldReasonPage', () => { - beforeAll(() => { - Onyx.init({keys: ONYXKEYS}); - }); - - beforeEach(async () => { - jest.clearAllMocks(); - mockSubmitHoldReason = undefined; - mockEnabledWhenOffline = undefined; - await Onyx.clear(); - }); - - it('hands the search to the backend when Select all is checked', async () => { - // Given the hold reason page opened with "Select all" checked and one expense deselected - renderPage(true); - await waitForBatchedUpdatesWithAct(); - - // When the user submits a reason - mockSubmitHoldReason?.({comment: 'needs a receipt'}); - - // Then every matching expense is held by the backend, except the deselected one, and nothing is held per expense - expect(queueBulkHoldExpenses).toHaveBeenCalledWith(expect.any(String), 'needs a receipt', ['tx2']); - expect(putOnHold).not.toHaveBeenCalled(); - expect(mockClearSelectedTransactions).toHaveBeenCalled(); - }); - - it('holds each selected expense when Select all is not checked', async () => { - // Given the hold reason page opened with a manual selection - renderPage(false); - await waitForBatchedUpdatesWithAct(); - - // When the user submits a reason - mockSubmitHoldReason?.({comment: 'needs a receipt'}); - - // Then the selected expense is held directly and nothing is queued on the backend - expect(putOnHold).toHaveBeenCalledTimes(1); - expect(queueBulkHoldExpenses).not.toHaveBeenCalled(); - }); - - it('keeps the reason form from submitting offline when Select all is checked', async () => { - // Given the hold reason page opened with "Select all" checked - renderPage(true); - await waitForBatchedUpdatesWithAct(); - - // Then the form is disabled offline, since the backend would hold whatever matches once the device reconnects - expect(mockEnabledWhenOffline).toBe(false); - }); - - it('lets the reason form submit offline when Select all is not checked', async () => { - // Given the hold reason page opened with a manual selection - renderPage(false); - await waitForBatchedUpdatesWithAct(); - - // Then the form still works offline, since each selected expense is updated optimistically - expect(mockEnabledWhenOffline).toBe(true); - }); -}); diff --git a/tests/unit/SearchRejectReasonPageTest.tsx b/tests/unit/SearchRejectReasonPageTest.tsx deleted file mode 100644 index 7ef7eb98a1cc..000000000000 --- a/tests/unit/SearchRejectReasonPageTest.tsx +++ /dev/null @@ -1,132 +0,0 @@ -import {render} from '@testing-library/react-native'; - -import type * as OnyxListItemProvider from '@components/OnyxListItemProvider'; -import type {SearchQueryJSON} from '@components/Search/types'; - -import {queueBulkRejectExpenses, rejectMoneyRequestsOnSearch} from '@libs/actions/Search'; - -import SearchRejectReasonPage from '@pages/Search/SearchRejectReasonPage'; - -import CONST from '@src/CONST'; -import ONYXKEYS from '@src/ONYXKEYS'; -import SCREENS from '@src/SCREENS'; - -import React from 'react'; -import Onyx from 'react-native-onyx'; - -import waitForBatchedUpdatesWithAct from '../utils/waitForBatchedUpdatesWithAct'; - -const mockQueryJSON: SearchQueryJSON = { - inputQuery: 'type:expense status:all', - hash: 12345, - recentSearchHash: 12345, - similarSearchHash: 12345, - flatFilters: [], - type: CONST.SEARCH.DATA_TYPES.EXPENSE, - sortBy: CONST.SEARCH.TABLE_COLUMNS.DATE, - sortOrder: CONST.SEARCH.SORT_ORDER.DESC, - view: CONST.SEARCH.VIEW.TABLE, - filters: {operator: CONST.SEARCH.SYNTAX_OPERATORS.AND, left: 'type', right: 'expense'}, -}; -const mockClearSelectedTransactions = jest.fn(); -let mockAreAllMatchingItemsSelected = false; -let mockSubmitRejectReason: ((values: {comment: string}) => void) | undefined; -let mockEnabledWhenOffline: boolean | undefined; - -jest.mock('@pages/iou/RejectReasonFormView', () => { - function MockRejectReasonFormView({onSubmit, enabledWhenOffline}: {onSubmit: (values: {comment: string}) => void; enabledWhenOffline?: boolean}) { - mockSubmitRejectReason = onSubmit; - mockEnabledWhenOffline = enabledWhenOffline; - return null; - } - return MockRejectReasonFormView; -}); -jest.mock('@components/Search/SearchContext', () => ({ - useSearchQueryContext: () => ({currentSearchHash: 12345, currentSearchQueryJSON: mockQueryJSON}), - useSearchResultsContext: () => ({currentSearchResults: undefined}), - useSearchSelectionActions: () => ({clearSelectedTransactions: mockClearSelectedTransactions}), - useSearchSelectionContext: () => ({ - selectedTransactionIDs: [], - selectedTransactions: {tx1: {reportID: 'report1'}}, - excludedTransactions: {tx2: {reportID: 'report1'}}, - areAllMatchingItemsSelected: mockAreAllMatchingItemsSelected, - }), -})); -jest.mock('@components/OnyxListItemProvider', () => ({ - ...jest.requireActual('@components/OnyxListItemProvider'), - useAllReportsTransactionsAndViolations: () => undefined, -})); -jest.mock('@libs/actions/Search', () => ({ - queueBulkRejectExpenses: jest.fn(), - rejectMoneyRequestsOnSearch: jest.fn(), -})); -jest.mock('@libs/Navigation/Navigation', () => ({ - dismissToSuperWideRHP: jest.fn(), - goBack: jest.fn(), - isNavigationReady: jest.fn(() => Promise.resolve()), -})); - -function renderPage(areAllMatchingItemsSelected: boolean) { - mockAreAllMatchingItemsSelected = areAllMatchingItemsSelected; - const route = {name: SCREENS.SEARCH.SEARCH_REJECT_REASON_RHP, key: 'reject', params: {}}; - // @ts-expect-error the page only reads route.name and route.params - render(); -} - -describe('SearchRejectReasonPage', () => { - beforeAll(() => { - Onyx.init({keys: ONYXKEYS}); - }); - - beforeEach(async () => { - jest.clearAllMocks(); - mockSubmitRejectReason = undefined; - mockEnabledWhenOffline = undefined; - await Onyx.clear(); - }); - - it('hands the search to the backend when Select all is checked', async () => { - // Given the reject reason page opened with "Select all" checked and one expense deselected - renderPage(true); - await waitForBatchedUpdatesWithAct(); - - // When the user submits a reason - mockSubmitRejectReason?.({comment: 'missing receipts'}); - - // Then every matching expense is rejected by the backend, except the deselected one, and nothing is rejected from the app - expect(queueBulkRejectExpenses).toHaveBeenCalledWith(expect.any(String), 'missing receipts', ['tx2']); - expect(rejectMoneyRequestsOnSearch).not.toHaveBeenCalled(); - expect(mockClearSelectedTransactions).toHaveBeenCalled(); - }); - - it('rejects the selected expenses from the app when Select all is not checked', async () => { - // Given the reject reason page opened with a manual selection - renderPage(false); - await waitForBatchedUpdatesWithAct(); - - // When the user submits a reason - mockSubmitRejectReason?.({comment: 'missing receipts'}); - - // Then the selected expenses are rejected directly and nothing is queued on the backend - expect(rejectMoneyRequestsOnSearch).toHaveBeenCalledTimes(1); - expect(queueBulkRejectExpenses).not.toHaveBeenCalled(); - }); - - it('keeps the reason form from submitting offline when Select all is checked', async () => { - // Given the reject reason page opened with "Select all" checked - renderPage(true); - await waitForBatchedUpdatesWithAct(); - - // Then the form is disabled offline, since the backend would reject whatever matches once the device reconnects - expect(mockEnabledWhenOffline).toBe(false); - }); - - it('lets the reason form submit offline when Select all is not checked', async () => { - // Given the reject reason page opened with a manual selection - renderPage(false); - await waitForBatchedUpdatesWithAct(); - - // Then the form still works offline, since each selected expense is updated optimistically - expect(mockEnabledWhenOffline).toBe(true); - }); -}); diff --git a/tests/unit/hooks/useSearchBulkActionsTest.ts b/tests/unit/hooks/useSearchBulkActionsTest.ts index 7b2c641b0f7c..c612600aa5b7 100644 --- a/tests/unit/hooks/useSearchBulkActionsTest.ts +++ b/tests/unit/hooks/useSearchBulkActionsTest.ts @@ -7,15 +7,7 @@ import type {SearchQueryJSON, SelectedReports, SelectedTransactions} from '@comp import useSearchBulkActions from '@hooks/useSearchBulkActions'; import {unholdRequest} from '@libs/actions/IOU/Hold'; -import { - exportSearchItemsToCSV, - getExportTemplates, - queueBulkDeleteExpenses, - queueBulkDeleteReports, - queueBulkUnholdExpenses, - queueExportSearchItemsToCSV, - queueExportSearchWithTemplate, -} from '@libs/actions/Search'; +import {exportSearchItemsToCSV, getExportTemplates, queueBulkDeleteExpenses, queueBulkDeleteReports, queueExportSearchItemsToCSV, queueExportSearchWithTemplate} from '@libs/actions/Search'; import type * as NetworkState from '@libs/NetworkState'; import type * as SearchUIUtils from '@libs/SearchUIUtils'; @@ -45,7 +37,6 @@ jest.mock('@libs/actions/Search', () => ({ queueExportSearchWithTemplate: jest.fn(() => 'mock-template-export-id'), queueBulkDeleteExpenses: jest.fn(), queueBulkDeleteReports: jest.fn(), - queueBulkUnholdExpenses: jest.fn(), getSearchApproveOnyxData: jest.fn(() => ({})), getSearchPayOnyxData: jest.fn(() => ({})), bulkDeleteReports: jest.fn(), @@ -761,137 +752,6 @@ describe('useSearchBulkActions - CSV export flow', () => { }); }); -describe('useSearchBulkActions - Hold, Unhold and Reject under Select all', () => { - beforeAll(() => { - Onyx.init({keys: ONYXKEYS}); - }); - - beforeEach(async () => { - jest.clearAllMocks(); - mockIsOffline = false; - mockAreAllMatchingItemsSelected = true; - await Onyx.clear(); - mockSelectedTransactions = {}; - mockExcludedTransactions = {}; - mockSelectedReports = []; - mockCurrentSearchResults = undefined; - mockGetExportTemplates.mockReturnValue({customTemplates: [], defaultTemplates: []}); - - await Onyx.merge(ONYXKEYS.SESSION, {accountID: CURRENT_USER_ACCOUNT_ID, email: 'test@example.com'}); - }); - - afterEach(async () => { - await Onyx.clear(); - }); - - it('offers Hold when one loaded expense can be held, even if another cannot', async () => { - // Given "Select all" with one holdable expense and one that is already held, which hides Hold for a normal selection - mockSelectedTransactions = {tx1: makeSelectedTransaction({canHold: true}), tx2: makeSelectedTransaction({canHold: false, canUnhold: true})}; - - // When the bulk actions are built - const {result} = renderHook(() => useSearchBulkActions({queryJSON: baseQueryJSON}), {wrapper: OnyxListItemProvider}); - - // Then both Hold and Unhold are offered, because the backend only acts on the expenses the user can act on - await waitFor(() => { - expect(result.current.headerButtonsOptions.some((option) => option.value === CONST.SEARCH.BULK_ACTION_TYPES.HOLD)).toBe(true); - }); - expect(result.current.headerButtonsOptions.some((option) => option.value === CONST.SEARCH.BULK_ACTION_TYPES.UNHOLD)).toBe(true); - }); - - it('queues a server-side bulk unhold without the expenses the user deselected', async () => { - // Given "Select all" on an expenses search with a held expense loaded, and one expense deselected afterwards - mockSelectedTransactions = {tx1: makeSelectedTransaction({canUnhold: true})}; - mockExcludedTransactions = {tx2: makeSelectedTransaction()}; - - const {result} = renderHook(() => useSearchBulkActions({queryJSON: baseQueryJSON}), {wrapper: OnyxListItemProvider}); - - await waitFor(() => { - expect(result.current.headerButtonsOptions.some((option) => option.value === CONST.SEARCH.BULK_ACTION_TYPES.UNHOLD)).toBe(true); - }); - - // When the user selects Unhold - const unholdOption = result.current.headerButtonsOptions.find((option) => option.value === CONST.SEARCH.BULK_ACTION_TYPES.UNHOLD); - await act(async () => { - await unholdOption?.onSelected?.(); - }); - - // Then the search is handed to the backend with the deselected expense listed, so it stays held - expect(queueBulkUnholdExpenses).toHaveBeenCalledTimes(1); - expect(queueBulkUnholdExpenses).toHaveBeenCalledWith(expect.any(String), ['tx2']); - expect(mockClearSelectedTransactions).toHaveBeenCalled(); - }); - - it('does not offer the backend bulk actions on an invoice search', async () => { - // Given "Select all" on an invoice search with an expense that could be held, unheld, rejected or approved - mockSelectedTransactions = { - tx1: makeSelectedTransaction({canHold: true, canUnhold: true, canReject: true, action: CONST.SEARCH.ACTION_TYPES.APPROVE}), - }; - - // When the bulk actions are built - const {result} = renderHook(() => useSearchBulkActions({queryJSON: {...baseQueryJSON, type: CONST.SEARCH.DATA_TYPES.INVOICE}}), {wrapper: OnyxListItemProvider}); - - // Then none of them is offered, because the backend only runs them on expense and report searches - await waitFor(() => { - expect(result.current.headerButtonsOptions.some((option) => option.value === CONST.SEARCH.BULK_ACTION_TYPES.EXPORT)).toBe(true); - }); - const offeredValues = result.current.headerButtonsOptions.map((option) => option.value); - for (const value of [ - CONST.SEARCH.BULK_ACTION_TYPES.HOLD, - CONST.SEARCH.BULK_ACTION_TYPES.UNHOLD, - CONST.SEARCH.BULK_ACTION_TYPES.REJECT, - CONST.SEARCH.BULK_ACTION_TYPES.APPROVE, - CONST.SEARCH.BULK_ACTION_TYPES.SUBMIT, - CONST.SEARCH.BULK_ACTION_TYPES.DELETE, - ]) { - expect(offeredValues).not.toContain(value); - } - }); - - it('offers Reject on an expenses search when one loaded expense can be rejected', async () => { - // Given "Select all" on an expenses search with one rejectable expense and one that is not, which hides Reject for a normal selection - mockSelectedTransactions = {tx1: makeSelectedTransaction({canReject: true}), tx2: makeSelectedTransaction({canReject: false})}; - - // When the bulk actions are built - const {result} = renderHook(() => useSearchBulkActions({queryJSON: baseQueryJSON}), {wrapper: OnyxListItemProvider}); - - // Then Reject is offered, because the backend only rejects expenses on reports the user can reject - await waitFor(() => { - expect(result.current.headerButtonsOptions.some((option) => option.value === CONST.SEARCH.BULK_ACTION_TYPES.REJECT)).toBe(true); - }); - }); - - it('does not offer Reject on a reports search', async () => { - // Given "Select all" on a reports search with a rejectable expense loaded - mockSelectedTransactions = {tx1: makeSelectedTransaction({canReject: true})}; - - // When the bulk actions are built - const {result} = renderHook(() => useSearchBulkActions({queryJSON: expenseReportQueryJSON}), {wrapper: OnyxListItemProvider}); - - await waitFor(() => { - expect(result.current.headerButtonsOptions.length).toBeGreaterThan(0); - }); - - // Then Reject is not offered, the same as for a normal selection of reports - expect(result.current.headerButtonsOptions.some((option) => option.value === CONST.SEARCH.BULK_ACTION_TYPES.REJECT)).toBe(false); - }); - - it('hides Hold and Unhold when no loaded expense can be held or unheld', async () => { - // Given nothing on the loaded page can be held or unheld - mockSelectedTransactions = {tx1: makeSelectedTransaction()}; - - // When the bulk actions are built - const {result} = renderHook(() => useSearchBulkActions({queryJSON: baseQueryJSON}), {wrapper: OnyxListItemProvider}); - - await waitFor(() => { - expect(result.current.headerButtonsOptions.length).toBeGreaterThan(0); - }); - - // Then neither is offered - expect(result.current.headerButtonsOptions.some((option) => option.value === CONST.SEARCH.BULK_ACTION_TYPES.HOLD)).toBe(false); - expect(result.current.headerButtonsOptions.some((option) => option.value === CONST.SEARCH.BULK_ACTION_TYPES.UNHOLD)).toBe(false); - }); -}); - describe('useSearchBulkActions - Delete under Select all', () => { beforeAll(() => { Onyx.init({keys: ONYXKEYS}); From 33eefef135170e3dfea7f6f52823fe37d636bbab Mon Sep 17 00:00:00 2001 From: allgandaf Date: Tue, 20 Oct 2026 09:50:57 +0530 Subject: [PATCH 58/73] move delete to its own PR --- src/hooks/useSearchBulkActions.ts | 66 +-------- .../QueueBulkDeleteExpensesParams.ts | 14 -- .../QueueBulkDeleteReportsParams.ts | 11 -- src/libs/API/parameters/index.ts | 2 - src/libs/API/types.ts | 4 - src/libs/actions/Search.ts | 14 -- tests/unit/hooks/useSearchBulkActionsTest.ts | 132 +----------------- 7 files changed, 4 insertions(+), 239 deletions(-) delete mode 100644 src/libs/API/parameters/QueueBulkDeleteExpensesParams.ts delete mode 100644 src/libs/API/parameters/QueueBulkDeleteReportsParams.ts diff --git a/src/hooks/useSearchBulkActions.ts b/src/hooks/useSearchBulkActions.ts index 3a9ad74dd692..2b259a09ffcb 100644 --- a/src/hooks/useSearchBulkActions.ts +++ b/src/hooks/useSearchBulkActions.ts @@ -35,8 +35,6 @@ import { getSearchPayOnyxData, getTotalFormattedAmount, isCurrencySupportWalletBulkPay, - queueBulkDeleteExpenses, - queueBulkDeleteReports, queueBulkMarkAsExported, queueBulkPayReports, queueExportSearchItemsToCSV, @@ -54,7 +52,6 @@ import Log from '@libs/Log'; import {getTransactionsAndReportsFromSearch} from '@libs/MergeTransactionUtils'; import Navigation from '@libs/Navigation/Navigation'; import TransitionTracker from '@libs/Navigation/TransitionTracker'; -import {getIsOffline} from '@libs/NetworkState'; import Parser from '@libs/Parser'; import {getLoginByAccountID} from '@libs/PersonalDetailsUtils'; import {getConnectedIntegration, isAdminOfCardEnabledPolicy, isSubmitPolicy} from '@libs/PolicyUtils'; @@ -456,21 +453,6 @@ function getAllMatchingReportQuery(queryJSON: SearchQueryJSON, excludedTransacti return buildSearchQueryJSON(buildSearchQueryString({...queryJSON, flatFilters})); } -/** Builds the query and the deselected expenses to send to the backend for a "Select all" bulk action on expenses. */ -function getAllMatchingExpenseActionQuery( - queryJSON: SearchQueryJSON, - excludedTransactions: SelectedTransactions, - searchData: SearchResultDataType | undefined, -): {jsonQuery: string; excludedTransactionIDList: string[]} | undefined { - if (queryJSON.type === CONST.SEARCH.DATA_TYPES.EXPENSE_REPORT) { - const reportQuery = getAllMatchingReportQuery(queryJSON, excludedTransactions); - return reportQuery ? {jsonQuery: serializeQueryJSONForBackend(reportQuery), excludedTransactionIDList: []} : undefined; - } - - const expenseQuery = getAllMatchingExportQueryAndExclusions(queryJSON, excludedTransactions, searchData); - return expenseQuery ? {jsonQuery: serializeQueryJSONForBackend(expenseQuery.queryJSON), excludedTransactionIDList: expenseQuery.excludedTransactionIDList} : undefined; -} - /** * The groupings whose selected groups `getSelectedGroupFilterEntry` can turn into a query filter, which a template export needs. * Keep this in sync with that function. @@ -753,8 +735,6 @@ function useSearchBulkActions({queryJSON}: UseSearchBulkActionsParams) { const getPersonalDetailsByLogin = useGetPersonalDetailsByLogin(); const isExpenseReportType = queryJSON?.type === CONST.SEARCH.DATA_TYPES.EXPENSE_REPORT; - // The backend runs a Select all bulk action only on an expense or report search. - const isExpenseOrReportSearch = queryJSON?.type === CONST.SEARCH.DATA_TYPES.EXPENSE || isExpenseReportType; const expensifyIcons = useMemoizedLazyExpensifyIcons([ 'Download', 'Export', @@ -1530,27 +1510,6 @@ function useSearchBulkActions({queryJSON}: UseSearchBulkActionsParams) { if (result.action !== ModalActions.CONFIRM) { return; } - // "Select all" can cover more than is loaded, so hand the search query to the backend to delete every match. - if (areAllMatchingItemsSelected) { - // The user can go offline while the confirmation is open. - if (getIsOffline()) { - showOfflineModal(); - return; - } - const allMatchingQuery = queryJSON ? getAllMatchingExpenseActionQuery(queryJSON, excludedTransactions, currentSearchResults?.data) : undefined; - if (!allMatchingQuery) { - Log.info('[BulkDelete] Dropping bulk delete: an excluded row could not be resolved'); - return; - } - if (isExpenseReportType) { - queueBulkDeleteReports(allMatchingQuery.jsonQuery); - } else { - queueBulkDeleteExpenses(allMatchingQuery.jsonQuery, allMatchingQuery.excludedTransactionIDList); - } - clearSelectedTransactions(); - return; - } - const validTransactions = Object.fromEntries(Object.entries(allTransactions ?? {}).filter((entry): entry is [string, Transaction] => entry[1] !== undefined)); const searchData = searchResults?.data; if (isExpenseReportType) { @@ -1634,11 +1593,7 @@ function useSearchBulkActions({queryJSON}: UseSearchBulkActionsParams) { showConfirmModal, deleteModalTitle, deleteModalPrompt, - areAllMatchingItemsSelected, - showOfflineModal, - queryJSON, - excludedTransactions, - currentSearchResults?.data, + queryJSON?.groupBy, translate, allTransactions, allTransactionViolations, @@ -2713,22 +2668,6 @@ function useSearchBulkActions({queryJSON}: UseSearchBulkActionsParams) { if (shouldShowPayOption) { allMatchingOptions.push(payButtonOption); } - // The backend only deletes what the user can delete, so one deletable loaded item is enough to offer it. - const hasLoadedDeletableItem = - selectedReports.length && isExpenseReportType - ? selectedReports.some((report) => shouldShowDeleteOption(selectedTransactions, currentSearchResults?.data, accountID, rules, cardList, [report], queryJSON?.type)) - : selectedTransactionsKeys.some((id) => - shouldShowDeleteOption({[id]: selectedTransactions[id]}, currentSearchResults?.data, accountID, rules, cardList, [], queryJSON?.type), - ); - if (!isOffline && isExpenseOrReportSearch && hasLoadedDeletableItem) { - allMatchingOptions.push({ - icon: expensifyIcons.Trashcan, - text: translate('search.bulkActions.delete'), - value: CONST.SEARCH.BULK_ACTION_TYPES.DELETE, - shouldCloseModalOnSelect: true, - onSelected: handleDeleteSelectedTransactions, - }); - } allMatchingOptions.push(exportButtonOption); if (isExpenseReportSearch) { allMatchingOptions.push(downloadPDFOption); @@ -3450,7 +3389,6 @@ function useSearchBulkActions({queryJSON}: UseSearchBulkActionsParams) { isDuplicateReportOptionVisible, invokeDuplicateReportHandler, isExpenseReportType, - isExpenseOrReportSearch, handleDeleteSelectedTransactions, undeleteTransactions, theme.icon, @@ -3549,5 +3487,5 @@ function useSearchBulkActions({queryJSON}: UseSearchBulkActionsParams) { } export default useSearchBulkActions; -export {getAllMatchingExpenseActionQuery, getFullyDeletedGroupKeysByTransactionID, getGroupKeysSelectedViaGroup, getSelectedGroupKeys, shouldShowBulkDuplicateOption}; +export {getFullyDeletedGroupKeysByTransactionID, getGroupKeysSelectedViaGroup, getSelectedGroupKeys, shouldShowBulkDuplicateOption}; export type {SearchHeaderOptionValue}; diff --git a/src/libs/API/parameters/QueueBulkDeleteExpensesParams.ts b/src/libs/API/parameters/QueueBulkDeleteExpensesParams.ts deleted file mode 100644 index 623045f88230..000000000000 --- a/src/libs/API/parameters/QueueBulkDeleteExpensesParams.ts +++ /dev/null @@ -1,14 +0,0 @@ -import type {SearchQueryString} from '@components/Search/types'; - -type QueueBulkDeleteExpensesParams = { - /** Serialized search query describing every expense to delete, so the backend can page through all matches instead of relying on a client-side list */ - jsonQuery: SearchQueryString; - - /** ID of the bulk action record the backend updates as the deletes finish */ - bulkActionID: string; - - /** Comma-separated expenses the user deselected after "Select all" */ - excludedTransactionIDList: string; -}; - -export default QueueBulkDeleteExpensesParams; diff --git a/src/libs/API/parameters/QueueBulkDeleteReportsParams.ts b/src/libs/API/parameters/QueueBulkDeleteReportsParams.ts deleted file mode 100644 index 497f9deadc2f..000000000000 --- a/src/libs/API/parameters/QueueBulkDeleteReportsParams.ts +++ /dev/null @@ -1,11 +0,0 @@ -import type {SearchQueryString} from '@components/Search/types'; - -type QueueBulkDeleteReportsParams = { - /** Serialized search query describing every report to delete, so the backend can page through all matches instead of relying on a client-side list */ - jsonQuery: SearchQueryString; - - /** ID of the bulk action record the backend updates as the deletes finish */ - bulkActionID: string; -}; - -export default QueueBulkDeleteReportsParams; diff --git a/src/libs/API/parameters/index.ts b/src/libs/API/parameters/index.ts index 299decc2df21..56d7f60e8595 100644 --- a/src/libs/API/parameters/index.ts +++ b/src/libs/API/parameters/index.ts @@ -659,8 +659,6 @@ export type {default as ExportSearchWithTemplateParams} from './ExportSearchWith export type {default as QueueExportSearchItemsToCSVParams} from './QueueExportSearchItemsToCSVParams'; export type {default as QueueExportSearchWithTemplateParams} from './QueueExportSearchWithTemplateParams'; export type {default as QueueBulkPayReportsParams} from './QueueBulkPayReportsParams'; -export type {default as QueueBulkDeleteReportsParams} from './QueueBulkDeleteReportsParams'; -export type {default as QueueBulkDeleteExpensesParams} from './QueueBulkDeleteExpensesParams'; export type {default as QueueBulkMarkAsExportedParams} from './QueueBulkMarkAsExportedParams'; export type {default as AssignReportToMeParams} from './AssignReportToMeParams'; export type {default as AddReportApproverParams} from './AddReportApproverParams'; diff --git a/src/libs/API/types.ts b/src/libs/API/types.ts index 2757a521ab70..14728d8764d0 100644 --- a/src/libs/API/types.ts +++ b/src/libs/API/types.ts @@ -660,8 +660,6 @@ const WRITE_COMMANDS = { QUEUE_EXPORT_SEARCH_ITEMS_TO_CSV: 'QueueExportSearchToCSV', QUEUE_EXPORT_SEARCH_WITH_TEMPLATE: 'QueueExportSearchWithTemplate', QUEUE_BULK_PAY_REPORTS: 'QueueBulkPayReports', - QUEUE_BULK_DELETE_REPORTS: 'QueueBulkDeleteReports', - QUEUE_BULK_DELETE_EXPENSES: 'QueueBulkDeleteExpenses', QUEUE_BULK_MARK_AS_EXPORTED: 'QueueBulkMarkAsExported', CREATE_WORKSPACE_APPROVAL: 'CreateWorkspaceApproval', UPDATE_WORKSPACE_APPROVAL: 'UpdateWorkspaceApproval', @@ -1506,8 +1504,6 @@ type WriteCommandParameters = { [WRITE_COMMANDS.QUEUE_EXPORT_SEARCH_ITEMS_TO_CSV]: Parameters.QueueExportSearchItemsToCSVParams; [WRITE_COMMANDS.QUEUE_EXPORT_SEARCH_WITH_TEMPLATE]: Parameters.QueueExportSearchWithTemplateParams; [WRITE_COMMANDS.QUEUE_BULK_PAY_REPORTS]: Parameters.QueueBulkPayReportsParams; - [WRITE_COMMANDS.QUEUE_BULK_DELETE_REPORTS]: Parameters.QueueBulkDeleteReportsParams; - [WRITE_COMMANDS.QUEUE_BULK_DELETE_EXPENSES]: Parameters.QueueBulkDeleteExpensesParams; [WRITE_COMMANDS.QUEUE_BULK_MARK_AS_EXPORTED]: Parameters.QueueBulkMarkAsExportedParams; [WRITE_COMMANDS.EXPORT_REPORT_TO_CSV]: Parameters.ExportReportCSVParams; [WRITE_COMMANDS.CREATE_WORKSPACE_APPROVAL]: Parameters.CreateWorkspaceApprovalParams; diff --git a/src/libs/actions/Search.ts b/src/libs/actions/Search.ts index 5b5d3ed10537..d57a9238ec80 100644 --- a/src/libs/actions/Search.ts +++ b/src/libs/actions/Search.ts @@ -2261,18 +2261,6 @@ function queueBulkPayReports(jsonQuery: string) { write(WRITE_COMMANDS.QUEUE_BULK_PAY_REPORTS, {jsonQuery, bulkActionID}, onyxData); } -/** Queues a delete for every report matching the search query that the user can delete. */ -function queueBulkDeleteReports(jsonQuery: string) { - const {bulkActionID, onyxData} = buildBulkActionOnyxData(CONST.SEARCH.BULK_ACTION_TYPES.DELETE); - write(WRITE_COMMANDS.QUEUE_BULK_DELETE_REPORTS, {jsonQuery, bulkActionID}, onyxData); -} - -/** Queues a delete for every expense matching the search query that the user can delete. */ -function queueBulkDeleteExpenses(jsonQuery: string, excludedTransactionIDList: string[]) { - const {bulkActionID, onyxData} = buildBulkActionOnyxData(CONST.BULK_ACTION.DELETE_EXPENSES); - write(WRITE_COMMANDS.QUEUE_BULK_DELETE_EXPENSES, {jsonQuery, bulkActionID, excludedTransactionIDList: excludedTransactionIDList.join(',')}, onyxData); -} - /** * Queues a manual bulk "Mark as exported" for every report matching the given search query on the given connection. * The backend pages through all matches itself, so this covers reports beyond the currently loaded page(s) when @@ -2724,8 +2712,6 @@ export { queueExportSearchItemsToCSV, queueExportSearchWithTemplate, queueBulkPayReports, - queueBulkDeleteReports, - queueBulkDeleteExpenses, queueBulkMarkAsExported, updateAdvancedFilters, setSearchContext, diff --git a/tests/unit/hooks/useSearchBulkActionsTest.ts b/tests/unit/hooks/useSearchBulkActionsTest.ts index c612600aa5b7..d5c952ef1bbd 100644 --- a/tests/unit/hooks/useSearchBulkActionsTest.ts +++ b/tests/unit/hooks/useSearchBulkActionsTest.ts @@ -1,15 +1,12 @@ import {act, renderHook, waitFor} from '@testing-library/react-native'; -import {ModalActions} from '@components/Modal/Global/ModalContext'; import OnyxListItemProvider from '@components/OnyxListItemProvider'; import type {SearchQueryJSON, SelectedReports, SelectedTransactions} from '@components/Search/types'; import useSearchBulkActions from '@hooks/useSearchBulkActions'; import {unholdRequest} from '@libs/actions/IOU/Hold'; -import {exportSearchItemsToCSV, getExportTemplates, queueBulkDeleteExpenses, queueBulkDeleteReports, queueExportSearchItemsToCSV, queueExportSearchWithTemplate} from '@libs/actions/Search'; -import type * as NetworkState from '@libs/NetworkState'; -import type * as SearchUIUtils from '@libs/SearchUIUtils'; +import {exportSearchItemsToCSV, getExportTemplates, queueExportSearchItemsToCSV, queueExportSearchWithTemplate} from '@libs/actions/Search'; import CONST from '@src/CONST'; import ONYXKEYS from '@src/ONYXKEYS'; @@ -35,8 +32,6 @@ jest.mock('@libs/actions/Search', () => ({ exportSearchItemsToCSV: jest.fn(), queueExportSearchItemsToCSV: jest.fn(() => 'mock-export-id'), queueExportSearchWithTemplate: jest.fn(() => 'mock-template-export-id'), - queueBulkDeleteExpenses: jest.fn(), - queueBulkDeleteReports: jest.fn(), getSearchApproveOnyxData: jest.fn(() => ({})), getSearchPayOnyxData: jest.fn(() => ({})), bulkDeleteReports: jest.fn(), @@ -112,12 +107,6 @@ jest.mock('@hooks/useNetwork', () => ({ default: () => ({isOffline: mockIsOffline}), })); -let mockIsNetworkOffline = false; -jest.mock('@libs/NetworkState', () => ({ - ...jest.requireActual('@libs/NetworkState'), - getIsOffline: () => mockIsNetworkOffline, -})); - const mockShowDecisionModal = jest.fn(); jest.mock('@hooks/useDecisionModal', () => ({ __esModule: true, @@ -134,19 +123,9 @@ jest.mock('@components/DelegateNoAccessModalProvider', () => ({ useDelegateNoAccessActions: () => ({showDelegateNoAccessModal: jest.fn()}), })); -jest.mock('@libs/SearchUIUtils', () => ({ - ...jest.requireActual('@libs/SearchUIUtils'), - shouldShowDeleteOption: jest.fn(() => true), -})); - -const mockShowConfirmModal = jest.fn(); jest.mock('@hooks/useConfirmModal', () => ({ __esModule: true, - default: () => ({showConfirmModal: mockShowConfirmModal}), -})); -jest.mock('@libs/showConfirmModalAfterMoreMenuDismiss', () => ({ - __esModule: true, - default: (showConfirmModal: (options: unknown) => Promise, options: unknown) => showConfirmModal(options), + default: () => ({showConfirmModal: jest.fn()}), })); jest.mock('@hooks/usePermissions', () => ({ @@ -751,110 +730,3 @@ describe('useSearchBulkActions - CSV export flow', () => { }); }); }); - -describe('useSearchBulkActions - Delete under Select all', () => { - beforeAll(() => { - Onyx.init({keys: ONYXKEYS}); - }); - - beforeEach(async () => { - jest.clearAllMocks(); - mockIsOffline = false; - mockIsNetworkOffline = false; - mockAreAllMatchingItemsSelected = true; - await Onyx.clear(); - mockSelectedTransactions = {tx1: makeSelectedTransaction()}; - mockExcludedTransactions = {}; - mockSelectedReports = []; - mockCurrentSearchResults = undefined; - mockGetExportTemplates.mockReturnValue({customTemplates: [], defaultTemplates: []}); - - await Onyx.merge(ONYXKEYS.SESSION, {accountID: CURRENT_USER_ACCOUNT_ID, email: 'test@example.com'}); - }); - - afterEach(async () => { - await Onyx.clear(); - }); - - it('queues a server-side delete of every matching report once the user confirms', async () => { - // Given "Select all" on a reports search and a user who confirms the delete - mockShowConfirmModal.mockResolvedValue({action: ModalActions.CONFIRM}); - const {result} = renderHook(() => useSearchBulkActions({queryJSON: expenseReportQueryJSON}), {wrapper: OnyxListItemProvider}); - - // When the user deletes the selection - await waitFor(() => { - expect(result.current.headerButtonsOptions.some((option) => option.value === CONST.SEARCH.BULK_ACTION_TYPES.DELETE)).toBe(true); - }); - const deleteOption = result.current.headerButtonsOptions.find((option) => option.value === CONST.SEARCH.BULK_ACTION_TYPES.DELETE); - await act(async () => { - await deleteOption?.onSelected?.(); - }); - - // Then the search is handed to the backend to delete the reports, not looped per loaded report - expect(queueBulkDeleteReports).toHaveBeenCalledWith(expect.any(String)); - expect(queueBulkDeleteExpenses).not.toHaveBeenCalled(); - expect(mockClearSelectedTransactions).toHaveBeenCalled(); - }); - - it('queues a server-side delete of every matching expense without the ones the user deselected', async () => { - // Given "Select all" on an expenses search with one expense deselected, and a user who confirms the delete - mockExcludedTransactions = {tx2: makeSelectedTransaction()}; - mockShowConfirmModal.mockResolvedValue({action: ModalActions.CONFIRM}); - const {result} = renderHook(() => useSearchBulkActions({queryJSON: baseQueryJSON}), {wrapper: OnyxListItemProvider}); - - // When the user deletes the selection - await waitFor(() => { - expect(result.current.headerButtonsOptions.some((option) => option.value === CONST.SEARCH.BULK_ACTION_TYPES.DELETE)).toBe(true); - }); - const deleteOption = result.current.headerButtonsOptions.find((option) => option.value === CONST.SEARCH.BULK_ACTION_TYPES.DELETE); - await act(async () => { - await deleteOption?.onSelected?.(); - }); - - // Then the search is handed to the backend with the deselected expense listed, so it is kept - expect(queueBulkDeleteExpenses).toHaveBeenCalledWith(expect.any(String), ['tx2']); - expect(queueBulkDeleteReports).not.toHaveBeenCalled(); - }); - - it('deletes nothing when the user goes offline while the confirmation is open', async () => { - // Given "Select all" while online, and a user who loses connection before confirming the delete - mockShowConfirmModal.mockImplementation(() => { - mockIsNetworkOffline = true; - return Promise.resolve({action: ModalActions.CONFIRM}); - }); - const {result} = renderHook(() => useSearchBulkActions({queryJSON: baseQueryJSON}), {wrapper: OnyxListItemProvider}); - - // When the user confirms - await waitFor(() => { - expect(result.current.headerButtonsOptions.some((option) => option.value === CONST.SEARCH.BULK_ACTION_TYPES.DELETE)).toBe(true); - }); - const deleteOption = result.current.headerButtonsOptions.find((option) => option.value === CONST.SEARCH.BULK_ACTION_TYPES.DELETE); - await act(async () => { - await deleteOption?.onSelected?.(); - }); - - // Then nothing is queued, since the backend would delete whatever matches once the device reconnects - expect(queueBulkDeleteExpenses).not.toHaveBeenCalled(); - expect(queueBulkDeleteReports).not.toHaveBeenCalled(); - expect(mockShowDecisionModal).toHaveBeenCalled(); - }); - - it('deletes nothing when the user cancels the confirmation', async () => { - // Given "Select all" and a user who cancels the delete confirmation - mockShowConfirmModal.mockResolvedValue({action: ModalActions.CLOSE}); - const {result} = renderHook(() => useSearchBulkActions({queryJSON: baseQueryJSON}), {wrapper: OnyxListItemProvider}); - - // When the user backs out - await waitFor(() => { - expect(result.current.headerButtonsOptions.some((option) => option.value === CONST.SEARCH.BULK_ACTION_TYPES.DELETE)).toBe(true); - }); - const deleteOption = result.current.headerButtonsOptions.find((option) => option.value === CONST.SEARCH.BULK_ACTION_TYPES.DELETE); - await act(async () => { - await deleteOption?.onSelected?.(); - }); - - // Then nothing is queued - expect(queueBulkDeleteExpenses).not.toHaveBeenCalled(); - expect(queueBulkDeleteReports).not.toHaveBeenCalled(); - }); -}); From ef1d6f7e7ff4cbc64ecfe8fe0a9398c3d46615d1 Mon Sep 17 00:00:00 2001 From: allgandaf Date: Tue, 20 Oct 2026 13:42:46 +0530 Subject: [PATCH 59/73] move the modal header comment above the component --- src/components/BulkActionStatusModal.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/BulkActionStatusModal.tsx b/src/components/BulkActionStatusModal.tsx index ef8b302b68bd..f90c44665d99 100644 --- a/src/components/BulkActionStatusModal.tsx +++ b/src/components/BulkActionStatusModal.tsx @@ -26,7 +26,6 @@ import Button from './Button'; import Modal from './Modal'; import Text from './Text'; -/** Shows the progress and result of a bulk action started from Search "Select all". */ const RUNNING_TITLES = { [CONST.SEARCH.BULK_ACTION_TYPES.APPROVE]: 'bulkAction.approvingTitle', [CONST.SEARCH.BULK_ACTION_TYPES.SUBMIT]: 'bulkAction.submittingTitle', @@ -199,6 +198,7 @@ type BulkActionStatusModalProps = { onClose: () => void; }; +/** Shows the progress and result of a bulk action started from Search "Select all". */ function BulkActionStatusModal({bulkActionID, isVisible, onClose}: BulkActionStatusModalProps) { const styles = useThemeStyles(); // isSmallScreenWidth is needed here because the modal type depends on actual screen width, not layout mode From 6f0921936ee9355d9bb14005a700ef84a5a87ab1 Mon Sep 17 00:00:00 2001 From: allgandaf Date: Tue, 20 Oct 2026 13:43:12 +0530 Subject: [PATCH 60/73] drop the isVisible prop from the bulk action status modal --- src/components/BulkActionStatusManager.tsx | 1 - src/components/BulkActionStatusModal.tsx | 6 ++---- 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/src/components/BulkActionStatusManager.tsx b/src/components/BulkActionStatusManager.tsx index 3538de3140dd..01a8f7476f89 100644 --- a/src/components/BulkActionStatusManager.tsx +++ b/src/components/BulkActionStatusManager.tsx @@ -64,7 +64,6 @@ function BulkActionStatusManager() { ); diff --git a/src/components/BulkActionStatusModal.tsx b/src/components/BulkActionStatusModal.tsx index f90c44665d99..1e031fe1d055 100644 --- a/src/components/BulkActionStatusModal.tsx +++ b/src/components/BulkActionStatusModal.tsx @@ -192,14 +192,12 @@ type BulkActionStatusModalProps = { /** The bulk action ID to subscribe to */ bulkActionID: string; - isVisible: boolean; - /** Callback when the modal is closed */ onClose: () => void; }; /** Shows the progress and result of a bulk action started from Search "Select all". */ -function BulkActionStatusModal({bulkActionID, isVisible, onClose}: BulkActionStatusModalProps) { +function BulkActionStatusModal({bulkActionID, onClose}: BulkActionStatusModalProps) { const styles = useThemeStyles(); // isSmallScreenWidth is needed here because the modal type depends on actual screen width, not layout mode // eslint-disable-next-line rulesdir/prefer-shouldUseNarrowLayout-instead-of-isSmallScreenWidth @@ -220,7 +218,7 @@ function BulkActionStatusModal({bulkActionID, isVisible, onClose}: BulkActionSta return ( {} : onClose} onBackdropPress={isRunning ? () => {} : undefined} shouldTreatModalAsCovering From d87a79bda6960badd1b62192637966e60830443b Mon Sep 17 00:00:00 2001 From: allgandaf Date: Tue, 20 Oct 2026 14:34:48 +0530 Subject: [PATCH 61/73] keep the reports search check for select all pay --- src/hooks/useSearchBulkActions.ts | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/hooks/useSearchBulkActions.ts b/src/hooks/useSearchBulkActions.ts index 2b259a09ffcb..8e656c98e687 100644 --- a/src/hooks/useSearchBulkActions.ts +++ b/src/hooks/useSearchBulkActions.ts @@ -1643,12 +1643,13 @@ function useSearchBulkActions({queryJSON}: UseSearchBulkActionsParams) { } if (areAllMatchingItemsSelected) { - const allMatchingQuery = queryJSON ? getAllMatchingReportQuery(queryJSON, excludedTransactions) : undefined; - if (!allMatchingQuery) { + const allMatchingQuery = isExpenseReportType && queryJSON ? getAllMatchingReportQuery(queryJSON, excludedTransactions) : queryJSON; + if (isExpenseReportType && !allMatchingQuery) { Log.info('[BulkPay] Dropping bulk pay: report exclusion has no reportID'); return; } - queueBulkPayReports(serializeQueryJSONForBackend(allMatchingQuery)); + const serializedQuery = allMatchingQuery ? serializeQueryJSONForBackend(allMatchingQuery) : JSON.stringify(allMatchingQuery); + queueBulkPayReports(serializedQuery); clearSelectedTransactions(); return; } @@ -1905,6 +1906,7 @@ function useSearchBulkActions({queryJSON}: UseSearchBulkActionsParams) { areAllMatchingItemsSelected, queryJSON, excludedTransactions, + isExpenseReportType, isOffline, isBetaEnabled, isDelegateAccessRestricted, From c5b535f87b6206dc2e10bf8db70a57815d276fb7 Mon Sep 17 00:00:00 2001 From: allgandaf Date: Tue, 20 Oct 2026 14:34:49 +0530 Subject: [PATCH 62/73] add space between the result title and the close button --- src/components/BulkActionStatusModal.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/BulkActionStatusModal.tsx b/src/components/BulkActionStatusModal.tsx index 1e031fe1d055..b55d442c0637 100644 --- a/src/components/BulkActionStatusModal.tsx +++ b/src/components/BulkActionStatusModal.tsx @@ -141,7 +141,7 @@ function BulkActionDone({action, total, failedReportIDs, onClose}: BulkActionDon return ( <> - {doneTitle} + 0 ? styles.mb2 : styles.mb5]}>{doneTitle} {total === 0 && {translate('bulkAction.noReportsBody')}} {failedReportIDs.length > 0 && ( <> From e271052aa017cb4f04f275ed09d5e26029dcaa1f Mon Sep 17 00:00:00 2001 From: allgandaf Date: Tue, 20 Oct 2026 15:40:40 +0530 Subject: [PATCH 63/73] wait for other modals to close before showing the bulk action status --- src/components/BulkActionStatusManager.tsx | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/components/BulkActionStatusManager.tsx b/src/components/BulkActionStatusManager.tsx index 01a8f7476f89..2902f39e6671 100644 --- a/src/components/BulkActionStatusManager.tsx +++ b/src/components/BulkActionStatusManager.tsx @@ -5,6 +5,7 @@ import {clearBulkAction, wasBulkActionInitiatedLocally} from '@libs/actions/Bulk import CONST from '@src/CONST'; import ONYXKEYS from '@src/ONYXKEYS'; +import {isModalActiveSelector} from '@selectors/Modal'; import React, {useState} from 'react'; import BulkActionStatusModal from './BulkActionStatusModal'; @@ -13,6 +14,7 @@ import BulkActionStatusModal from './BulkActionStatusModal'; function BulkActionStatusManager() { const [bulkActions, bulkActionsMetadata] = useOnyx(ONYXKEYS.COLLECTION.BULK_ACTION); const [openBulkActionID, setOpenBulkActionID] = useState(); + const [isAnyOtherModalActive] = useOnyx(ONYXKEYS.MODAL, {selector: isModalActiveSelector}); // A record that already existed when this tab loaded resurfaces after a reload. One started in another tab // after that doesn't pop open here until this tab reloads. @@ -32,7 +34,8 @@ function BulkActionStatusManager() { const surfaceableBulkActionID = surfaceableKey?.replace(ONYXKEYS.COLLECTION.BULK_ACTION, ''); // Keep the modal open through the switch to shouldSendFromConcierge, and close it once the record is gone. - if (!openBulkActionID && surfaceableBulkActionID) { + // The menu that started the bulk action may still be closing, and iOS can't open a modal on top of it. + if (!openBulkActionID && surfaceableBulkActionID && !isAnyOtherModalActive) { setOpenBulkActionID(surfaceableBulkActionID); } if (openBulkActionID && !bulkActions?.[`${ONYXKEYS.COLLECTION.BULK_ACTION}${openBulkActionID}`]) { From d34b10632598278b531323ed8076996706ac5fcd Mon Sep 17 00:00:00 2001 From: allgandaf Date: Tue, 20 Oct 2026 15:40:40 +0530 Subject: [PATCH 64/73] test the status modal waits for the closing menu --- tests/unit/BulkActionStatusManagerTest.tsx | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/tests/unit/BulkActionStatusManagerTest.tsx b/tests/unit/BulkActionStatusManagerTest.tsx index 0b89eaf648e1..56ab379ab388 100644 --- a/tests/unit/BulkActionStatusManagerTest.tsx +++ b/tests/unit/BulkActionStatusManagerTest.tsx @@ -138,6 +138,25 @@ describe('BulkActionStatusManager', () => { expect(screen.getByText('bulkAction.heldTitle')).toBeTruthy(); }); + it('waits for the menu that started the bulk action to close before showing it', async () => { + // Given a bulk pay that just started while the Pay menu is still closing + await Onyx.set(ONYXKEYS.MODAL, {isVisible: true, isPopover: true}); + await Onyx.set(BULK_ACTION_KEY, {state: CONST.BULK_ACTION.STATE.RUNNING, action: CONST.SEARCH.BULK_ACTION_TYPES.PAY}); + + render(); + await waitForBatchedUpdatesWithAct(); + + // Then nothing opens yet, since iOS can't open a modal on top of one that is closing + expect(screen.queryByText('bulkAction.payingTitle')).toBeNull(); + + // When the menu has closed + await Onyx.set(ONYXKEYS.MODAL, {isVisible: false}); + await waitForBatchedUpdatesWithAct(); + + // Then the bulk pay shows + expect(screen.getByText('bulkAction.payingTitle')).toBeTruthy(); + }); + it('says so when no report matched', async () => { // Given a bulk pay that found no report to mark as paid await Onyx.set(BULK_ACTION_KEY, {state: CONST.BULK_ACTION.STATE.DONE, action: CONST.SEARCH.BULK_ACTION_TYPES.PAY, total: 0}); From 0b7180e158ebf60652dfbb558c0cb2072a37fc1a Mon Sep 17 00:00:00 2001 From: allgandaf Date: Thu, 22 Oct 2026 02:25:21 +0530 Subject: [PATCH 65/73] play the success sound for select all pay again --- src/hooks/useSearchBulkActions.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/src/hooks/useSearchBulkActions.ts b/src/hooks/useSearchBulkActions.ts index 8e656c98e687..5a6967f5e8e1 100644 --- a/src/hooks/useSearchBulkActions.ts +++ b/src/hooks/useSearchBulkActions.ts @@ -1650,6 +1650,7 @@ function useSearchBulkActions({queryJSON}: UseSearchBulkActionsParams) { } const serializedQuery = allMatchingQuery ? serializeQueryJSONForBackend(allMatchingQuery) : JSON.stringify(allMatchingQuery); queueBulkPayReports(serializedQuery); + playSound(SOUNDS.SUCCESS); clearSelectedTransactions(); return; } From 8f3c89336074597c19b080044e50066e85de4daa Mon Sep 17 00:00:00 2001 From: allgandaf Date: Thu, 22 Oct 2026 02:26:56 +0530 Subject: [PATCH 66/73] clear the bulk action once from view reports --- src/components/BulkActionStatusModal.tsx | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/components/BulkActionStatusModal.tsx b/src/components/BulkActionStatusModal.tsx index b55d442c0637..9e73303fdf87 100644 --- a/src/components/BulkActionStatusModal.tsx +++ b/src/components/BulkActionStatusModal.tsx @@ -132,10 +132,12 @@ function BulkActionDone({action, total, failedReportIDs, onClose}: BulkActionDon const viewFailedReports = () => { const queryJSON = buildSearchQueryJSON(`type:${CONST.SEARCH.DATA_TYPES.EXPENSE_REPORT} ${CONST.SEARCH.SYNTAX_FILTER_KEYS.REPORT_ID}:${failedReportIDs.join(',')}`); - onClose(); if (!queryJSON) { + onClose(); return; } + + // close() runs the modal's onClose, which clears the record. close(() => Navigation.navigate(ROUTES.SEARCH_ROOT.getRoute({query: buildSearchQueryString(queryJSON)}))); }; From e3425f298c05ac791739c1bace27d9ae42315130 Mon Sep 17 00:00:00 2001 From: allgandaf Date: Thu, 22 Oct 2026 02:26:57 +0530 Subject: [PATCH 67/73] test view reports clears the bulk action once --- tests/unit/BulkActionStatusManagerTest.tsx | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/tests/unit/BulkActionStatusManagerTest.tsx b/tests/unit/BulkActionStatusManagerTest.tsx index 56ab379ab388..5459569b4bac 100644 --- a/tests/unit/BulkActionStatusManagerTest.tsx +++ b/tests/unit/BulkActionStatusManagerTest.tsx @@ -20,10 +20,17 @@ jest.mock('@userActions/BulkAction', () => ({ clearBulkAction: jest.fn(), wasBulkActionInitiatedLocally: jest.fn(() => false), })); -jest.mock('@userActions/Modal', () => ({ - ...jest.requireActual('@userActions/Modal'), - close: jest.fn((cb?: () => void) => cb?.()), -})); +jest.mock('@userActions/Modal', () => { + const actualModal = jest.requireActual('@userActions/Modal'); + return { + ...actualModal, + // Like the real close(), this runs the open modal's onClose before the callback. + close: jest.fn((cb?: () => void) => { + actualModal.closeTop(); + cb?.(); + }), + }; +}); jest.mock('@libs/Navigation/Navigation', () => ({ navigate: jest.fn(), isNavigationReady: jest.fn(() => Promise.resolve()), @@ -103,6 +110,7 @@ describe('BulkActionStatusManager', () => { // Then Search opens on exactly those reports and the record is cleared expect(mockNavigate).toHaveBeenCalledWith(expect.stringMatching(/reportID%3A111%2C222/)); + expect(mockClearBulkAction).toHaveBeenCalledTimes(1); expect(mockClearBulkAction).toHaveBeenCalledWith(BULK_ACTION_ID, expect.objectContaining({state: CONST.BULK_ACTION.STATE.DONE})); }); From 0e5c2746ff610513197ca861bbe123ed8548e57c Mon Sep 17 00:00:00 2001 From: allgandaf Date: Thu, 22 Oct 2026 02:30:03 +0530 Subject: [PATCH 68/73] clear a failed bulk action on the device only --- src/libs/actions/BulkAction.ts | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/libs/actions/BulkAction.ts b/src/libs/actions/BulkAction.ts index 950008224428..000048f0b820 100644 --- a/src/libs/actions/BulkAction.ts +++ b/src/libs/actions/BulkAction.ts @@ -71,6 +71,12 @@ function clearBulkAction(bulkActionID: string, bulkAction: OnyxEntry locallyInitiatedBulkActionIDs.delete(bulkActionID); const onyxKey = `${ONYXKEYS.COLLECTION.BULK_ACTION}${bulkActionID}` as const; + // A failed bulk action only exists on this device, since the backend drops it when queuing fails. + if (bulkAction?.state === CONST.BULK_ACTION.STATE.FAILED) { + Onyx.set(onyxKey, null); + return; + } + const optimisticData: AnyOnyxUpdate[] = [ { onyxMethod: Onyx.METHOD.SET, From 9e13dbfe201bfb9dd9b141258007a16ae75ef673 Mon Sep 17 00:00:00 2001 From: allgandaf Date: Thu, 22 Oct 2026 02:30:03 +0530 Subject: [PATCH 69/73] test clearing a failed and a finished bulk action --- tests/unit/BulkActionActionsTest.ts | 64 +++++++++++++++++++++++++++++ 1 file changed, 64 insertions(+) create mode 100644 tests/unit/BulkActionActionsTest.ts diff --git a/tests/unit/BulkActionActionsTest.ts b/tests/unit/BulkActionActionsTest.ts new file mode 100644 index 000000000000..6e7d854a37e0 --- /dev/null +++ b/tests/unit/BulkActionActionsTest.ts @@ -0,0 +1,64 @@ +import {WRITE_COMMANDS} from '@libs/API/types'; + +import {clearBulkAction} from '@userActions/BulkAction'; + +import CONST from '@src/CONST'; +import ONYXKEYS from '@src/ONYXKEYS'; + +import Onyx from 'react-native-onyx'; + +import type {MockFetch} from '../utils/TestHelper'; + +import getOnyxValue from '../utils/getOnyxValue'; +import * as TestHelper from '../utils/TestHelper'; +import waitForBatchedUpdates from '../utils/waitForBatchedUpdates'; + +jest.mock('@libs/Navigation/Navigation'); + +function getRequestedCommands(mockFetch: MockFetch): string[] { + return mockFetch.mock.calls.map(([url]) => String(url)); +} + +describe('BulkAction actions', () => { + let mockFetch: MockFetch; + + beforeAll(() => { + Onyx.init({keys: ONYXKEYS}); + }); + + beforeEach(() => { + mockFetch = TestHelper.getGlobalFetchMock(); + global.fetch = mockFetch; + return Onyx.clear().then(waitForBatchedUpdates); + }); + + test('clearBulkAction removes a failed bulk action without asking the backend', async () => { + // Given a bulk action whose queue request failed, so the backend never kept it + const onyxKey = `${ONYXKEYS.COLLECTION.BULK_ACTION}111` as const; + const failedBulkAction = {state: CONST.BULK_ACTION.STATE.FAILED, action: CONST.SEARCH.BULK_ACTION_TYPES.PAY}; + await Onyx.set(onyxKey, failedBulkAction); + + // When the user closes it + clearBulkAction('111', failedBulkAction); + await waitForBatchedUpdates(); + + // Then it's gone, and no ClearBulkAction request is sent that could fail and bring it back + expect(await getOnyxValue(onyxKey)).toBeUndefined(); + expect(getRequestedCommands(mockFetch).some((url) => url.includes(WRITE_COMMANDS.CLEAR_BULK_ACTION))).toBe(false); + }); + + test('clearBulkAction asks the backend to clear a finished bulk action', async () => { + // Given a finished bulk action the backend saved + const onyxKey = `${ONYXKEYS.COLLECTION.BULK_ACTION}222` as const; + const doneBulkAction = {state: CONST.BULK_ACTION.STATE.DONE, action: CONST.SEARCH.BULK_ACTION_TYPES.PAY, total: 2, failedReportIDs: []}; + await Onyx.set(onyxKey, doneBulkAction); + + // When the user closes it + clearBulkAction('222', doneBulkAction); + await waitForBatchedUpdates(); + + // Then it's gone here and the backend is asked to drop it too + expect(await getOnyxValue(onyxKey)).toBeUndefined(); + expect(getRequestedCommands(mockFetch).some((url) => url.includes(WRITE_COMMANDS.CLEAR_BULK_ACTION))).toBe(true); + }); +}); From 102516166c8596a4d897cafc9c1b6b872a6f090a Mon Sep 17 00:00:00 2001 From: allgandaf Date: Thu, 22 Oct 2026 02:32:24 +0530 Subject: [PATCH 70/73] check the clear request with the API test helper --- tests/unit/BulkActionActionsTest.ts | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/tests/unit/BulkActionActionsTest.ts b/tests/unit/BulkActionActionsTest.ts index 6e7d854a37e0..52fc0c49ba5f 100644 --- a/tests/unit/BulkActionActionsTest.ts +++ b/tests/unit/BulkActionActionsTest.ts @@ -15,10 +15,6 @@ import waitForBatchedUpdates from '../utils/waitForBatchedUpdates'; jest.mock('@libs/Navigation/Navigation'); -function getRequestedCommands(mockFetch: MockFetch): string[] { - return mockFetch.mock.calls.map(([url]) => String(url)); -} - describe('BulkAction actions', () => { let mockFetch: MockFetch; @@ -44,7 +40,7 @@ describe('BulkAction actions', () => { // Then it's gone, and no ClearBulkAction request is sent that could fail and bring it back expect(await getOnyxValue(onyxKey)).toBeUndefined(); - expect(getRequestedCommands(mockFetch).some((url) => url.includes(WRITE_COMMANDS.CLEAR_BULK_ACTION))).toBe(false); + TestHelper.expectAPICommandToHaveBeenCalled(WRITE_COMMANDS.CLEAR_BULK_ACTION, 0); }); test('clearBulkAction asks the backend to clear a finished bulk action', async () => { @@ -59,6 +55,6 @@ describe('BulkAction actions', () => { // Then it's gone here and the backend is asked to drop it too expect(await getOnyxValue(onyxKey)).toBeUndefined(); - expect(getRequestedCommands(mockFetch).some((url) => url.includes(WRITE_COMMANDS.CLEAR_BULK_ACTION))).toBe(true); + TestHelper.expectAPICommandToHaveBeenCalled(WRITE_COMMANDS.CLEAR_BULK_ACTION, 1); }); }); From 330883912f15ab69c2348fdc466d6cc4c946fd7f Mon Sep 17 00:00:00 2001 From: allgandaf Date: Fri, 23 Oct 2026 12:08:11 +0530 Subject: [PATCH 71/73] use the agreed copy while a bulk action runs --- src/languages/de.ts | 2 +- src/languages/el.ts | 2 +- src/languages/en.ts | 2 +- src/languages/es.ts | 2 +- src/languages/fr.ts | 2 +- src/languages/it.ts | 2 +- src/languages/ja.ts | 2 +- src/languages/nl.ts | 2 +- src/languages/pl.ts | 2 +- src/languages/pt-BR.ts | 2 +- src/languages/zh-hans.ts | 2 +- 11 files changed, 11 insertions(+), 11 deletions(-) diff --git a/src/languages/de.ts b/src/languages/de.ts index de0a5564b913..615110596378 100644 --- a/src/languages/de.ts +++ b/src/languages/de.ts @@ -12135,7 +12135,7 @@ Hier ist ein *Testbeleg*, um dir zu zeigen, wie es funktioniert:`, rejectingTitle: 'Ausgaben werden abgelehnt …', deletingTitle: 'Berichte werden gelöscht …', deletingExpensesTitle: 'Ausgaben werden gelöscht …', - runningBody: 'Dies kann einige Minuten dauern. Sie können hier warten, oder Concierge kann Ihnen eine Nachricht senden, wenn es fertig ist.', + runningBody: 'Warten Sie ein paar Minuten, oder Concierge kann Sie benachrichtigen, wenn es fertig ist.', sendFromConcierge: 'Mir eine Nachricht senden, wenn es fertig ist', conciergeTitle: 'Auf jeden Fall!', conciergeBody: 'Concierge wird Ihnen eine Nachricht senden, sobald es fertig ist.', diff --git a/src/languages/el.ts b/src/languages/el.ts index 4ca32a0ee17c..2d6c07084e8b 100644 --- a/src/languages/el.ts +++ b/src/languages/el.ts @@ -12362,7 +12362,7 @@ ${reportName}`, rejectingTitle: 'Απόρριψη εξόδων...', deletingTitle: 'Γίνεται διαγραφή αναφορών...', deletingExpensesTitle: 'Γίνεται διαγραφή εξόδων...', - runningBody: 'Αυτό μπορεί να πάρει μερικά λεπτά. Μπορείτε να περιμένετε εδώ ή ο Concierge μπορεί να σας στείλει μήνυμα όταν ολοκληρωθεί.', + runningBody: 'Περιμένετε μερικά λεπτά ή αφήστε το Concierge να σας στείλει μήνυμα όταν ολοκληρωθεί.', sendFromConcierge: 'Στείλτε μου μήνυμα όταν τελειώσει', conciergeTitle: 'Βεβαίως!', conciergeBody: 'Ο Concierge θα σας στείλει μήνυμα όταν ολοκληρωθεί.', diff --git a/src/languages/en.ts b/src/languages/en.ts index 75a54bca49f6..77bae8d49b28 100644 --- a/src/languages/en.ts +++ b/src/languages/en.ts @@ -12145,7 +12145,7 @@ const translations = { rejectingTitle: 'Rejecting expenses...', deletingTitle: 'Deleting reports...', deletingExpensesTitle: 'Deleting expenses...', - runningBody: "This can take a few minutes. You can wait here, or Concierge can message you when it's done.", + runningBody: "Wait a few minutes, or Concierge can message you when it's done.", sendFromConcierge: "Message me when it's done", conciergeTitle: 'You bet!', conciergeBody: "Concierge will message you when it's done.", diff --git a/src/languages/es.ts b/src/languages/es.ts index 8272d401dad8..e023f080e92e 100644 --- a/src/languages/es.ts +++ b/src/languages/es.ts @@ -12398,7 +12398,7 @@ ${reportName}`, rejectingTitle: 'Rechazando gastos...', deletingTitle: 'Eliminando informes...', deletingExpensesTitle: 'Eliminando gastos...', - runningBody: 'Esto puede tardar unos minutos. Puedes esperar aquí o Concierge puede enviarte un mensaje cuando haya terminado.', + runningBody: 'Espera unos minutos o deja que Concierge te envíe un mensaje cuando termine.', sendFromConcierge: 'Envíame un mensaje cuando esté listo', conciergeTitle: '¡Por supuesto!', conciergeBody: 'Concierge te enviará un mensaje cuando haya terminado.', diff --git a/src/languages/fr.ts b/src/languages/fr.ts index 9d80a6483689..a532e9bad96a 100644 --- a/src/languages/fr.ts +++ b/src/languages/fr.ts @@ -12169,7 +12169,7 @@ Voici un *reçu test* pour vous montrer comment ça fonctionne :`, rejectingTitle: 'Rejet des dépenses...', deletingTitle: 'Suppression des notes de frais...', deletingExpensesTitle: 'Suppression des dépenses...', - runningBody: 'Cela peut prendre quelques minutes. Vous pouvez attendre ici ou Concierge peut vous envoyer un message lorsque ce sera terminé.', + runningBody: 'Patientez quelques minutes, ou laissez Concierge vous envoyer un message lorsque ce sera terminé.', sendFromConcierge: 'Envoyez-moi un message quand ce sera fait', conciergeTitle: 'Bien sûr !', conciergeBody: 'Concierge vous enverra un message lorsque ce sera terminé.', diff --git a/src/languages/it.ts b/src/languages/it.ts index 43bb660d5fe7..93d08bb4dde6 100644 --- a/src/languages/it.ts +++ b/src/languages/it.ts @@ -12087,7 +12087,7 @@ Ecco una *ricevuta di prova* per mostrarti come funziona:`, rejectingTitle: 'Rifiuto delle spese in corso...', deletingTitle: 'Eliminazione dei report in corso...', deletingExpensesTitle: 'Eliminazione delle spese in corso...', - runningBody: 'Questo può richiedere alcuni minuti. Puoi aspettare qui oppure Concierge può mandarti un messaggio quando è tutto pronto.', + runningBody: 'Aspetta qualche minuto oppure lascia che Concierge ti invii un messaggio quando ha finito.', sendFromConcierge: 'Scrivimi quando hai finito', conciergeTitle: 'Ci puoi contare!', conciergeBody: 'Concierge ti manderà un messaggio quando avrà finito.', diff --git a/src/languages/ja.ts b/src/languages/ja.ts index 72774c6cd367..8a6506a985a2 100644 --- a/src/languages/ja.ts +++ b/src/languages/ja.ts @@ -11913,7 +11913,7 @@ ${reportName}`, rejectingTitle: '経費を却下しています…', deletingTitle: 'レポートを削除しています…', deletingExpensesTitle: '経費を削除しています…', - runningBody: '数分かかる場合があります。ここでお待ちいただくか、完了したときに Concierge からメッセージを受け取ることもできます。', + runningBody: '数分お待ちいただくか、完了したら Concierge からメッセージをお送りすることもできます。', sendFromConcierge: '完了したらメッセージを送ってください', conciergeTitle: 'もちろんです!', conciergeBody: '完了したら Concierge からメッセージが届きます。', diff --git a/src/languages/nl.ts b/src/languages/nl.ts index 167cac6be986..10f25321c2c1 100644 --- a/src/languages/nl.ts +++ b/src/languages/nl.ts @@ -12048,7 +12048,7 @@ Hier is een *proefbon* om je te laten zien hoe het werkt:`, rejectingTitle: 'Uitgaven afwijzen...', deletingTitle: 'Rapporten verwijderen...', deletingExpensesTitle: 'Uitgaven verwijderen...', - runningBody: 'Dit kan een paar minuten duren. Je kunt hier wachten, of Concierge kan je een bericht sturen als het klaar is.', + runningBody: 'Wacht een paar minuten, of laat Concierge je een bericht sturen zodra het klaar is.', sendFromConcierge: 'Stuur me een bericht als het klaar is', conciergeTitle: 'Zeker weten!', conciergeBody: 'Concierge stuurt je een bericht zodra het klaar is.', diff --git a/src/languages/pl.ts b/src/languages/pl.ts index 2577e79293e8..095446595a52 100644 --- a/src/languages/pl.ts +++ b/src/languages/pl.ts @@ -12066,7 +12066,7 @@ Oto *paragon testowy*, żeby pokazać Ci, jak to działa:`, rejectingTitle: 'Odrzucanie wydatków...', deletingTitle: 'Usuwanie raportów...', deletingExpensesTitle: 'Usuwanie wydatków...', - runningBody: 'To może potrwać kilka minut. Możesz poczekać tutaj albo Concierge napisze do ciebie, kiedy będzie gotowe.', + runningBody: 'Poczekaj kilka minut albo pozwól, by Concierge wysłał ci wiadomość, gdy wszystko będzie gotowe.', sendFromConcierge: 'Napisz do mnie, kiedy będzie gotowe', conciergeTitle: 'No jasne!', conciergeBody: 'Gdy Concierge skończy, wyśle ci wiadomość.', diff --git a/src/languages/pt-BR.ts b/src/languages/pt-BR.ts index b9c21a7f4e78..0608550092bd 100644 --- a/src/languages/pt-BR.ts +++ b/src/languages/pt-BR.ts @@ -12039,7 +12039,7 @@ Aqui está um *comprovante de teste* para mostrar como funciona:`, rejectingTitle: 'Rejeitando despesas...', deletingTitle: 'Excluindo relatórios...', deletingExpensesTitle: 'Excluindo despesas...', - runningBody: 'Isso pode levar alguns minutos. Você pode esperar aqui ou o Concierge pode te mandar uma mensagem quando terminar.', + runningBody: 'Espere alguns minutos ou deixe o Concierge avisar você quando terminar.', sendFromConcierge: 'Me avise quando terminar', conciergeTitle: 'Pode apostar!', conciergeBody: 'O Concierge vai te enviar uma mensagem quando terminar.', diff --git a/src/languages/zh-hans.ts b/src/languages/zh-hans.ts index 16ce7ce7282d..bba1de1d55f7 100644 --- a/src/languages/zh-hans.ts +++ b/src/languages/zh-hans.ts @@ -11605,7 +11605,7 @@ ${reportName}`, rejectingTitle: '正在拒绝报销费用…', deletingTitle: '正在删除报表…', deletingExpensesTitle: '正在删除报销费用…', - runningBody: '这可能需要几分钟。你可以在这里等待,或者等完成后由 Concierge 给你发送消息。', + runningBody: '请稍等几分钟,或者由 Concierge 在完成后发送消息通知你。', sendFromConcierge: '完成后给我发消息', conciergeTitle: '当然!', conciergeBody: '完成后,Concierge 会给你发送消息。', From 024a5d2f87700f39520dafe6c3f741004d677d85 Mon Sep 17 00:00:00 2001 From: allgandaf Date: Fri, 23 Oct 2026 12:10:52 +0530 Subject: [PATCH 72/73] say which action failed in the bulk action result --- src/components/BulkActionStatusModal.tsx | 13 ++++++++- src/languages/de.ts | 36 +++++++++++++++++++++--- src/languages/el.ts | 36 +++++++++++++++++++++--- src/languages/en.ts | 34 ++++++++++++++++++++-- src/languages/es.ts | 36 +++++++++++++++++++++--- src/languages/fr.ts | 36 +++++++++++++++++++++--- src/languages/it.ts | 36 +++++++++++++++++++++--- src/languages/ja.ts | 36 +++++++++++++++++++++--- src/languages/nl.ts | 36 +++++++++++++++++++++--- src/languages/pl.ts | 36 +++++++++++++++++++++--- src/languages/pt-BR.ts | 36 +++++++++++++++++++++--- src/languages/zh-hans.ts | 36 +++++++++++++++++++++--- 12 files changed, 363 insertions(+), 44 deletions(-) diff --git a/src/components/BulkActionStatusModal.tsx b/src/components/BulkActionStatusModal.tsx index 9e73303fdf87..fa3b64b8ba94 100644 --- a/src/components/BulkActionStatusModal.tsx +++ b/src/components/BulkActionStatusModal.tsx @@ -48,6 +48,17 @@ const DONE_TITLES = { [CONST.BULK_ACTION.DELETE_EXPENSES]: 'bulkAction.deletedExpensesTitle', } as const satisfies Record; +const FAILED_BODIES = { + [CONST.SEARCH.BULK_ACTION_TYPES.APPROVE]: 'bulkAction.notApprovedBody', + [CONST.SEARCH.BULK_ACTION_TYPES.SUBMIT]: 'bulkAction.notSubmittedBody', + [CONST.SEARCH.BULK_ACTION_TYPES.PAY]: 'bulkAction.notPaidBody', + [CONST.SEARCH.BULK_ACTION_TYPES.HOLD]: 'bulkAction.notHeldBody', + [CONST.SEARCH.BULK_ACTION_TYPES.UNHOLD]: 'bulkAction.notUnheldBody', + [CONST.SEARCH.BULK_ACTION_TYPES.REJECT]: 'bulkAction.notRejectedBody', + [CONST.SEARCH.BULK_ACTION_TYPES.DELETE]: 'bulkAction.notDeletedBody', + [CONST.BULK_ACTION.DELETE_EXPENSES]: 'bulkAction.expensesNotDeletedBody', +} as const satisfies Record; + type BulkActionRunningProps = { /** The action that is running */ action: BulkActionType | undefined; @@ -147,7 +158,7 @@ function BulkActionDone({action, total, failedReportIDs, onClose}: BulkActionDon {total === 0 && {translate('bulkAction.noReportsBody')}} {failedReportIDs.length > 0 && ( <> - {translate('bulkAction.failedReportsBody', {count: failedReportIDs.length})} + {translate(FAILED_BODIES[action ?? CONST.SEARCH.BULK_ACTION_TYPES.PAY], {count: failedReportIDs.length})}