Skip to content
Draft
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
11 changes: 8 additions & 3 deletions src/components/HoldMenuSectionList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,18 +17,23 @@ type HoldMenuSection = {
titleTranslationKey: TranslationPaths;
};

function HoldMenuSectionList() {
type HoldMenuSectionListProps = {
/** Whether the expense is from a DM (direct message) report */
isDM?: boolean;
};

function HoldMenuSectionList({isDM}: HoldMenuSectionListProps) {
const {translate} = useLocalize();
const styles = useThemeStyles();
const illustrations = useMemoizedLazyIllustrations(['RealtimeReport', 'Stopwatch']);
const holdMenuSections: HoldMenuSection[] = [
{
icon: illustrations.Stopwatch,
titleTranslationKey: 'iou.holdIsLeftBehind',
titleTranslationKey: isDM ? 'iou.holdIsLeftBehindDM' : 'iou.holdIsLeftBehind',
},
{
icon: illustrations.RealtimeReport,
titleTranslationKey: 'iou.unholdWhenReady',
titleTranslationKey: isDM ? 'iou.unholdWhenReadyDM' : 'iou.unholdWhenReady',
},
];

Expand Down
9 changes: 6 additions & 3 deletions src/components/HoldSubmitterEducationalModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,12 @@ type HoldSubmitterEducationalModalProps = {

/** Method to trigger when pressing confirm button */
onConfirm: () => void;

/** Whether the expense is from a DM (direct message) report */
isDM?: boolean;
};

function HoldSubmitterEducationalModal({onClose, onConfirm}: HoldSubmitterEducationalModalProps) {
function HoldSubmitterEducationalModal({onClose, onConfirm, isDM}: HoldSubmitterEducationalModalProps) {
const {translate} = useLocalize();
const styles = useThemeStyles();
const illustrations = useMemoizedLazyIllustrations(['HoldExpense']);
Expand All @@ -26,7 +29,7 @@ function HoldSubmitterEducationalModal({onClose, onConfirm}: HoldSubmitterEducat
return (
<FeatureTrainingModal
title={translate('iou.holdEducationalTitle')}
description={translate('iou.whatIsHoldExplain')}
description={translate(isDM ? 'iou.whatIsHoldExplainDM' : 'iou.whatIsHoldExplain')}
confirmText={translate('common.buttonConfirm')}
image={illustrations.HoldExpense}
contentFitImage="cover"
Expand All @@ -41,7 +44,7 @@ function HoldSubmitterEducationalModal({onClose, onConfirm}: HoldSubmitterEducat
shouldGoBack={false}
shouldUseScrollView
>
<HoldMenuSectionList />
<HoldMenuSectionList isDM={isDM} />
</FeatureTrainingModal>
);
}
Expand Down
3 changes: 2 additions & 1 deletion src/components/MoneyReportHeaderEducationalModals.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import getNonEmptyStringOnyxID from '@libs/getNonEmptyStringOnyxID';
import {getAllNonDeletedTransactions} from '@libs/MoneyRequestReportUtils';
import Navigation from '@libs/Navigation/Navigation';
import {getFilteredReportActionsForReportView, getOneTransactionThreadReportID, getOriginalMessage, isMoneyRequestAction} from '@libs/ReportActionsUtils';
import {changeMoneyRequestHoldStatus, rejectMoneyRequestReason} from '@libs/ReportUtils';
import {changeMoneyRequestHoldStatus, isDM, rejectMoneyRequestReason} from '@libs/ReportUtils';
import {dismissRejectUseExplanation} from '@userActions/IOU/RejectMoneyRequest';
import CONST from '@src/CONST';
import ONYXKEYS from '@src/ONYXKEYS';
Expand Down Expand Up @@ -112,6 +112,7 @@ function MoneyReportHeaderEducationalModals({reportID, ref}: MoneyReportHeaderEd
<HoldSubmitterEducationalModal
onClose={dismissModalAndUpdateUseHold}
onConfirm={dismissModalAndUpdateUseHold}
isDM={isDM(chatReport)}
/>
)}
</>
Expand Down
8 changes: 5 additions & 3 deletions src/components/MoneyRequestHeaderSecondaryActions.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -300,10 +300,11 @@ function MoneyRequestHeaderSecondaryActions({reportID, onBackButtonPress}: Money
return;
}

const isDismissed = isReportSubmitter ? dismissedHoldUseExplanation : dismissedRejectUseExplanation;
if (isDismissed || isParentChatReportDM) {
const shouldShowHoldEducationalModal = isReportSubmitter || isParentChatReportDM;
const isDismissed = shouldShowHoldEducationalModal ? dismissedHoldUseExplanation : dismissedRejectUseExplanation;
if (isDismissed) {
changeMoneyRequestHoldStatus(parentReportAction, transaction, isOffline);
} else if (isReportSubmitter) {
} else if (shouldShowHoldEducationalModal) {
setIsHoldEducationalModalVisible(true);
} else {
setRejectModalAction(CONST.REPORT.TRANSACTION_SECONDARY_ACTIONS.HOLD);
Expand Down Expand Up @@ -529,6 +530,7 @@ function MoneyRequestHeaderSecondaryActions({reportID, onBackButtonPress}: Money
<HoldSubmitterEducationalModal
onClose={dismissModalAndUpdateUseHold}
onConfirm={dismissModalAndUpdateUseHold}
isDM={isParentChatReportDM}
/>
)}
</>
Expand Down
2 changes: 2 additions & 0 deletions src/components/Search/SearchBulkActionsButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ function SearchBulkActionsButton({queryJSON}: SearchBulkActionsButtonProps) {
isOfflineModalVisible,
isDownloadErrorModalVisible,
isHoldEducationalModalVisible,
areAllTransactionsFromDMReports,
rejectModalAction,
emptyReportsCount,
handleOfflineModalClose,
Expand Down Expand Up @@ -261,6 +262,7 @@ function SearchBulkActionsButton({queryJSON}: SearchBulkActionsButtonProps) {
<HoldSubmitterEducationalModal
onClose={dismissModalAndUpdateUseHold}
onConfirm={dismissModalAndUpdateUseHold}
isDM={areAllTransactionsFromDMReports}
/>
)}
</>
Expand Down
7 changes: 4 additions & 3 deletions src/hooks/useHoldRejectActions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,11 +71,12 @@ function useHoldRejectActions({reportID, onHoldEducationalOpen, onRejectModalOpe
return;
}

const isDismissed = isReportSubmitter ? dismissedHoldUseExplanation : dismissedRejectUseExplanation;
const shouldShowHoldEducationalModal = isReportSubmitter || isChatReportDM;
const isDismissed = shouldShowHoldEducationalModal ? dismissedHoldUseExplanation : dismissedRejectUseExplanation;

if (isDismissed || isChatReportDM) {
if (isDismissed) {
changeMoneyRequestHoldStatus(requestParentReportAction, transaction, isOffline);
} else if (isReportSubmitter) {
} else if (shouldShowHoldEducationalModal) {
onHoldEducationalOpen();
} else {
onRejectModalOpen(CONST.REPORT.TRANSACTION_SECONDARY_ACTIONS.HOLD);
Expand Down
23 changes: 23 additions & 0 deletions src/hooks/useSearchBulkActions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -823,6 +823,28 @@ function useSearchBulkActions({queryJSON}: UseSearchBulkActionsParams) {
);
}, [selectedTransactionReportIDs, currentUserPersonalDetails?.accountID, currentSearchResults?.data]);

const areAllTransactionsFromDMReports = useMemo(() => {
const searchData = currentSearchResults?.data;
const reports: Report[] = searchData
? Object.keys(searchData)
.filter((key) => key.startsWith(ONYXKEYS.COLLECTION.REPORT))
.map((key) => searchData[key as keyof typeof searchData] as Report)
.filter((report): report is Report => report != null && 'reportID' in report)
: [];

return (
selectedTransactionReportIDs.length > 0 &&
selectedTransactionReportIDs.every((id) => {
const iouReport = getReportOrDraftReport(id, reports);
if (!iouReport?.chatReportID) {
return false;
}
const chatReport = allReports?.[`${ONYXKEYS.COLLECTION.REPORT}${iouReport.chatReportID}`];
return isDM(chatReport);
})
);
}, [selectedTransactionReportIDs, currentSearchResults?.data, allReports]);

const duplicateHandlerRef = useRef<() => void>(() => {});
const setDuplicateHandler = useCallback((handler: () => void) => {
duplicateHandlerRef.current = handler;
Expand Down Expand Up @@ -1559,6 +1581,7 @@ function useSearchBulkActions({queryJSON}: UseSearchBulkActionsParams) {
isOfflineModalVisible,
isDownloadErrorModalVisible,
isHoldEducationalModalVisible,
areAllTransactionsFromDMReports,
rejectModalAction,
emptyReportsCount,
handleOfflineModalClose,
Expand Down
3 changes: 3 additions & 0 deletions src/languages/de.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1522,8 +1522,11 @@ const translations: TranslationDeepObject<typeof en> = {
approveOnly: 'Nur genehmigen',
holdEducationalTitle: 'Soll diese Ausgabe zurückgestellt werden?',
whatIsHoldExplain: 'Hold ist wie ein „Pause“-Knopf für eine Ausgabe, bis du bereit bist, sie einzureichen.',
whatIsHoldExplainDM: 'Hold ist wie ein „Pause“-Knopf für eine Ausgabe, bis du bereit bist, sie zu senden.',
holdIsLeftBehind: 'Zurückgehaltene Ausgaben werden ausgelassen, selbst wenn du einen gesamten Bericht einreichst.',
holdIsLeftBehindDM: 'Zurückgehaltene Ausgaben werden erst gesendet, wenn du die Zurückstellung aufhebst.',
unholdWhenReady: 'Gib Ausgaben wieder frei, wenn du bereit bist, sie einzureichen.',
unholdWhenReadyDM: 'Hebe die Zurückstellung auf, wenn du bereit bist, die Ausgaben zu senden.',
changePolicyEducational: {
title: 'Du hast diesen Bericht verschoben!',
description: 'Überprüfe diese Punkte sorgfältig, da sie sich beim Verschieben von Berichten in einen neuen Workspace häufig ändern.',
Expand Down
3 changes: 3 additions & 0 deletions src/languages/en.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1574,8 +1574,11 @@ const translations = {
approveOnly: 'Approve only',
holdEducationalTitle: 'Should you hold this expense?',
whatIsHoldExplain: "Hold is like hitting “pause” on an expense until you're ready to submit it.",
whatIsHoldExplainDM: "Hold is like hitting 'pause' on an expense until you're ready to send it.",
holdIsLeftBehind: 'Held expenses are left behind even if you submit an entire report.',
holdIsLeftBehindDM: "Held expenses won't be sent until you remove the hold.",
unholdWhenReady: "Unhold expenses when you're ready to submit them.",
unholdWhenReadyDM: "Unhold expenses when you're ready to send them.",
changePolicyEducational: {
title: 'You moved this report!',
description: 'Double-check these items, which tend to change when moving reports to a new workspace.',
Expand Down
3 changes: 3 additions & 0 deletions src/languages/es.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1472,8 +1472,11 @@ const translations: TranslationDeepObject<typeof en> = {
unhold: 'Desbloquear',
holdEducationalTitle: '¿Deberías retener este gasto?',
whatIsHoldExplain: 'Retener es como presionar "pausa" en un gasto hasta que estés listo para enviarlo.',
whatIsHoldExplainDM: 'Retener es como presionar "pausa" en un gasto hasta que estés listo para enviarlo.',
holdIsLeftBehind: 'Los gastos retenidos se quedan fuera incluso si envías un informe completo.',
holdIsLeftBehindDM: 'Los gastos retenidos no se enviarán hasta que los desbloquees.',
unholdWhenReady: 'Desbloquea los gastos cuando estés listo para enviarlos.',
unholdWhenReadyDM: 'Desbloquea los gastos cuando estés listo para enviarlos.',
changePolicyEducational: {
title: '¡Has movido este informe!',
description: 'Revisa cuidadosamente estos elementos, que tienden a cambiar al trasladar informes a un nuevo espacio de trabajo.',
Expand Down
3 changes: 3 additions & 0 deletions src/languages/fr.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1525,8 +1525,11 @@ const translations: TranslationDeepObject<typeof en> = {
approveOnly: 'Approuver uniquement',
holdEducationalTitle: 'Devriez-vous conserver cette dépense ?',
whatIsHoldExplain: "La mise en attente revient à mettre une « pause » sur une dépense jusqu'à ce que vous soyez prêt à la soumettre.",
whatIsHoldExplainDM: "La mise en attente revient a mettre une depense en 'pause' jusqu'a ce que vous soyez pret a l'envoyer.",
holdIsLeftBehind: 'Les dépenses retenues sont laissées de côté même si vous soumettez une note de frais entière.',
holdIsLeftBehindDM: 'Les depenses retenues ne seront pas envoyees tant que vous ne retirerez pas la mise en attente.',
unholdWhenReady: 'Retirez les dépenses de la mise en attente lorsque vous êtes prêt à les soumettre.',
unholdWhenReadyDM: 'Retirez la mise en attente des depenses lorsque vous etes pret a les envoyer.',
changePolicyEducational: {
title: 'Vous avez déplacé cette note de frais !',
description: 'Vérifiez attentivement ces éléments, qui ont tendance à changer lorsque vous déplacez des notes de frais vers un nouvel espace de travail.',
Expand Down
3 changes: 3 additions & 0 deletions src/languages/it.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1520,8 +1520,11 @@ const translations: TranslationDeepObject<typeof en> = {
approveOnly: 'Solo approva',
holdEducationalTitle: 'Dovresti tenere in sospeso questa spesa?',
whatIsHoldExplain: 'La funzione “Metti in sospeso” è come premere “pausa” su una spesa finché non sei prontə a inviarla.',
whatIsHoldExplainDM: "La funzione 'Metti in sospeso' e come premere 'pausa' su una spesa finche non sei prontə a inviarla.",
holdIsLeftBehind: 'Le spese in sospeso vengono lasciate indietro anche se invii un intero resoconto.',
holdIsLeftBehindDM: 'Le spese in sospeso non verranno inviate finche non rimuovi la sospensione.',
unholdWhenReady: 'Sblocca le spese quando sei pronto a inviarle.',
unholdWhenReadyDM: 'Rimuovi la sospensione dalle spese quando sei prontə a inviarle.',
changePolicyEducational: {
title: 'Hai spostato questo report!',
description: 'Ricontrolla questi elementi, che tendono a cambiare quando si spostano i report in un nuovo workspace.',
Expand Down
3 changes: 3 additions & 0 deletions src/languages/ja.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1501,8 +1501,11 @@ const translations: TranslationDeepObject<typeof en> = {
approveOnly: '承認のみ',
holdEducationalTitle: 'この経費を保留しますか?',
whatIsHoldExplain: '保留は、提出の準備ができるまで経費を「一時停止」しておくようなものです。',
whatIsHoldExplainDM: '保留は、送信の準備ができるまで経費を「一時停止」しておくようなものです。',
holdIsLeftBehind: '保留中の経費は、レポート全体を提出してもそのまま残ります。',
holdIsLeftBehindDM: '保留中の経費は、保留を解除するまで送信されません。',
unholdWhenReady: '提出の準備ができたら、経費の保留を解除してください。',
unholdWhenReadyDM: '送信の準備ができたら、経費の保留を解除してください。',
changePolicyEducational: {
title: 'このレポートを移動しました!',
description: 'レポートを新しいワークスペースに移動すると変更されやすい、次の項目を再確認してください。',
Expand Down
3 changes: 3 additions & 0 deletions src/languages/nl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1517,8 +1517,11 @@ const translations: TranslationDeepObject<typeof en> = {
approveOnly: 'Alleen goedkeuren',
holdEducationalTitle: 'Moet je deze uitgave aanhouden?',
whatIsHoldExplain: 'Pauzeren is alsof je een uitgave op “pauze” zet totdat je klaar bent om die in te dienen.',
whatIsHoldExplainDM: "Aanhouden is alsof je een uitgave op 'pauze' zet totdat je klaar bent om die te verzenden.",
holdIsLeftBehind: 'Geblokkeerde uitgaven blijven achter, zelfs als je een volledig rapport indient.',
holdIsLeftBehindDM: 'Aangehouden uitgaven worden niet verzonden totdat je de aanhouding opheft.',
unholdWhenReady: 'Haal de blokkering van de uitgaven wanneer je klaar bent om ze in te dienen.',
unholdWhenReadyDM: 'Hef de aanhouding van uitgaven op wanneer je klaar bent om ze te verzenden.',
changePolicyEducational: {
title: 'Je hebt dit rapport verplaatst!',
description: 'Controleer deze onderdelen goed; ze veranderen vaak wanneer rapporten naar een nieuwe workspace worden verplaatst.',
Expand Down
3 changes: 3 additions & 0 deletions src/languages/pl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1515,8 +1515,11 @@ const translations: TranslationDeepObject<typeof en> = {
approveOnly: 'Tylko zaakceptuj',
holdEducationalTitle: 'Czy powinieneś wstrzymać ten wydatek?',
whatIsHoldExplain: 'Wstrzymanie działa jak naciśnięcie „pauzy” na wydatku, dopóki nie będziesz gotowy, aby go przesłać.',
whatIsHoldExplainDM: "Wstrzymanie dziala jak nacisniecie 'pauzy' na wydatku, dopoki nie bedziesz gotowy(-a), aby go wyslac.",
holdIsLeftBehind: 'Wstrzymane wydatki pozostają nieprzetworzone, nawet jeśli prześlesz cały raport.',
holdIsLeftBehindDM: 'Wstrzymane wydatki nie zostana wyslane, dopoki nie zdejmiesz wstrzymania.',
unholdWhenReady: 'Zdejmij wstrzymanie z wydatków, gdy będziesz gotowy(-a) je przesłać.',
unholdWhenReadyDM: 'Zdejmij wstrzymanie z wydatkow, gdy bedziesz gotowy(-a) je wyslac.',
changePolicyEducational: {
title: 'Przeniesiono ten raport!',
description: 'Sprawdź dokładnie te elementy, które zwykle się zmieniają podczas przenoszenia raportów do nowej przestrzeni roboczej.',
Expand Down
3 changes: 3 additions & 0 deletions src/languages/pt-BR.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1514,8 +1514,11 @@ const translations: TranslationDeepObject<typeof en> = {
approveOnly: 'Apenas aprovar',
holdEducationalTitle: 'Você deve reter esta despesa?',
whatIsHoldExplain: 'Reter é como apertar “pausa” em uma despesa até que você esteja pronto para enviá-la.',
whatIsHoldExplainDM: "Reter e como apertar 'pausa' em uma despesa ate que voce esteja pronto para envia-la.",
holdIsLeftBehind: 'Despesas em espera ficam de fora mesmo se você enviar um relatório inteiro.',
holdIsLeftBehindDM: 'Despesas retidas nao serao enviadas ate que voce remova a retencao.',
unholdWhenReady: 'Desbloqueie as despesas quando estiver pronto para enviá-las.',
unholdWhenReadyDM: 'Remova a retencao das despesas quando estiver pronto para envia-las.',
changePolicyEducational: {
title: 'Você moveu este relatório!',
description: 'Confira novamente estes itens, que tendem a mudar ao mover relatórios para um novo workspace.',
Expand Down
3 changes: 3 additions & 0 deletions src/languages/zh-hans.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1473,8 +1473,11 @@ const translations: TranslationDeepObject<typeof en> = {
approveOnly: '仅批准',
holdEducationalTitle: '你要暂时保留这笔报销吗?',
whatIsHoldExplain: '“暂缓”就像对一笔报销按下“暂停键”,直到你准备好提交它。',
whatIsHoldExplainDM: '“暂缓”就像对一笔报销按下“暂停键”,直到你准备好发送它。',
holdIsLeftBehind: '即使您提交整份报表,被暂挂的报销也会被保留在外。',
holdIsLeftBehindDM: '被暂缓的报销在你解除暂缓之前不会被发送。',
unholdWhenReady: '准备报销时,解除报销的暂挂状态。',
unholdWhenReadyDM: '准备发送时,解除报销的暂缓状态。',
changePolicyEducational: {
title: '你已移动此报表!',
description: '请仔细检查这些项目,它们在将报表移动到新工作区时往往会发生变化。',
Expand Down
Loading