Skip to content

Commit 87be80e

Browse files
authored
Merge pull request Expensify#75511 from hoangzinh/74580-show-created-action-for-harvest-expense-report
Show the CREATED report action when the expense report was created during harvest
2 parents a8610b8 + 124ab7b commit 87be80e

26 files changed

Lines changed: 460 additions & 181 deletions

src/components/MoneyRequestReportView/MoneyRequestReportActionsList.tsx

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ import {
5353
shouldReportActionBeVisible,
5454
wasMessageReceivedWhileOffline,
5555
} from '@libs/ReportActionsUtils';
56-
import {canUserPerformWriteAction, chatIncludesChronosWithID, getOriginalReportID, getReportLastVisibleActionCreated, isUnread} from '@libs/ReportUtils';
56+
import {canUserPerformWriteAction, chatIncludesChronosWithID, getOriginalReportID, getReportLastVisibleActionCreated, isHarvestCreatedExpenseReport, isUnread} from '@libs/ReportUtils';
5757
import markOpenReportEnd from '@libs/telemetry/markOpenReportEnd';
5858
import {isTransactionPendingDelete} from '@libs/TransactionUtils';
5959
import Visibility from '@libs/Visibility';
@@ -175,6 +175,8 @@ function MoneyRequestReportActionsList({
175175
const {shouldUseNarrowLayout} = useResponsiveLayout();
176176

177177
const [session] = useOnyx(ONYXKEYS.SESSION, {canBeMissing: false});
178+
const [reportNameValuePairs] = useOnyx(`${ONYXKEYS.COLLECTION.REPORT_NAME_VALUE_PAIRS}${getNonEmptyStringOnyxID(reportID)}`, {canBeMissing: true});
179+
const shouldShowHarvestCreatedAction = isHarvestCreatedExpenseReport(reportNameValuePairs?.origin, reportNameValuePairs?.originalID);
178180
const [offlineModalVisible, setOfflineModalVisible] = useState(false);
179181
const [isDownloadErrorModalVisible, setIsDownloadErrorModalVisible] = useState(false);
180182
const [enableScrollToEnd, setEnableScrollToEnd] = useState<boolean>(false);
@@ -222,7 +224,7 @@ function MoneyRequestReportActionsList({
222224
// We are reversing actions because in this View we are starting at the top and don't use Inverted list
223225
const visibleReportActions = useMemo(() => {
224226
const filteredActions = reportActions.filter((reportAction) => {
225-
const isActionVisibleOnMoneyReport = isActionVisibleOnMoneyRequestReport(reportAction);
227+
const isActionVisibleOnMoneyReport = isActionVisibleOnMoneyRequestReport(reportAction, shouldShowHarvestCreatedAction);
226228

227229
return (
228230
isActionVisibleOnMoneyReport &&
@@ -233,7 +235,7 @@ function MoneyRequestReportActionsList({
233235
});
234236

235237
return filteredActions.toReversed();
236-
}, [reportActions, isOffline, canPerformWriteAction, reportTransactionIDs]);
238+
}, [reportActions, isOffline, canPerformWriteAction, reportTransactionIDs, shouldShowHarvestCreatedAction]);
237239

238240
const reportActionSize = useRef(visibleReportActions.length);
239241
const lastAction = visibleReportActions.at(-1);
@@ -578,6 +580,8 @@ function MoneyRequestReportActionsList({
578580
isReportArchived={isReportArchived}
579581
draftMessage={matchingDraftMessageString}
580582
isTryNewDotNVPDismissed={isTryNewDotNVPDismissed}
583+
reportNameValuePairsOrigin={reportNameValuePairs?.origin}
584+
reportNameValuePairsOriginalID={reportNameValuePairs?.originalID}
581585
/>
582586
);
583587
},
@@ -601,6 +605,8 @@ function MoneyRequestReportActionsList({
601605
draftMessage,
602606
isTryNewDotNVPDismissed,
603607
isReportArchived,
608+
reportNameValuePairs?.origin,
609+
reportNameValuePairs?.originalID,
604610
],
605611
);
606612

src/languages/de.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,7 @@ import type {
121121
FocusModeUpdateParams,
122122
FormattedMaxLengthParams,
123123
GoBackMessageParams,
124+
HarvestCreatedExpenseReportParams,
124125
ImportedTagsMessageParams,
125126
ImportedTypesParams,
126127
ImportFieldParams,
@@ -1017,6 +1018,8 @@ const translations: TranslationDeepObject<typeof en> = {
10171018
adminOnlyCanPost: 'Nur Administratoren können Nachrichten in diesem Raum senden.',
10181019
reportAction: {
10191020
asCopilot: 'als Copilot für',
1021+
harvestCreatedExpenseReport: ({reportUrl, reportName}: HarvestCreatedExpenseReportParams) =>
1022+
`hat diesen Bericht erstellt, um alle Ausgaben aus <a href="${reportUrl}">${reportName}</a> aufzunehmen, die mit der von dir gewählten Frequenz nicht eingereicht werden konnten`,
10201023
},
10211024
mentionSuggestions: {
10221025
hereAlternateText: 'Alle in dieser Unterhaltung benachrichtigen',

src/languages/en.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,7 @@ import type {
109109
FocusModeUpdateParams,
110110
FormattedMaxLengthParams,
111111
GoBackMessageParams,
112+
HarvestCreatedExpenseReportParams,
112113
ImportedTagsMessageParams,
113114
ImportedTypesParams,
114115
ImportFieldParams,
@@ -1001,6 +1002,8 @@ const translations = {
10011002
adminOnlyCanPost: 'Only admins can send messages in this room.',
10021003
reportAction: {
10031004
asCopilot: 'as copilot for',
1005+
harvestCreatedExpenseReport: ({reportUrl, reportName}: HarvestCreatedExpenseReportParams) =>
1006+
`created this report to hold all expenses from <a href="${reportUrl}">${reportName}</a> that couldn't be submitted on your chosen frequency`,
10041007
},
10051008
mentionSuggestions: {
10061009
hereAlternateText: 'Notify everyone in this conversation',

src/languages/es.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import {CONST as COMMON_CONST} from 'expensify-common';
22
import dedent from '@libs/StringUtils/dedent';
33
import CONST from '@src/CONST';
44
import type en from './en';
5-
import type {BeginningOfChatHistoryParams, TagSelectionParams, ViolationsRterParams} from './params';
5+
import type {BeginningOfChatHistoryParams, HarvestCreatedExpenseReportParams, TagSelectionParams, ViolationsRterParams} from './params';
66
import type {TranslationDeepObject} from './types';
77

88
/* eslint-disable max-len */
@@ -636,6 +636,8 @@ const translations: TranslationDeepObject<typeof en> = {
636636
adminOnlyCanPost: 'Solo los administradores pueden enviar mensajes en esta sala.',
637637
reportAction: {
638638
asCopilot: 'como copiloto de',
639+
harvestCreatedExpenseReport: ({reportUrl, reportName}: HarvestCreatedExpenseReportParams) =>
640+
`creó este informe para contener todos los gastos de <a href="${reportUrl}">${reportName}</a> que no se pudieron enviar con la frecuencia que elegiste`,
639641
},
640642
mentionSuggestions: {
641643
hereAlternateText: 'Notificar a todos en esta conversación',

src/languages/fr.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,7 @@ import type {
121121
FocusModeUpdateParams,
122122
FormattedMaxLengthParams,
123123
GoBackMessageParams,
124+
HarvestCreatedExpenseReportParams,
124125
ImportedTagsMessageParams,
125126
ImportedTypesParams,
126127
ImportFieldParams,
@@ -1019,6 +1020,8 @@ const translations: TranslationDeepObject<typeof en> = {
10191020
adminOnlyCanPost: 'Seuls les administrateurs peuvent envoyer des messages dans cette salle.',
10201021
reportAction: {
10211022
asCopilot: 'en tant que copilote pour',
1023+
harvestCreatedExpenseReport: ({reportUrl, reportName}: HarvestCreatedExpenseReportParams) =>
1024+
`a créé ce rapport pour regrouper toutes les dépenses de <a href="${reportUrl}">${reportName}</a> qui n'ont pas pu être soumises selon la fréquence que vous avez choisie`,
10221025
},
10231026
mentionSuggestions: {
10241027
hereAlternateText: 'Notifier tout le monde dans cette conversation',

src/languages/it.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,7 @@ import type {
121121
FocusModeUpdateParams,
122122
FormattedMaxLengthParams,
123123
GoBackMessageParams,
124+
HarvestCreatedExpenseReportParams,
124125
ImportedTagsMessageParams,
125126
ImportedTypesParams,
126127
ImportFieldParams,
@@ -1017,6 +1018,8 @@ const translations: TranslationDeepObject<typeof en> = {
10171018
adminOnlyCanPost: 'Solo gli amministratori possono inviare messaggi in questa stanza.',
10181019
reportAction: {
10191020
asCopilot: 'come copilota per',
1021+
harvestCreatedExpenseReport: ({reportUrl, reportName}: HarvestCreatedExpenseReportParams) =>
1022+
`ha creato questo rapporto per raccogliere tutte le spese di <a href="${reportUrl}">${reportName}</a> che non sono state inviate con la frequenza scelta`,
10201023
},
10211024
mentionSuggestions: {
10221025
hereAlternateText: 'Notifica tutti in questa conversazione',

src/languages/ja.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,7 @@ import type {
121121
FocusModeUpdateParams,
122122
FormattedMaxLengthParams,
123123
GoBackMessageParams,
124+
HarvestCreatedExpenseReportParams,
124125
ImportedTagsMessageParams,
125126
ImportedTypesParams,
126127
ImportFieldParams,
@@ -1016,6 +1017,8 @@ const translations: TranslationDeepObject<typeof en> = {
10161017
adminOnlyCanPost: 'このルームでメッセージを送信できるのは管理者のみです。',
10171018
reportAction: {
10181019
asCopilot: 'のコパイロットとして',
1020+
harvestCreatedExpenseReport: ({reportUrl, reportName}: HarvestCreatedExpenseReportParams) =>
1021+
`選択した頻度では提出できなかった <a href="${reportUrl}">${reportName}</a> のすべての経費をまとめるためにこのレポートを作成しました`,
10191022
},
10201023
mentionSuggestions: {
10211024
hereAlternateText: 'この会話の全員に通知',

src/languages/nl.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,7 @@ import type {
121121
FocusModeUpdateParams,
122122
FormattedMaxLengthParams,
123123
GoBackMessageParams,
124+
HarvestCreatedExpenseReportParams,
124125
ImportedTagsMessageParams,
125126
ImportedTypesParams,
126127
ImportFieldParams,
@@ -1016,6 +1017,8 @@ const translations: TranslationDeepObject<typeof en> = {
10161017
adminOnlyCanPost: 'Alleen beheerders kunnen berichten sturen in deze ruimte.',
10171018
reportAction: {
10181019
asCopilot: 'als copiloot voor',
1020+
harvestCreatedExpenseReport: ({reportUrl, reportName}: HarvestCreatedExpenseReportParams) =>
1021+
`heeft dit rapport aangemaakt om alle uitgaven van <a href="${reportUrl}">${reportName}</a> op te nemen die niet konden worden ingediend met de door jou gekozen frequentie`,
10191022
},
10201023
mentionSuggestions: {
10211024
hereAlternateText: 'Iedereen in dit gesprek op de hoogte stellen',

src/languages/params.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,11 @@ type ReportArchiveReasonsInvoiceReceiverPolicyDeletedParams = {
144144
policyName: string;
145145
};
146146

147+
type HarvestCreatedExpenseReportParams = {
148+
reportUrl: string;
149+
reportName: string;
150+
};
151+
147152
type DuplicateTransactionParams = {
148153
isSubmitted: boolean;
149154
};
@@ -1114,6 +1119,7 @@ export type {
11141119
ReportArchiveReasonsMergedParams,
11151120
ReportPolicyNameParams,
11161121
ReportArchiveReasonsInvoiceReceiverPolicyDeletedParams,
1122+
HarvestCreatedExpenseReportParams,
11171123
ReportArchiveReasonsRemovedFromPolicyParams,
11181124
RequestAmountParams,
11191125
RequestCountParams,

src/languages/pl.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,7 @@ import type {
121121
FocusModeUpdateParams,
122122
FormattedMaxLengthParams,
123123
GoBackMessageParams,
124+
HarvestCreatedExpenseReportParams,
124125
ImportedTagsMessageParams,
125126
ImportedTypesParams,
126127
ImportFieldParams,
@@ -1016,6 +1017,8 @@ const translations: TranslationDeepObject<typeof en> = {
10161017
adminOnlyCanPost: 'Tylko administratorzy mogą wysyłać wiadomości w tym pokoju.',
10171018
reportAction: {
10181019
asCopilot: 'jako kopilot dla',
1020+
harvestCreatedExpenseReport: ({reportUrl, reportName}: HarvestCreatedExpenseReportParams) =>
1021+
`utworzył ten raport, aby zawrzeć wszystkie wydatki z <a href="${reportUrl}">${reportName}</a>, które nie mogły zostać przesłane zgodnie z wybraną przez ciebie częstotliwością`,
10191022
},
10201023
mentionSuggestions: {
10211024
hereAlternateText: 'Powiadom wszystkich w tej konwersacji',

0 commit comments

Comments
 (0)