Skip to content

Commit f9bcf40

Browse files
authored
Merge pull request Expensify#87991 from shubham1206agra/refactor-shouldReportActionBeVisible
Refactor: isolate allReports from shouldReportActionBeVisible function
2 parents f08b45e + c0db579 commit f9bcf40

18 files changed

Lines changed: 82 additions & 126 deletions

File tree

src/components/ReportActionItem/MovedTransactionAction.tsx

Lines changed: 1 addition & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -17,34 +17,20 @@ type MovedTransactionActionProps = {
1717
/** The moved transaction action data */
1818
action: ReportAction<typeof CONST.REPORT.ACTIONS.TYPE.MOVED_TRANSACTION>;
1919

20-
/** The element to render when there is no report that the transaction was moved to or from */
21-
emptyHTML: React.JSX.Element;
22-
2320
/** Original report from which the given reportAction is first created */
2421
originalReport: OnyxEntry<Report>;
2522
};
2623

27-
function MovedTransactionAction({action, emptyHTML, originalReport}: MovedTransactionActionProps) {
24+
function MovedTransactionAction({action, originalReport}: MovedTransactionActionProps) {
2825
const {translate} = useLocalize();
2926
const movedTransactionOriginalMessage = getOriginalMessage(action);
30-
const toReportID = movedTransactionOriginalMessage?.toReportID;
3127
const fromReportID = movedTransactionOriginalMessage?.fromReportID;
3228

33-
const [toReport] = useOnyx(`${ONYXKEYS.COLLECTION.REPORT}${toReportID}`);
3429
const [fromReport] = useOnyx(`${ONYXKEYS.COLLECTION.REPORT}${fromReportID}`);
3530
const [conciergeReportID] = useOnyx(ONYXKEYS.CONCIERGE_REPORT_ID);
3631
const [childReport] = useOnyx(`${ONYXKEYS.COLLECTION.REPORT}${getNonEmptyStringOnyxID(action.childReportID)}`);
3732

3833
const isPendingDelete = fromReport?.pendingFields?.preview === CONST.RED_BRICK_ROAD_PENDING_ACTION.DELETE;
39-
// When the transaction is moved from personal space (unreported), fromReportID will be "0" which doesn't exist in allReports
40-
const hasFromReport = fromReportID === CONST.REPORT.UNREPORTED_REPORT_ID ? true : !!fromReport;
41-
42-
// When expenses are merged multiple times, the previous fromReportID may reference a deleted report,
43-
// making it impossible to retrieve the report name for display
44-
// Ref: https://github.com/Expensify/App/issues/70338
45-
if (!toReport && !hasFromReport) {
46-
return emptyHTML;
47-
}
4834

4935
const message = getMovedTransactionMessage(translate, action, conciergeReportID);
5036

src/languages/de.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1228,9 +1228,12 @@ const translations: TranslationDeepObject<typeof en> = {
12281228
deleteReceipt: 'Beleg löschen',
12291229
findExpense: 'Ausgabe finden',
12301230
deletedTransaction: (amount: string, merchant: string) => `hat eine Ausgabe gelöscht (${amount} für ${merchant})`,
1231-
movedFromReport: (reportName: string) => `hat eine Ausgabe verschoben${reportName ? `von ${reportName}` : ''}`,
1232-
movedTransactionTo: (reportUrl: string, reportName?: string) => `hat diese Ausgabe verschoben${reportName ? `zu <a href="${reportUrl}">${reportName}</a>` : ''}`,
1233-
movedTransactionFrom: (reportUrl: string, reportName?: string) => `hat diese Ausgabe verschoben${reportName ? `von <a href="${reportUrl}">${reportName}</a>` : ''}`,
1231+
movedFromReport: (reportName: string) => `hat eine Ausgabe aus ${reportName} verschoben`,
1232+
movedFromReportNoName: 'hat eine Ausgabe verschoben',
1233+
movedTransactionTo: (reportUrl: string, reportName: string) => `hat diese Ausgabe nach <a href="${reportUrl}">${reportName}</a> verschoben`,
1234+
movedTransactionToAnotherReport: 'hat diese Ausgabe in einen anderen Bericht verschoben',
1235+
movedTransactionFrom: (reportUrl: string, reportName: string) => `hat diese Ausgabe von <a href="${reportUrl}">${reportName}</a> verschoben`,
1236+
movedTransactionFromAnotherReport: 'diese Ausgabe aus einem anderen Bericht verschoben',
12341237
unreportedTransaction: (reportUrl: string) => `hat diese Ausgabe in deinen <a href="${reportUrl}">persönlichen Bereich</a> verschoben`,
12351238
movedAction: (shouldHideMovedReportUrl: boolean, movedReportUrl: string, newParentReportUrl: string, toPolicyName: string) => {
12361239
if (shouldHideMovedReportUrl) {

src/languages/en.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1279,9 +1279,12 @@ const translations = {
12791279
deleteReceipt: 'Delete receipt',
12801280
findExpense: 'Find expense',
12811281
deletedTransaction: (amount: string, merchant: string) => `deleted an expense (${amount} for ${merchant})`,
1282-
movedFromReport: (reportName: string) => `moved an expense${reportName ? ` from ${reportName}` : ''}`,
1283-
movedTransactionTo: (reportUrl: string, reportName?: string) => `moved this expense${reportName ? ` to <a href="${reportUrl}">${reportName}</a>` : ''}`,
1284-
movedTransactionFrom: (reportUrl: string, reportName?: string) => `moved this expense${reportName ? ` from <a href="${reportUrl}">${reportName}</a>` : ''}`,
1282+
movedFromReport: (reportName: string) => `moved an expense from ${reportName}`,
1283+
movedFromReportNoName: 'moved an expense',
1284+
movedTransactionTo: (reportUrl: string, reportName: string) => `moved this expense to <a href="${reportUrl}">${reportName}</a>`,
1285+
movedTransactionToAnotherReport: 'moved this expense to another report',
1286+
movedTransactionFrom: (reportUrl: string, reportName: string) => `moved this expense from <a href="${reportUrl}">${reportName}</a>`,
1287+
movedTransactionFromAnotherReport: 'moved this expense from another report',
12851288
unreportedTransaction: (reportUrl: string) => `moved this expense to your <a href="${reportUrl}">personal space</a>`,
12861289
movedAction: (shouldHideMovedReportUrl: boolean, movedReportUrl: string, newParentReportUrl: string, toPolicyName: string) => {
12871290
if (shouldHideMovedReportUrl) {

src/languages/es.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1194,9 +1194,12 @@ const translations: TranslationDeepObject<typeof en> = {
11941194
routePending: 'Ruta pendiente...',
11951195
findExpense: 'Buscar gasto',
11961196
deletedTransaction: (amount, merchant) => `eliminó un gasto (${amount} para ${merchant})`,
1197-
movedFromReport: (reportName) => `movió un gasto${reportName ? ` desde ${reportName}` : ''}`,
1198-
movedTransactionTo: (reportUrl, reportName) => `movió este gasto${reportName ? ` a <a href="${reportUrl}">${reportName}</a>` : ''}`,
1199-
movedTransactionFrom: (reportUrl, reportName) => `movió este gasto${reportName ? ` desde <a href="${reportUrl}">${reportName}</a>` : ''}`,
1197+
movedFromReport: (reportName) => `movió un gasto desde ${reportName}`,
1198+
movedFromReportNoName: 'movió un gasto',
1199+
movedTransactionTo: (reportUrl, reportName) => `movió este gasto a <a href="${reportUrl}">${reportName}</a>`,
1200+
movedTransactionToAnotherReport: 'movió este gasto a otro informe',
1201+
movedTransactionFrom: (reportUrl, reportName) => `movió este gasto desde <a href="${reportUrl}">${reportName}</a>`,
1202+
movedTransactionFromAnotherReport: 'movió este gasto desde otro informe',
12001203
unreportedTransaction: (reportUrl) => `movió este gasto a tu <a href="${reportUrl}">espacio personal</a>`,
12011204
movedAction: (shouldHideMovedReportUrl, movedReportUrl, newParentReportUrl, toPolicyName) => {
12021205
if (shouldHideMovedReportUrl) {

src/languages/fr.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1232,9 +1232,12 @@ const translations: TranslationDeepObject<typeof en> = {
12321232
deleteReceipt: 'Supprimer le reçu',
12331233
findExpense: 'Trouver une dépense',
12341234
deletedTransaction: (amount: string, merchant: string) => `a supprimé une dépense (${amount} pour ${merchant})`,
1235-
movedFromReport: (reportName: string) => `a déplacé une dépense${reportName ? `de ${reportName}` : ''}`,
1236-
movedTransactionTo: (reportUrl: string, reportName?: string) => `a déplacé cette dépense${reportName ? `vers <a href="${reportUrl}">${reportName}</a>` : ''}`,
1237-
movedTransactionFrom: (reportUrl: string, reportName?: string) => `a déplacé cette dépense${reportName ? `depuis <a href="${reportUrl}">${reportName}</a>` : ''}`,
1235+
movedFromReport: (reportName: string) => `a déplacé une dépense depuis ${reportName}`,
1236+
movedFromReportNoName: 'a déplacé une dépense',
1237+
movedTransactionTo: (reportUrl: string, reportName: string) => `a déplacé cette dépense vers <a href="${reportUrl}">${reportName}</a>`,
1238+
movedTransactionToAnotherReport: 'a déplacé cette dépense vers un autre rapport',
1239+
movedTransactionFrom: (reportUrl: string, reportName: string) => `a déplacé cette dépense depuis <a href="${reportUrl}">${reportName}</a>`,
1240+
movedTransactionFromAnotherReport: 'a déplacé cette dépense depuis un autre rapport',
12381241
unreportedTransaction: (reportUrl: string) => `a déplacé cette dépense vers votre <a href="${reportUrl}">espace personnel</a>`,
12391242
movedAction: (shouldHideMovedReportUrl: boolean, movedReportUrl: string, newParentReportUrl: string, toPolicyName: string) => {
12401243
if (shouldHideMovedReportUrl) {

src/languages/it.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1228,9 +1228,12 @@ const translations: TranslationDeepObject<typeof en> = {
12281228
deleteReceipt: 'Elimina ricevuta',
12291229
findExpense: 'Trova spesa',
12301230
deletedTransaction: (amount: string, merchant: string) => `ha eliminato una spesa (${amount} per ${merchant})`,
1231-
movedFromReport: (reportName: string) => `ha spostato una spesa${reportName ? `da ${reportName}` : ''}`,
1232-
movedTransactionTo: (reportUrl: string, reportName?: string) => `ha spostato questa spesa${reportName ? `a <a href="${reportUrl}">${reportName}</a>` : ''}`,
1233-
movedTransactionFrom: (reportUrl: string, reportName?: string) => `ha spostato questa spesa${reportName ? `da <a href="${reportUrl}">${reportName}</a>` : ''}`,
1231+
movedFromReport: (reportName: string) => `ha spostato una spesa da ${reportName}`,
1232+
movedFromReportNoName: 'ha spostato una spesa',
1233+
movedTransactionTo: (reportUrl: string, reportName: string) => `ha spostato questa spesa su <a href="${reportUrl}">${reportName}</a>`,
1234+
movedTransactionToAnotherReport: 'ha spostato questa spesa in un altro report',
1235+
movedTransactionFrom: (reportUrl: string, reportName: string) => `ha spostato questa spesa da <a href="${reportUrl}">${reportName}</a>`,
1236+
movedTransactionFromAnotherReport: 'ha spostato questa nota spese da un altro report',
12341237
unreportedTransaction: (reportUrl: string) => `ha spostato questa spesa nel tuo <a href="${reportUrl}">spazio personale</a>`,
12351238
movedAction: (shouldHideMovedReportUrl: boolean, movedReportUrl: string, newParentReportUrl: string, toPolicyName: string) => {
12361239
if (shouldHideMovedReportUrl) {

src/languages/ja.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1211,9 +1211,12 @@ const translations: TranslationDeepObject<typeof en> = {
12111211
deleteReceipt: '領収書を削除',
12121212
findExpense: '経費を検索',
12131213
deletedTransaction: (amount: string, merchant: string) => `経費を削除しました(${merchant} に ${amount})`,
1214-
movedFromReport: (reportName: string) => `経費${reportName ? `${reportName} から` : ''}を移動しました`,
1215-
movedTransactionTo: (reportUrl: string, reportName?: string) => `この経費を移動しました${reportName ? `<a href="${reportUrl}">${reportName}</a>へ` : ''}`,
1216-
movedTransactionFrom: (reportUrl: string, reportName?: string) => `この経費を移動しました${reportName ? `<a href="${reportUrl}">${reportName}</a> から` : ''}`,
1214+
movedFromReport: (reportName: string) => `${reportName} から経費を移動しました`,
1215+
movedFromReportNoName: '経費を移動しました',
1216+
movedTransactionTo: (reportUrl: string, reportName: string) => `この経費を<a href="${reportUrl}">${reportName}</a>に移動しました`,
1217+
movedTransactionToAnotherReport: 'この経費を別のレポートに移動しました',
1218+
movedTransactionFrom: (reportUrl: string, reportName: string) => `この経費を<a href="${reportUrl}">${reportName}</a>から移動しました`,
1219+
movedTransactionFromAnotherReport: 'この経費を別のレポートから移動しました',
12171220
unreportedTransaction: (reportUrl: string) => `この経費をあなたの<a href="${reportUrl}">個人スペース</a>に移動しました`,
12181221
movedAction: (shouldHideMovedReportUrl: boolean, movedReportUrl: string, newParentReportUrl: string, toPolicyName: string) => {
12191222
if (shouldHideMovedReportUrl) {

src/languages/nl.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1226,9 +1226,12 @@ const translations: TranslationDeepObject<typeof en> = {
12261226
deleteReceipt: 'Bon verwijderen',
12271227
findExpense: 'Uitgave zoeken',
12281228
deletedTransaction: (amount: string, merchant: string) => `heeft een uitgave verwijderd (${amount} voor ${merchant})`,
1229-
movedFromReport: (reportName: string) => `heeft een uitgave verplaatst${reportName ? `van ${reportName}` : ''}`,
1230-
movedTransactionTo: (reportUrl: string, reportName?: string) => `heeft deze uitgave verplaatst${reportName ? `naar <a href="${reportUrl}">${reportName}</a>` : ''}`,
1231-
movedTransactionFrom: (reportUrl: string, reportName?: string) => `heeft deze uitgave verplaatst${reportName ? `van <a href="${reportUrl}">${reportName}</a>` : ''}`,
1229+
movedFromReport: (reportName: string) => `heeft een uitgave verplaatst uit ${reportName}`,
1230+
movedFromReportNoName: 'heeft een uitgave verplaatst',
1231+
movedTransactionTo: (reportUrl: string, reportName: string) => `heeft deze uitgave verplaatst naar <a href="${reportUrl}">${reportName}</a>`,
1232+
movedTransactionToAnotherReport: 'heeft deze uitgave naar een ander rapport verplaatst',
1233+
movedTransactionFrom: (reportUrl: string, reportName: string) => `heeft deze uitgave verplaatst van <a href="${reportUrl}">${reportName}</a>`,
1234+
movedTransactionFromAnotherReport: 'heeft deze uitgave van een ander rapport verplaatst',
12321235
unreportedTransaction: (reportUrl: string) => `heeft deze uitgave verplaatst naar je <a href="${reportUrl}">persoonlijke ruimte</a>`,
12331236
movedAction: (shouldHideMovedReportUrl: boolean, movedReportUrl: string, newParentReportUrl: string, toPolicyName: string) => {
12341237
if (shouldHideMovedReportUrl) {

src/languages/pl.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1226,9 +1226,12 @@ const translations: TranslationDeepObject<typeof en> = {
12261226
deleteReceipt: 'Usuń paragon',
12271227
findExpense: 'Znajdź wydatek',
12281228
deletedTransaction: (amount: string, merchant: string) => `usunął(-ę) wydatek (${amount} dla ${merchant})`,
1229-
movedFromReport: (reportName: string) => `przeniesiono wydatek${reportName ? `z ${reportName}` : ''}`,
1230-
movedTransactionTo: (reportUrl: string, reportName?: string) => `przeniósł ten wydatek${reportName ? `do <a href="${reportUrl}">${reportName}</a>` : ''}`,
1231-
movedTransactionFrom: (reportUrl: string, reportName?: string) => `przeniósł(-ę) ten wydatek${reportName ? `z <a href="${reportUrl}">${reportName}</a>` : ''}`,
1229+
movedFromReport: (reportName: string) => `przeniesiono wydatek z ${reportName}`,
1230+
movedFromReportNoName: 'przeniesiono wydatek',
1231+
movedTransactionTo: (reportUrl: string, reportName: string) => `przeniósł ten wydatek do <a href="${reportUrl}">${reportName}</a>`,
1232+
movedTransactionToAnotherReport: 'przeniesiono ten wydatek do innego raportu',
1233+
movedTransactionFrom: (reportUrl: string, reportName: string) => `przeniósł ten wydatek z <a href="${reportUrl}">${reportName}</a>`,
1234+
movedTransactionFromAnotherReport: 'przeniesiono ten wydatek z innego raportu',
12321235
unreportedTransaction: (reportUrl: string) => `przeniósł ten wydatek do Twojej <a href="${reportUrl}">przestrzeni osobistej</a>`,
12331236
movedAction: (shouldHideMovedReportUrl: boolean, movedReportUrl: string, newParentReportUrl: string, toPolicyName: string) => {
12341237
if (shouldHideMovedReportUrl) {

src/languages/pt-BR.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1226,9 +1226,12 @@ const translations: TranslationDeepObject<typeof en> = {
12261226
deleteReceipt: 'Excluir recibo',
12271227
findExpense: 'Encontrar despesa',
12281228
deletedTransaction: (amount: string, merchant: string) => `excluiu uma despesa (${amount} em ${merchant})`,
1229-
movedFromReport: (reportName: string) => `moveu uma despesa${reportName ? `de ${reportName}` : ''}`,
1230-
movedTransactionTo: (reportUrl: string, reportName?: string) => `moveu esta despesa${reportName ? `para <a href="${reportUrl}">${reportName}</a>` : ''}`,
1231-
movedTransactionFrom: (reportUrl: string, reportName?: string) => `moveu esta despesa${reportName ? `de <a href="${reportUrl}">${reportName}</a>` : ''}`,
1229+
movedFromReport: (reportName: string) => `moveu uma despesa de ${reportName}`,
1230+
movedFromReportNoName: 'moveu uma despesa',
1231+
movedTransactionTo: (reportUrl: string, reportName: string) => `moveu esta despesa para <a href="${reportUrl}">${reportName}</a>`,
1232+
movedTransactionToAnotherReport: 'moveu esta despesa para outro relatório',
1233+
movedTransactionFrom: (reportUrl: string, reportName: string) => `moveu esta despesa de <a href="${reportUrl}">${reportName}</a>`,
1234+
movedTransactionFromAnotherReport: 'moveu esta despesa de outro relatório',
12321235
unreportedTransaction: (reportUrl: string) => `moveu esta despesa para o seu <a href="${reportUrl}">espaço pessoal</a>`,
12331236
movedAction: (shouldHideMovedReportUrl: boolean, movedReportUrl: string, newParentReportUrl: string, toPolicyName: string) => {
12341237
if (shouldHideMovedReportUrl) {

0 commit comments

Comments
 (0)