Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
62 changes: 51 additions & 11 deletions src/hooks/useSearchBulkActions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ import Log from '@libs/Log';
import {getTransactionsAndReportsFromSearch} from '@libs/MergeTransactionUtils';
import Navigation from '@libs/Navigation/Navigation';
import TransitionTracker from '@libs/Navigation/TransitionTracker';
import Parser from '@libs/Parser';
import {getLoginByAccountID} from '@libs/PersonalDetailsUtils';
import {getConnectedIntegration, isAdminOfCardEnabledPolicy, isSubmitPolicy} from '@libs/PolicyUtils';
import {getReportAccountingExportActions, isMergeActionForSelectedTransactions} from '@libs/ReportSecondaryActionUtils';
Expand Down Expand Up @@ -92,6 +93,7 @@ import {
} from '@libs/SearchUIUtils';
import showConfirmModalAfterMoreMenuDismiss from '@libs/showConfirmModalAfterMoreMenuDismiss';
import playSound, {SOUNDS} from '@libs/Sound';
import StringUtils from '@libs/StringUtils';
import {shouldRestrictUserBillableActions} from '@libs/SubscriptionUtils';
import {
getDeleteConfirmationPrompt,
Expand All @@ -107,8 +109,6 @@ import {
isPending,
isPerDiemRequest,
isScanning,
showHeldExpensesBlockModal,
showPendingCardTransactionsBlockModal,
} from '@libs/TransactionUtils';

import variables from '@styles/variables';
Expand Down Expand Up @@ -2014,7 +2014,7 @@ function useSearchBulkActions({queryJSON}: UseSearchBulkActionsParams) {
connectionNameFriendly,
reportName: '',
}).trim(),
prompt: exportedReportNames.join('\n'),
prompt: exportedReportNames.map((reportName) => `${CONST.DOT_SEPARATOR} ${reportName}`).join('\n'),
confirmText: translate('workspace.exportAgainModal.confirmText'),
cancelText: translate('workspace.exportAgainModal.cancelText'),
shouldEnablePromptScroll: true,
Expand Down Expand Up @@ -2047,7 +2047,7 @@ function useSearchBulkActions({queryJSON}: UseSearchBulkActionsParams) {
integrationReportIDs.length < integrationGroupSize,
connectionNameFriendly,
),
prompt: exportableReportNames.join('\n'),
prompt: exportableReportNames.map((reportName) => `${CONST.DOT_SEPARATOR} ${reportName}`).join('\n'),
confirmText: translate('workspace.exportPartialModal.confirmText', {count: integrationReportIDs.length}),
cancelText: translate('workspace.exportPartialModal.cancelText'),
shouldEnablePromptScroll: true,
Expand Down Expand Up @@ -2398,22 +2398,35 @@ function useSearchBulkActions({queryJSON}: UseSearchBulkActionsParams) {
.map((id) => selectedTransactions[id]?.transaction ?? allTransactions?.[`${ONYXKEYS.COLLECTION.TRANSACTION}${id}`])
.filter((t): t is NonNullable<typeof t> => !!t);

if (hasOnlyPendingCardTransactions(allSelectedTransactionsList)) {
showPendingCardTransactionsBlockModal(showConfirmModal, translate, allReportsShouldMarkAsDone);
return;
// The blocked-report checks are per report, so group the selected transactions by report.
const transactionsByReportID = new Map<string, Transaction[]>();
for (const transaction of allSelectedTransactionsList) {
if (!transaction.reportID) {
continue;
}
const reportTransactions = transactionsByReportID.get(transaction.reportID);
if (reportTransactions) {
reportTransactions.push(transaction);
} else {
transactionsByReportID.set(transaction.reportID, [transaction]);
}
}

if (hasOnlyHeldExpenses(allSelectedTransactionsList)) {
showHeldExpensesBlockModal(showConfirmModal, translate, allReportsShouldMarkAsDone);
return;
const blockedReportIDs = new Set<string>();
for (const [reportID, reportTransactions] of transactionsByReportID) {
if (hasOnlyPendingCardTransactions(reportTransactions) || hasOnlyHeldExpenses(reportTransactions)) {
blockedReportIDs.add(reportID);
}
}
const areAllSelectedReportsBlocked = blockedReportIDs.size > 0 && blockedReportIDs.size === transactionsByReportID.size;

const selectedReportForSubmit = selectedReports.at(0);
const reportIDForSubmit = selectedReportForSubmit?.reportID ?? selectedTransactionsKeys.map((id) => selectedTransactions[id]?.reportID).find((id): id is string => !!id);
const policyIDForSubmit = selectedReportForSubmit?.policyID ?? selectedTransactionsKeys.map((id) => selectedTransactions[id]?.policyID).find((id): id is string => !!id);
const policyForSubmit = policyIDForSubmit ? policies?.[`${ONYXKEYS.COLLECTION.POLICY}${policyIDForSubmit}`] : undefined;

if (policyForSubmit && isSubmitPolicy(policyForSubmit) && reportIDForSubmit && hash) {
// A blocked report skips the submit-to popover and falls through to the modal below.
if (!areAllSelectedReportsBlocked && policyForSubmit && isSubmitPolicy(policyForSubmit) && reportIDForSubmit && hash) {
Comment thread
NikkiWines marked this conversation as resolved.
Resolved
const snapshotReport = getReportOrDraftReport(
reportIDForSubmit,
undefined,
Expand Down Expand Up @@ -2449,13 +2462,40 @@ function useSearchBulkActions({queryJSON}: UseSearchBulkActionsParams) {
}

for (const item of itemList) {
if (item.reportID && blockedReportIDs.has(item.reportID)) {
continue;
}
const policy = policies?.[`${ONYXKEYS.COLLECTION.POLICY}${item.policyID}`];
if (policy) {
submitMoneyRequestOnSearch(hash, [item as Report], [policy], getLoginByAccountID(item.ownerAccountID, personalDetails), getCurrencyDecimals, rules);
} else {
Log.info('[BulkSubmit] Skipping report: policy not found in Onyx', false, {reportID: item?.reportID, policyID: item?.policyID});
}
}

// List the skipped reports by the name the Search rows display.
if (blockedReportIDs.size > 0) {
const blockedReportNames: string[] = [];
for (const reportID of blockedReportIDs) {
const reportName = searchResults?.data?.[`${ONYXKEYS.COLLECTION.REPORT}${reportID}`]?.reportName;
if (reportName) {
blockedReportNames.push(StringUtils.lineBreaksToSpaces(Parser.htmlToText(reportName)));
}
}
showConfirmModalAfterMoreMenuDismiss(showConfirmModal, {
title: translate(allReportsShouldMarkAsDone ? 'iou.error.reportsNotMarkedAsDoneTitle' : 'iou.error.reportsNotSubmittedTitle'),
subtitle: translate(allReportsShouldMarkAsDone ? 'iou.error.reportsNotMarkedAsDoneDescription' : 'iou.error.reportsNotSubmittedDescription'),
prompt: blockedReportNames.map((reportName) => `${CONST.DOT_SEPARATOR} ${reportName}`).join('\n'),
confirmText: translate('common.buttonConfirm'),
shouldShowCancelButton: false,
shouldEnablePromptScroll: true,
});

if (areAllSelectedReportsBlocked) {
return;
}
}

// Submitting only changes the report, so the rows keep serving the snapshot's pre-submit report
// context (which still offers Submit) until the snapshot is refetched, the same way approving and
// paying from Search already do.
Expand Down
6 changes: 6 additions & 0 deletions src/languages/de.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1625,6 +1625,12 @@ const translations: TranslationDeepObject<typeof en> = {
'Sie können diesen Bericht nicht als erledigt markieren, weil alle Transaktionen ausstehen. Es kann einige Tage dauern, bis sie gebucht werden.',
allExpensesOnHoldDescription: 'Sie können diesen Bericht nicht einreichen, da alle Ausgaben angehalten wurden. Entfernen Sie die Sperre, um ihn einzureichen.',
allExpensesOnHoldMarkAsDoneDescription: 'Sie können diesen Bericht nicht als erledigt markieren, da alle Ausgaben angehalten wurden. Entfernen Sie die Sperre, um fortzufahren.',
reportsNotSubmittedTitle: 'Berichte einreichen',
reportsNotMarkedAsDoneTitle: 'Berichte als erledigt markieren',
reportsNotSubmittedDescription:
'Diese Berichte konnten nicht eingereicht werden. Stellen Sie sicher, dass Ausgaben nicht zurückgehalten oder ausstehend sind, und versuchen Sie es dann erneut.',
reportsNotMarkedAsDoneDescription:
'Diese Berichte konnten nicht als erledigt markiert werden. Prüfen Sie, dass Ausgaben nicht zurückgehalten oder ausstehend sind, und versuchen Sie es dann erneut.',
stitchOdometerImagesFailed: 'Kilometerzählerbilder konnten nicht zusammengeführt werden. Bitte versuchen Sie es später noch einmal.',
failedToSaveOdometerDraft: 'Dein Kilometerzähler-Entwurf konnte nicht gespeichert werden. Bitte versuche es erneut.',
},
Expand Down
5 changes: 5 additions & 0 deletions src/languages/el.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1650,6 +1650,11 @@ const translations: TranslationDeepObject<typeof en> = {
allExpensesOnHoldDescription: 'Δεν μπορείτε να υποβάλετε αυτήν την αναφορά, επειδή όλες οι δαπάνες είναι σε αναμονή. Αφαιρέστε την αναμονή για να την υποβάλετε.',
allExpensesOnHoldMarkAsDoneDescription:
'Δεν μπορείτε να επισημάνετε αυτήν την αναφορά ως ολοκληρωμένη, επειδή όλες οι δαπάνες είναι σε αναμονή. Αφαιρέστε την αναμονή για να συνεχίσετε.',
reportsNotSubmittedTitle: 'Υποβολή αναφορών',
reportsNotMarkedAsDoneTitle: 'Σημειώστε τις αναφορές ως ολοκληρωμένες',
reportsNotSubmittedDescription: 'Αυτές οι αναφορές δεν ήταν δυνατό να υποβληθούν. Ελέγξτε ότι τα έξοδα δεν είναι σε αναμονή ή σε εκκρεμότητα και δοκιμάστε ξανά.',
reportsNotMarkedAsDoneDescription:
'Δεν ήταν δυνατή η επισήμανση αυτών των αναφορών ως ολοκληρωμένων. Ελέγξτε ότι οι δαπάνες δεν είναι σε αναμονή ή εκκρεμείς και δοκιμάστε ξανά.',
failedToSaveOdometerDraft: 'Δεν ήταν δυνατή η αποθήκευση του πρόχειρου χιλιομετρητή σας. Παρακαλούμε δοκιμάστε ξανά.',
invalidIntegerAmount: 'Παρακαλούμε εισαγάγετε ένα ακέραιο ποσό σε δολάρια πριν συνεχίσετε',
invalidTaxAmount: (amount: string) => `Το μέγιστο ποσό φόρου είναι ${amount}`,
Expand Down
4 changes: 4 additions & 0 deletions src/languages/en.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1681,6 +1681,10 @@ const translations = {
allTransactionsPendingMarkAsDoneDescription: "You can't mark this report as done because all transactions are pending. They may take a few days to post.",
allExpensesOnHoldDescription: "You can't submit this report because all expenses are on hold. Remove the hold to submit.",
allExpensesOnHoldMarkAsDoneDescription: "You can't mark this report as done because all expenses are on hold. Remove the hold to continue.",
reportsNotSubmittedTitle: 'Submit reports',
reportsNotMarkedAsDoneTitle: 'Mark reports as done',
reportsNotSubmittedDescription: "These reports couldn't be submitted. Check that expenses aren't held or pending, then try again.",
reportsNotMarkedAsDoneDescription: "These reports couldn't be marked as done. Check that expenses aren't held or pending, then try again.",
failedToSaveOdometerDraft: "Couldn't save your odometer draft. Please try again.",
invalidIntegerAmount: 'Please enter a whole dollar amount before continuing',
invalidTaxAmount: (amount: string) => `Maximum tax amount is ${amount}`,
Expand Down
4 changes: 4 additions & 0 deletions src/languages/es.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1592,6 +1592,10 @@ const translations: TranslationDeepObject<typeof en> = {
allTransactionsPendingMarkAsDoneDescription: 'No puedes marcar este informe como listo porque todas las transacciones están pendientes. Pueden tardar unos días en procesarse.',
allExpensesOnHoldDescription: 'No puedes enviar este informe porque todos los gastos están retenidos. Elimina la retención para enviarlo.',
allExpensesOnHoldMarkAsDoneDescription: 'No puedes marcar este informe como listo porque todos los gastos están retenidos. Elimina la retención para continuar.',
reportsNotSubmittedTitle: 'Enviar informes',
reportsNotMarkedAsDoneTitle: 'Marcar informes como listos',
reportsNotSubmittedDescription: 'No se han podido enviar estos informes. Comprueba que no haya gastos retenidos o pendientes y vuelve a intentarlo.',
reportsNotMarkedAsDoneDescription: 'No se ha podido marcar estos informes como completados. Comprueba que no haya gastos retenidos o pendientes y vuelve a intentarlo.',
stitchOdometerImagesFailed: 'No se pudieron combinar las imágenes del odómetro. Por favor, inténtalo de nuevo más tarde.',
failedToSaveOdometerDraft: 'No se pudo guardar el borrador del odómetro. Por favor, inténtalo de nuevo.',
invalidIntegerAmount: 'Por favor, introduce un importe entero en dólares antes de continuar',
Expand Down
4 changes: 4 additions & 0 deletions src/languages/fr.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1631,6 +1631,10 @@ const translations: TranslationDeepObject<typeof en> = {
allExpensesOnHoldDescription: 'Vous ne pouvez pas soumettre cette note de frais, car toutes les dépenses sont en attente. Supprimez le blocage pour soumettre.',
allExpensesOnHoldMarkAsDoneDescription:
'Vous ne pouvez pas marquer cette note de frais comme terminée, car toutes les dépenses sont en attente. Supprimez le blocage pour continuer.',
reportsNotSubmittedTitle: 'Soumettre des notes de frais',
reportsNotMarkedAsDoneTitle: 'Marquer les notes de frais comme terminées',
reportsNotSubmittedDescription: "Ces notes de frais n'ont pas pu être soumises. Vérifiez qu'aucune dépense n'est en attente ou en suspens, puis réessayez.",
reportsNotMarkedAsDoneDescription: "Ces notes de frais n'ont pas pu être marquées comme terminées. Vérifiez qu'aucune dépense n'est en attente ou en suspens, puis réessayez.",
stitchOdometerImagesFailed: 'Échec de la combinaison des images de l’odomètre. Veuillez réessayer plus tard.',
failedToSaveOdometerDraft: 'Impossible d’enregistrer votre brouillon de compteur kilométrique. Veuillez réessayer.',
},
Expand Down
4 changes: 4 additions & 0 deletions src/languages/it.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1621,6 +1621,10 @@ const translations: TranslationDeepObject<typeof en> = {
'Non puoi segnare questo report come completato perché tutte le transazioni sono in sospeso. Potrebbero volerci alcuni giorni prima che vengano registrate.',
allExpensesOnHoldDescription: 'Non puoi inviare questo report perché tutte le spese sono in sospeso. Rimuovi il blocco per inviarlo.',
allExpensesOnHoldMarkAsDoneDescription: 'Non puoi segnare questo report come completato perché tutte le spese sono in sospeso. Rimuovi il blocco per continuare.',
reportsNotSubmittedTitle: 'Invia report',
reportsNotMarkedAsDoneTitle: 'Segna i report come completati',
reportsNotSubmittedDescription: 'Questi report non possono essere inviati. Controlla che le spese non siano bloccate o in sospeso, poi riprova.',
reportsNotMarkedAsDoneDescription: 'Non è stato possibile contrassegnare questi report come completati. Verifica che le spese non siano bloccate o in sospeso, poi riprova.',
dateRangeExceedsMaxDays: `L’intervallo di date non può superare ${CONST.IOU.SPLITS_LIMIT} giorni.`,
stitchOdometerImagesFailed: 'Impossibile combinare le immagini del contachilometri. Riprova più tardi.',
failedToSaveOdometerDraft: 'Impossibile salvare la tua bozza del contachilometri. Riprova.',
Expand Down
4 changes: 4 additions & 0 deletions src/languages/ja.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1606,6 +1606,10 @@ const translations: TranslationDeepObject<typeof en> = {
allTransactionsPendingMarkAsDoneDescription: 'すべての取引が保留中のため、このレポートを完了にできません。反映されるまでに数日かかる場合があります。',
allExpensesOnHoldDescription: 'すべての経費が保留中のため、このレポートを送信できません。送信するには、保留を解除してください。',
allExpensesOnHoldMarkAsDoneDescription: 'すべての経費が保留中のため、このレポートを完了にできません。続行するには、保留を解除してください。',
reportsNotSubmittedTitle: 'レポートを提出',
reportsNotMarkedAsDoneTitle: 'レポートを完了にする',
reportsNotSubmittedDescription: 'これらのレポートを送信できませんでした。経費が保留中または処理待ちになっていないことを確認してから、もう一度お試しください。',
reportsNotMarkedAsDoneDescription: 'これらのレポートを完了済みにできませんでした。経費が保留中や未処理になっていないか確認してから、もう一度お試しください。',
stitchOdometerImagesFailed: '走行距離計の画像を結合できませんでした。後でもう一度お試しください。',
failedToSaveOdometerDraft: 'オドメーターの下書きを保存できませんでした。もう一度お試しください。',
},
Expand Down
5 changes: 5 additions & 0 deletions src/languages/nl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1620,6 +1620,11 @@ const translations: TranslationDeepObject<typeof en> = {
'Je kunt dit rapport niet markeren als voltooid omdat alle transacties in behandeling zijn. Het kan een paar dagen duren voordat ze worden verwerkt.',
allExpensesOnHoldDescription: 'Je kunt dit rapport niet indienen omdat alle uitgaven zijn gepauzeerd. Verwijder de pauzering om het in te dienen.',
allExpensesOnHoldMarkAsDoneDescription: 'Je kunt dit rapport niet markeren als voltooid omdat alle uitgaven zijn gepauzeerd. Verwijder de pauzering om door te gaan.',
reportsNotSubmittedTitle: 'Rapporten indienen',
reportsNotMarkedAsDoneTitle: 'Rapporten markeren als voltooid',
reportsNotSubmittedDescription: 'Deze rapporten konden niet worden ingediend. Controleer of er geen onkosten vastgehouden of in behandeling zijn en probeer het dan opnieuw.',
reportsNotMarkedAsDoneDescription:
'Deze rapporten konden niet als voltooid worden gemarkeerd. Controleer of er geen onkostendeclaraties vastgehouden of in behandeling zijn en probeer het dan opnieuw.',
stitchOdometerImagesFailed: 'Odometerafbeeldingen combineren mislukt. Probeer het later opnieuw.',
failedToSaveOdometerDraft: 'De conceptkilometerstand kon niet worden opgeslagen. Probeer het opnieuw.',
},
Expand Down
Loading
Loading