diff --git a/src/components/Search/SearchRouter/useCreateNavigationSuggestions.ts b/src/components/Search/SearchRouter/useCreateNavigationSuggestions.ts index 4729f516865d..ab89e84d26d7 100644 --- a/src/components/Search/SearchRouter/useCreateNavigationSuggestions.ts +++ b/src/components/Search/SearchRouter/useCreateNavigationSuggestions.ts @@ -98,7 +98,7 @@ function useCreateNavigationMatchTerms() { const {translate} = useLocalize(); return { - createExpense: [translate('iou.createExpense'), translate('iou.addExpense'), translate('homePage.gettingStartedSection.createExpense')], + createExpense: [translate('iou.createExpense'), translate('iou.addExpense'), translate('iou.createAnExpense'), translate('homePage.gettingStartedSection.addFirstReceipt')], createReport: [translate('report.newReport.createReport')], trackDistance: [translate('iou.trackDistance')], chat: [translate('sidebarScreen.fabNewChat'), `${translate('common.new')} ${translate('common.chat')}`], diff --git a/src/languages/de.ts b/src/languages/de.ts index d4075d6bcb6d..1201b9fd63c6 100644 --- a/src/languages/de.ts +++ b/src/languages/de.ts @@ -1158,8 +1158,6 @@ const translations: TranslationDeepObject = { customizeSpendCategoriesSubText: 'Ausgaben organisieren und klassifizieren', customizeExpenseCategories: 'Passen Sie Ihre Ausgabenkategorien an', customizeExpenseCategoriesSubText: 'Fügen Sie die Kategorien Ihres Unternehmens hinzu, um Ihre Ausgaben zu kodieren', - createExpense: 'Ausgabe erstellen', - createExpenseSubText: 'Scannen Sie eine Ausgabe, ziehen Sie sie per Drag & Drop herein oder geben Sie sie manuell über die + Schaltfläche ein', linkPersonalCard: 'Persönliche Karte verknüpfen', linkPersonalCardSubText: 'Spesen automatisch importieren', configureApprovals: 'Genehmigungsworkflow konfigurieren', @@ -1178,6 +1176,8 @@ const translations: TranslationDeepObject = { configureApprovalsSubText: 'Berichtsfreigaben festlegen', setupTravel: 'Reisen einrichten', setupTravelSubText: 'Reisespezifische Regeln konfigurieren', + addFirstReceipt: 'Fügen Sie Ihren ersten Beleg hinzu', + addFirstReceiptSubText: 'Beleg scannen oder manuell eingeben', }, freeTrialSection: { title: ({count}: {count: number}) => ({ @@ -1493,6 +1493,7 @@ const translations: TranslationDeepObject = { removeThisExpense: 'Diesen Beleg entfernen', removeExpenseConfirmation: 'Möchtest du diesen Beleg wirklich entfernen? Diese Aktion kann nicht rückgängig gemacht werden.', addExpense: 'Ausgabe hinzufügen', + createAnExpense: 'Ausgabe erstellen', chooseRecipient: 'Empfänger auswählen', createExpenseWithAmount: ({amount}: {amount: string}) => `${amount}-Ausgabe erstellen`, confirmDetails: 'Details bestätigen', diff --git a/src/languages/el.ts b/src/languages/el.ts index ba409a1044fa..53214860e250 100644 --- a/src/languages/el.ts +++ b/src/languages/el.ts @@ -1230,12 +1230,12 @@ const translations: TranslationDeepObject = { customizeSpendCategoriesSubText: 'Οργανώστε και ταξινομήστε τα έξοδα', customizeExpenseCategories: 'Προσαρμόστε τις κατηγορίες εξόδων σας', customizeExpenseCategoriesSubText: 'Προσθέστε τις κατηγορίες της εταιρείας σας για να κωδικοποιήσετε τα έξοδά σας', - createExpense: 'Δημιουργία δαπάνης', - createExpenseSubText: 'Σαρώστε, σύρετε και αποθέστε ή καταχωρίστε χειροκίνητα μία δαπάνη χρησιμοποιώντας το κουμπί +', linkPersonalCard: 'Συνδέστε προσωπική κάρτα', linkPersonalCardSubText: 'Εισαγάγετε αυτόματα τις δαπάνες', setupTravel: 'Ρύθμιση ταξιδιού', setupTravelSubText: 'Ρύθμιση ειδικών κανόνων για ταξίδια', + addFirstReceipt: 'Προσθέστε την πρώτη σας απόδειξη', + addFirstReceiptSubText: 'Σαρώστε ή καταχωρίστε χειροκίνητα μια απόδειξη', }, upcomingTravel: 'Επερχόμενα ταξίδια', upcomingTravelSection: { @@ -1539,6 +1539,7 @@ const translations: TranslationDeepObject = { removeThisExpense: 'Καταργήστε αυτήν τη δαπάνη', removeExpenseConfirmation: 'Είστε βέβαιοι ότι θέλετε να αφαιρέσετε αυτήν την απόδειξη; Αυτή η ενέργεια δεν μπορεί να αναιρεθεί.', addExpense: 'Προσθέστε δαπάνη', + createAnExpense: 'Δημιουργία δαπάνης', chooseRecipient: 'Επιλέξτε παραλήπτη', createExpenseWithAmount: ({amount}: {amount: string}) => `Δημιουργία εξόδου ${amount}`, confirmDetails: 'Επιβεβαιώστε τα στοιχεία', diff --git a/src/languages/en.ts b/src/languages/en.ts index aee6f5b227fb..e878eb93c7d2 100644 --- a/src/languages/en.ts +++ b/src/languages/en.ts @@ -1330,8 +1330,8 @@ const translations = { customizeSpendCategoriesSubText: 'Organize and classify expenses', customizeExpenseCategories: 'Customize your expense categories', customizeExpenseCategoriesSubText: 'Add your company’s categories to code your expenses', - createExpense: 'Create an expense', - createExpenseSubText: 'Scan, drag and drop, or manually enter an expense using the + button', + addFirstReceipt: 'Add your first receipt', + addFirstReceiptSubText: 'Scan or manually enter a receipt', linkPersonalCard: 'Link personal card', linkPersonalCardSubText: 'Import expenses automatically', setupRulesSubText: 'Require receipts, flag high spend, and more', @@ -1633,6 +1633,7 @@ const translations = { removeThisExpense: 'Remove this expense', removeExpenseConfirmation: 'Are you sure you want to remove this receipt? This action cannot be undone.', addExpense: 'Add expense', + createAnExpense: 'Create an expense', chooseRecipient: 'Choose recipient', createExpenseWithAmount: ({amount}: {amount: string}) => `Create ${amount} expense`, confirmDetails: 'Confirm details', diff --git a/src/languages/es.ts b/src/languages/es.ts index 37fdf70e4c27..3bc282618414 100644 --- a/src/languages/es.ts +++ b/src/languages/es.ts @@ -1160,8 +1160,6 @@ const translations: TranslationDeepObject = { customizeSpendCategoriesSubText: 'Organiza y clasifica gastos', customizeExpenseCategories: 'Personaliza tus categorías de gastos', customizeExpenseCategoriesSubText: 'Añade las categorías de tu empresa para codificar tus gastos', - createExpense: 'Crear un gasto', - createExpenseSubText: 'Escanea, arrastra y suelta o introduce manualmente un gasto usando el botón +', linkPersonalCard: 'Vincular tarjeta personal', linkPersonalCardSubText: 'Importa gastos automáticamente', configureApprovals: 'Configura el flujo de aprobación', @@ -1180,6 +1178,8 @@ const translations: TranslationDeepObject = { configureApprovalsSubText: 'Definir aprobaciones de informes', setupTravel: 'Configurar viajes', setupTravelSubText: 'Configura reglas específicas de viaje', + addFirstReceipt: 'Añade tu primer recibo', + addFirstReceiptSubText: 'Escanear o introducir manualmente un recibo', }, upcomingTravel: 'Próximos viajes', upcomingTravelSection: { @@ -1471,6 +1471,7 @@ const translations: TranslationDeepObject = { splitExpenseDistanceErrorModalDescription: 'Corrige el error de la tarifa de distancia e inténtalo de nuevo.', splitExpensePerDiemRateErrorModalDescription: 'Por favor, corrige el error de la tasa de viáticos y vuelve a intentarlo.', addExpense: 'Agregar gasto', + createAnExpense: 'Crear un gasto', expense: 'Gasto', categorize: 'Categorizar', share: 'Compartir', diff --git a/src/languages/fr.ts b/src/languages/fr.ts index d487a103bad5..601b70fe8db2 100644 --- a/src/languages/fr.ts +++ b/src/languages/fr.ts @@ -1178,8 +1178,6 @@ const translations: TranslationDeepObject = { customizeSpendCategoriesSubText: 'Organiser et classer les dépenses', customizeExpenseCategories: 'Personnalisez vos catégories de dépenses', customizeExpenseCategoriesSubText: 'Ajoutez les catégories de votre entreprise pour coder vos dépenses', - createExpense: 'Créer une dépense', - createExpenseSubText: 'Numérisez, faites glisser-déposer ou saisissez manuellement une dépense à l’aide du bouton +', linkPersonalCard: 'Lier une carte personnelle', linkPersonalCardSubText: 'Importer les dépenses automatiquement', configureApprovals: 'Configurer le flux d’approbation', @@ -1198,6 +1196,8 @@ const translations: TranslationDeepObject = { configureApprovalsSubText: 'Définir les approbations de notes de frais', setupTravel: 'Configurer les déplacements', setupTravelSubText: 'Configurer des règles spécifiques aux déplacements', + addFirstReceipt: 'Ajoutez votre premier reçu', + addFirstReceiptSubText: 'Scanner ou saisir manuellement un reçu', }, yourSpend: { title: 'Vos dépenses', @@ -1501,6 +1501,7 @@ const translations: TranslationDeepObject = { removeThisExpense: 'Supprimer cette dépense', removeExpenseConfirmation: 'Voulez-vous vraiment supprimer ce reçu ? Cette action est irréversible.', addExpense: 'Ajouter une dépense', + createAnExpense: 'Créer une dépense', chooseRecipient: 'Choisir le destinataire', createExpenseWithAmount: ({amount}: {amount: string}) => `Créer une dépense de ${amount}`, confirmDetails: 'Confirmer les détails', diff --git a/src/languages/it.ts b/src/languages/it.ts index 79c3e93cecfa..c01af627ef33 100644 --- a/src/languages/it.ts +++ b/src/languages/it.ts @@ -1177,8 +1177,6 @@ const translations: TranslationDeepObject = { customizeSpendCategoriesSubText: 'Organizza e classifica le spese', customizeExpenseCategories: 'Personalizza le tue categorie di spesa', customizeExpenseCategoriesSubText: 'Aggiungi le categorie della tua azienda per codificare le tue spese', - createExpense: 'Crea una spesa', - createExpenseSubText: 'Scansiona, trascina e rilascia oppure inserisci manualmente una spesa usando il pulsante +', linkPersonalCard: 'Collega carta personale', linkPersonalCardSubText: 'Importa le spese automaticamente', configureApprovals: 'Configura il flusso di approvazione', @@ -1197,6 +1195,8 @@ const translations: TranslationDeepObject = { configureApprovalsSubText: 'Definisci le approvazioni dei report', setupTravel: 'Configura viaggi', setupTravelSubText: 'Configura regole specifiche per i viaggi', + addFirstReceipt: 'Aggiungi la tua prima ricevuta', + addFirstReceiptSubText: 'Scansiona o inserisci manualmente una ricevuta', }, yourSpend: { title: 'Le tue spese', @@ -1492,6 +1492,7 @@ const translations: TranslationDeepObject = { removeThisExpense: 'Rimuovi questa spesa', removeExpenseConfirmation: 'Sei sicuro di voler rimuovere questa ricevuta? Questa azione non può essere annullata.', addExpense: 'Aggiungi spesa', + createAnExpense: 'Crea una spesa', chooseRecipient: 'Scegli destinatario', createExpenseWithAmount: ({amount}: {amount: string}) => `Crea spesa da ${amount}`, confirmDetails: 'Conferma i dettagli', diff --git a/src/languages/ja.ts b/src/languages/ja.ts index 2eaad98ef385..20287ae5daa5 100644 --- a/src/languages/ja.ts +++ b/src/languages/ja.ts @@ -1162,8 +1162,6 @@ const translations: TranslationDeepObject = { customizeSpendCategoriesSubText: '経費を整理して分類する', customizeExpenseCategories: '経費カテゴリをカスタマイズ', customizeExpenseCategoriesSubText: '会社のカテゴリを追加して経費を分類しましょう', - createExpense: '経費を作成', - createExpenseSubText: 'スキャンするか、ドラッグ&ドロップするか、または+ボタンから手入力して経費を追加します', linkPersonalCard: '個人カードをリンクする', linkPersonalCardSubText: '経費を自動的にインポートします', configureApprovals: '承認ワークフローを設定', @@ -1182,6 +1180,8 @@ const translations: TranslationDeepObject = { configureApprovalsSubText: 'レポート承認を定義する', setupTravel: '出張を設定', setupTravelSubText: '出張用のルールを設定する', + addFirstReceipt: '最初のレシートを追加する', + addFirstReceiptSubText: 'レシートをスキャンするか手入力します', }, yourSpend: { title: 'あなたの支出', @@ -1475,6 +1475,7 @@ const translations: TranslationDeepObject = { removeThisExpense: 'この経費を削除', removeExpenseConfirmation: 'この領収書を削除してもよろしいですか?この操作は元に戻せません。', addExpense: '経費を追加', + createAnExpense: '経費を作成', chooseRecipient: '送金先を選択', createExpenseWithAmount: ({amount}: {amount: string}) => `${amount} の経費を作成`, confirmDetails: '詳細を確認', diff --git a/src/languages/nl.ts b/src/languages/nl.ts index fc4e7c401466..f67bbab12395 100644 --- a/src/languages/nl.ts +++ b/src/languages/nl.ts @@ -1173,8 +1173,6 @@ const translations: TranslationDeepObject = { customizeSpendCategoriesSubText: 'Orden en classificeer uitgaven', customizeExpenseCategories: 'Pas je uitgavencategorieën aan', customizeExpenseCategoriesSubText: 'Voeg de categorieën van je bedrijf toe om je uitgaven te coderen', - createExpense: 'Maak een uitgave', - createExpenseSubText: 'Scan, sleep neer en zet neer, of voer handmatig een uitgave in met de +-knop', linkPersonalCard: 'Koppel persoonlijke kaart', linkPersonalCardSubText: 'Importeer uitgaven automatisch', configureApprovals: 'Goedkeuringsworkflow instellen', @@ -1193,6 +1191,8 @@ const translations: TranslationDeepObject = { configureApprovalsSubText: 'Definieer rapportgoedkeuringen', setupTravel: 'Reizen instellen', setupTravelSubText: 'Reisspecifieke regels instellen', + addFirstReceipt: 'Voeg je eerste bon toe', + addFirstReceiptSubText: 'Scan of voer handmatig een bon in', }, yourSpend: { title: 'Je uitgaven', @@ -1490,6 +1490,7 @@ const translations: TranslationDeepObject = { removeThisExpense: 'Deze uitgave verwijderen', removeExpenseConfirmation: 'Weet je zeker dat je deze bon wilt verwijderen? Deze actie kan niet ongedaan worden gemaakt.', addExpense: 'Uitgave toevoegen', + createAnExpense: 'Maak een uitgave', chooseRecipient: 'Kies ontvanger', createExpenseWithAmount: ({amount}: {amount: string}) => `${amount}-uitgave maken`, confirmDetails: 'Bevestig details', diff --git a/src/languages/pl.ts b/src/languages/pl.ts index df6e36b53e19..1b3642a0ad25 100644 --- a/src/languages/pl.ts +++ b/src/languages/pl.ts @@ -1200,8 +1200,6 @@ const translations: TranslationDeepObject = { customizeSpendCategoriesSubText: 'Porządkuj i klasyfikuj wydatki', customizeExpenseCategories: 'Dostosuj swoje kategorie wydatków', customizeExpenseCategoriesSubText: 'Dodaj kategorie swojej firmy, aby kodować wydatki', - createExpense: 'Dodaj wydatek', - createExpenseSubText: 'Zeskanuj, przeciągnij i upuść lub ręcznie wprowadź wydatek za pomocą przycisku +', linkPersonalCard: 'Połącz kartę osobistą', linkPersonalCardSubText: 'Automatycznie importuj wydatki', configureApprovals: 'Skonfiguruj przepływ akceptacji', @@ -1220,6 +1218,8 @@ const translations: TranslationDeepObject = { configureApprovalsSubText: 'Zdefiniuj zatwierdzanie raportów', setupTravel: 'Skonfiguruj podróże', setupTravelSubText: 'Skonfiguruj zasady dotyczące podróży', + addFirstReceipt: 'Dodaj swój pierwszy paragon', + addFirstReceiptSubText: 'Zeskanuj lub wprowadź paragon ręcznie', }, yourSpend: { title: 'Twoje wydatki', @@ -1530,6 +1530,7 @@ const translations: TranslationDeepObject = { removeThisExpense: 'Usuń ten wydatek', removeExpenseConfirmation: 'Czy na pewno chcesz usunąć ten paragon? Tej operacji nie można cofnąć.', addExpense: 'Dodaj wydatek', + createAnExpense: 'Dodaj wydatek', chooseRecipient: 'Wybierz odbiorcę', createExpenseWithAmount: ({amount}: {amount: string}) => `Utwórz wydatek ${amount}`, confirmDetails: 'Potwierdź szczegóły', diff --git a/src/languages/pt-BR.ts b/src/languages/pt-BR.ts index eb282b53d640..333d1ccc9ade 100644 --- a/src/languages/pt-BR.ts +++ b/src/languages/pt-BR.ts @@ -1176,8 +1176,6 @@ const translations: TranslationDeepObject = { customizeSpendCategoriesSubText: 'Organize e classifique despesas', customizeExpenseCategories: 'Personalize suas categorias de despesas', customizeExpenseCategoriesSubText: 'Adicione as categorias da sua empresa para codificar suas despesas', - createExpense: 'Criar uma despesa', - createExpenseSubText: 'Escaneie, arraste e solte ou insira manualmente uma despesa usando o botão +', linkPersonalCard: 'Vincular cartão pessoal', linkPersonalCardSubText: 'Importar despesas automaticamente', configureApprovals: 'Configurar fluxo de aprovação', @@ -1196,6 +1194,8 @@ const translations: TranslationDeepObject = { configureApprovalsSubText: 'Definir aprovações de relatórios', setupTravel: 'Configurar viagem', setupTravelSubText: 'Configurar regras específicas de viagem', + addFirstReceipt: 'Adicione seu primeiro recibo', + addFirstReceiptSubText: 'Escaneie ou insira manualmente um recibo', }, yourSpend: { title: 'Seus gastos', @@ -1492,6 +1492,7 @@ const translations: TranslationDeepObject = { removeThisExpense: 'Remover esta despesa', removeExpenseConfirmation: 'Tem certeza de que deseja remover este recibo? Esta ação não poderá ser desfeita.', addExpense: 'Adicionar despesa', + createAnExpense: 'Criar uma despesa', chooseRecipient: 'Escolher destinatário', createExpenseWithAmount: ({amount}: {amount: string}) => `Criar despesa de ${amount}`, confirmDetails: 'Confirmar detalhes', diff --git a/src/languages/zh-hans.ts b/src/languages/zh-hans.ts index 981594baab8d..14ca8c884a97 100644 --- a/src/languages/zh-hans.ts +++ b/src/languages/zh-hans.ts @@ -1136,8 +1136,6 @@ const translations: TranslationDeepObject = { customizeSpendCategoriesSubText: '整理并分类支出', customizeExpenseCategories: '自定义您的支出类别', customizeExpenseCategoriesSubText: '添加贵公司的类别以对支出进行编码', - createExpense: '创建报销费用', - createExpenseSubText: '使用 + 按钮扫描、拖放或手动输入支出', linkPersonalCard: '关联个人银行卡', linkPersonalCardSubText: '自动导入支出', configureApprovals: '配置审批流程', @@ -1156,6 +1154,8 @@ const translations: TranslationDeepObject = { configureApprovalsSubText: '定义报表审批', setupTravel: '设置差旅', setupTravelSubText: '配置差旅专用规则', + addFirstReceipt: '添加您的第一张票据', + addFirstReceiptSubText: '扫描或手动输入收据', }, yourSpend: {title: '您的支出', awaitingApproval: '等待审批', repaidLast30Days: '过去30天已偿还'}, seeMore: ({count}: {count: number}) => `再查看 ${count} 个`, @@ -1432,6 +1432,7 @@ const translations: TranslationDeepObject = { removeThisExpense: '移除此报销费用', removeExpenseConfirmation: '是否确定要删除此收据?此操作无法撤销。', addExpense: '添加报销', + createAnExpense: '创建报销费用', chooseRecipient: '选择收款人', createExpenseWithAmount: ({amount}: {amount: string}) => `创建 ${amount} 笔报销`, confirmDetails: '确认详情', diff --git a/src/pages/home/GettingStartedSection/GettingStartedRow.tsx b/src/pages/home/GettingStartedSection/GettingStartedRow.tsx index d5be0491a4c2..e47a38c4c612 100644 --- a/src/pages/home/GettingStartedSection/GettingStartedRow.tsx +++ b/src/pages/home/GettingStartedSection/GettingStartedRow.tsx @@ -26,7 +26,8 @@ const SENTRY_LABELS: Record Object.values(transactions ?? {}).some((transaction) => !!transaction && !isDeletedTransaction(transaction) && !isTransactionPendingDelete(transaction)), + const [liveExpenseReportIDs] = useOnyx(ONYXKEYS.COLLECTION.TRANSACTION, { + selector: (transactions) => { + const reportIDs = new Set(); + for (const transaction of Object.values(transactions ?? {})) { + if (transaction?.reportID && !isDeletedTransaction(transaction) && !isTransactionPendingDelete(transaction)) { + reportIDs.add(transaction.reportID); + } + } + return [...reportIDs]; + }, + }); + // Approvers and payers also hold other people's expenses locally, so only expenses on the user's own reports count. + const [hasCreatedExpense = false] = useOnyx(ONYXKEYS.COLLECTION.REPORT, { + selector: (reports) => + !!liveExpenseReportIDs?.some((reportID) => { + if (reportID === CONST.REPORT.UNREPORTED_REPORT_ID) { + return true; + } + const report = reports?.[`${ONYXKEYS.COLLECTION.REPORT}${reportID}`]; + return isReportOwner(report, currentUserAccountID) && (isMoneyRequestReport(report) || isSelfDM(report)); + }), }); const [draftTransactionIDs] = useOnyx(ONYXKEYS.COLLECTION.TRANSACTION_DRAFT, {selector: validTransactionDraftIDsSelector}); const personalCards = useBankLinkedPersonalCards(); @@ -116,6 +135,15 @@ function useGettingStartedItems(): UseGettingStartedItemsResult { const emptyResult: UseGettingStartedItemsResult = {shouldShowSection: false, items: []}; + // Completes on any expense the user has, so expenses created before this step existed also count. + const addFirstReceiptItem: GettingStartedItem = { + key: 'addFirstReceipt', + label: translate('homePage.gettingStartedSection.addFirstReceipt'), + subText: translate('homePage.gettingStartedSection.addFirstReceiptSubText'), + isComplete: hasCreatedExpense, + onPress: () => startMoneyRequest(CONST.IOU.TYPE.CREATE, generateReportID(), draftTransactionIDs, CONST.IOU.REQUEST_TYPE.SCAN), + }; + // Hide the whole section as soon as every onboarding to-do is complete, instead of keeping it // around for the full Getting Started window. const buildResult = (builtItems: GettingStartedItem[]): UseGettingStartedItemsResult => { @@ -183,7 +211,7 @@ function useGettingStartedItems(): UseGettingStartedItemsResult { return emptyResult; } - // The Submit intent has exactly two to-dos and no "Create a workspace" step, because the workspace already exists here. + // The Submit intent has no "Create a workspace" step, because the workspace already exists here. if (isSubmitIntent) { const submitItems: GettingStartedItem[] = []; @@ -199,6 +227,8 @@ function useGettingStartedItems(): UseGettingStartedItemsResult { }); } + submitItems.push(addFirstReceiptItem); + submitItems.push({ key: 'linkPersonalCard', label: translate('homePage.gettingStartedSection.linkPersonalCard'), @@ -234,13 +264,7 @@ function useGettingStartedItems(): UseGettingStartedItemsResult { }); } - items.push({ - key: 'createExpense', - label: translate('homePage.gettingStartedSection.createExpense'), - subText: translate('homePage.gettingStartedSection.createExpenseSubText'), - isComplete: hasCreatedExpense, - onPress: () => startMoneyRequest(CONST.IOU.TYPE.CREATE, generateReportID(), draftTransactionIDs), - }); + items.push(addFirstReceiptItem); items.push({ key: 'linkPersonalCard', @@ -264,6 +288,8 @@ function useGettingStartedItems(): UseGettingStartedItemsResult { }); } + items.push(addFirstReceiptItem); + if (policy.areCompanyCardsEnabled) { items.push({ key: 'linkCompanyCards', diff --git a/tests/unit/hooks/useGettingStartedItems.test.ts b/tests/unit/hooks/useGettingStartedItems.test.ts index eb821235a3ea..ba8c7bbe9a2d 100644 --- a/tests/unit/hooks/useGettingStartedItems.test.ts +++ b/tests/unit/hooks/useGettingStartedItems.test.ts @@ -68,6 +68,12 @@ function buildPolicy(overrides: Partial = {}): Policy { }; } +async function addOwnExpense() { + await Onyx.merge(ONYXKEYS.SESSION, {accountID: CURRENT_USER_ACCOUNT_ID}); + await Onyx.merge(`${ONYXKEYS.COLLECTION.REPORT}r1`, {reportID: 'r1', type: CONST.REPORT.TYPE.EXPENSE, ownerAccountID: CURRENT_USER_ACCOUNT_ID}); + await Onyx.merge(`${ONYXKEYS.COLLECTION.TRANSACTION}1`, {transactionID: '1', reportID: 'r1'}); +} + async function setupTrackWorkspaceScenario(overrides: {policy?: Partial; firstDayTrial?: string; lastDayTrial?: string; intentSource?: 'introSelected' | 'onboardingPurpose'} = {}) { // New workspaces enable Categories by default, so keep the categories step visible unless a test opts out. const policy = buildPolicy({areCategoriesEnabled: true, ...overrides.policy}); @@ -1426,13 +1432,60 @@ describe('useGettingStartedItems', () => { }); describe('items and check states', () => { - it('should return exactly three items in order: createWorkspace, customizeCategories, inviteAccountant', async () => { + it('should return exactly four items in order: createWorkspace, customizeCategories, addFirstReceipt, inviteAccountant', async () => { await setupTrackWorkspaceScenario(); const {result} = renderHook(() => useGettingStartedItems()); const keys = result.current.items.map((item) => item.key); - expect(keys).toEqual(['createWorkspace', 'customizeCategories', 'inviteAccountant']); + expect(keys).toEqual(['createWorkspace', 'customizeCategories', 'addFirstReceipt', 'inviteAccountant']); + }); + + it('should mark addFirstReceipt complete once a non-deleted expense exists', async () => { + // Given a Track workspace admin with no expenses yet + await setupTrackWorkspaceScenario(); + + // When the hook builds the items + const {result: emptyResult} = renderHook(() => useGettingStartedItems()); + + // Then the step is incomplete + expect(emptyResult.current.items.find((item) => item.key === 'addFirstReceipt')?.isComplete).toBe(false); + + // When the user creates an expense anywhere in the product + await addOwnExpense(); + await waitForBatchedUpdates(); + + // Then the step is marked complete + const {result: withExpense} = renderHook(() => useGettingStartedItems()); + expect(withExpense.current.items.find((item) => item.key === 'addFirstReceipt')?.isComplete).toBe(true); + }); + + it('should not mark addFirstReceipt complete for an expense on a report the user does not own', async () => { + // Given a Track workspace admin who has opened an expense report submitted by another member + await setupTrackWorkspaceScenario(); + await Onyx.merge(ONYXKEYS.SESSION, {accountID: CURRENT_USER_ACCOUNT_ID}); + await Onyx.merge(`${ONYXKEYS.COLLECTION.REPORT}r2`, {reportID: 'r2', type: CONST.REPORT.TYPE.EXPENSE, ownerAccountID: CURRENT_USER_ACCOUNT_ID + 1}); + await Onyx.merge(`${ONYXKEYS.COLLECTION.TRANSACTION}2`, {transactionID: '2', reportID: 'r2'}); + await waitForBatchedUpdates(); + + // When the hook builds the items + const {result} = renderHook(() => useGettingStartedItems()); + + // Then the step stays incomplete, because approving or paying someone else's expense is not adding a receipt + expect(result.current.items.find((item) => item.key === 'addFirstReceipt')?.isComplete).toBe(false); + }); + + it('should mark addFirstReceipt complete for an unreported expense', async () => { + // Given a Track workspace admin with a tracked expense that is not on any report + await setupTrackWorkspaceScenario(); + await Onyx.merge(`${ONYXKEYS.COLLECTION.TRANSACTION}3`, {transactionID: '3', reportID: CONST.REPORT.UNREPORTED_REPORT_ID}); + await waitForBatchedUpdates(); + + // When the hook builds the items + const {result} = renderHook(() => useGettingStartedItems()); + + // Then the step is complete, because only the user can hold an unreported expense + expect(result.current.items.find((item) => item.key === 'addFirstReceipt')?.isComplete).toBe(true); }); it('should keep createWorkspace isComplete=true even when no workspace-related state exists', async () => { @@ -1626,7 +1679,7 @@ describe('useGettingStartedItems', () => { const {result} = renderHook(() => useGettingStartedItems()); const keys = result.current.items.map((item) => item.key); - expect(keys).toEqual(['createWorkspace', 'customizeCategories', 'linkCompanyCards', 'inviteAccountant']); + expect(keys).toEqual(['createWorkspace', 'customizeCategories', 'addFirstReceipt', 'linkCompanyCards', 'inviteAccountant']); }); it('should navigate to the workspace company cards route', async () => { @@ -1671,7 +1724,7 @@ describe('useGettingStartedItems', () => { const {result} = renderHook(() => useGettingStartedItems()); const keys = result.current.items.map((item) => item.key); - expect(keys).toEqual(['createWorkspace', 'customizeCategories', 'linkCompanyCards', 'setupTravel', 'inviteAccountant']); + expect(keys).toEqual(['createWorkspace', 'customizeCategories', 'addFirstReceipt', 'linkCompanyCards', 'setupTravel', 'inviteAccountant']); }); it('should not show setupTravel when travel is not enabled', async () => { @@ -1718,7 +1771,7 @@ describe('useGettingStartedItems', () => { const {result} = renderHook(() => useGettingStartedItems()); const keys = result.current.items.map((item) => item.key); - expect(keys).toEqual(['createWorkspace', 'linkCompanyCards', 'inviteAccountant']); + expect(keys).toEqual(['createWorkspace', 'addFirstReceipt', 'linkCompanyCards', 'inviteAccountant']); }); it('should hide the linkCompanyCards step when Company cards is disabled', async () => { @@ -1727,20 +1780,20 @@ describe('useGettingStartedItems', () => { const {result} = renderHook(() => useGettingStartedItems()); const keys = result.current.items.map((item) => item.key); - expect(keys).toEqual(['createWorkspace', 'customizeCategories', 'inviteAccountant']); + expect(keys).toEqual(['createWorkspace', 'customizeCategories', 'addFirstReceipt', 'inviteAccountant']); }); it('should preserve relative order and only collapse the hidden step when both features toggle', async () => { await setupTrackWorkspaceScenario({policy: {areCategoriesEnabled: false, areCompanyCardsEnabled: false}}); const {result: bothDisabled} = renderHook(() => useGettingStartedItems()); - expect(bothDisabled.current.items.map((item) => item.key)).toEqual(['createWorkspace', 'inviteAccountant']); + expect(bothDisabled.current.items.map((item) => item.key)).toEqual(['createWorkspace', 'addFirstReceipt', 'inviteAccountant']); await Onyx.merge(`${ONYXKEYS.COLLECTION.POLICY}${POLICY_ID}`, {areCategoriesEnabled: true, areCompanyCardsEnabled: true}); await waitForBatchedUpdates(); const {result: bothEnabled} = renderHook(() => useGettingStartedItems()); - expect(bothEnabled.current.items.map((item) => item.key)).toEqual(['createWorkspace', 'customizeCategories', 'linkCompanyCards', 'inviteAccountant']); + expect(bothEnabled.current.items.map((item) => item.key)).toEqual(['createWorkspace', 'customizeCategories', 'addFirstReceipt', 'linkCompanyCards', 'inviteAccountant']); }); }); }); @@ -1816,7 +1869,7 @@ describe('useGettingStartedItems', () => { const {result} = renderHook(() => useGettingStartedItems()); const keys = result.current.items.map((item) => item.key); - expect(keys).toEqual(['createWorkspace', 'customizeSpendCategories', 'createExpense', 'linkPersonalCard']); + expect(keys).toEqual(['createWorkspace', 'customizeSpendCategories', 'addFirstReceipt', 'linkPersonalCard']); }); it('should omit customizeSpendCategories when the Categories feature is disabled', async () => { @@ -1825,7 +1878,7 @@ describe('useGettingStartedItems', () => { const {result} = renderHook(() => useGettingStartedItems()); const keys = result.current.items.map((item) => item.key); - expect(keys).toEqual(['createWorkspace', 'createExpense', 'linkPersonalCard']); + expect(keys).toEqual(['createWorkspace', 'addFirstReceipt', 'linkPersonalCard']); }); it('should resolve customizeSpendCategories to the categories route and mark it enabled', async () => { @@ -1851,38 +1904,38 @@ describe('useGettingStartedItems', () => { expect(customResult.current.items.find((item) => item.key === 'customizeSpendCategories')?.isComplete).toBe(true); }); - it('should give createExpense an onPress (not a route) that starts a create money request', async () => { + it('should give addFirstReceipt an onPress (not a route) that opens the create expense flow on the Scan tab', async () => { startMoneyRequest.mockClear(); await setupTrackPersonalScenario({policy: {areCategoriesEnabled: true}}); const {result} = renderHook(() => useGettingStartedItems()); - const createExpenseItem = result.current.items.find((item) => item.key === 'createExpense'); - expect(createExpenseItem?.route).toBeUndefined(); - createExpenseItem?.onPress?.(); - expect(startMoneyRequest).toHaveBeenCalledWith(CONST.IOU.TYPE.CREATE, expect.any(String), expect.any(Array)); + const addFirstReceiptItem = result.current.items.find((item) => item.key === 'addFirstReceipt'); + expect(addFirstReceiptItem?.route).toBeUndefined(); + addFirstReceiptItem?.onPress?.(); + expect(startMoneyRequest).toHaveBeenCalledWith(CONST.IOU.TYPE.CREATE, expect.any(String), expect.any(Array), CONST.IOU.REQUEST_TYPE.SCAN); }); - it('should mark createExpense incomplete with no transactions and complete once a non-deleted transaction exists', async () => { + it('should mark addFirstReceipt incomplete with no transactions and complete once a non-deleted transaction exists', async () => { await setupTrackPersonalScenario({policy: {areCategoriesEnabled: true}}); const {result: emptyResult} = renderHook(() => useGettingStartedItems()); - expect(emptyResult.current.items.find((item) => item.key === 'createExpense')?.isComplete).toBe(false); + expect(emptyResult.current.items.find((item) => item.key === 'addFirstReceipt')?.isComplete).toBe(false); - await Onyx.merge(`${ONYXKEYS.COLLECTION.TRANSACTION}1`, {transactionID: '1', reportID: 'r1'}); + await addOwnExpense(); await waitForBatchedUpdates(); const {result: withExpense} = renderHook(() => useGettingStartedItems()); - expect(withExpense.current.items.find((item) => item.key === 'createExpense')?.isComplete).toBe(true); + expect(withExpense.current.items.find((item) => item.key === 'addFirstReceipt')?.isComplete).toBe(true); }); - it('should not count a trashed transaction toward createExpense completion', async () => { + it('should not count a trashed transaction toward addFirstReceipt completion', async () => { await Onyx.merge(`${ONYXKEYS.COLLECTION.TRANSACTION}1`, {transactionID: '1', reportID: CONST.REPORT.TRASH_REPORT_ID}); await setupTrackPersonalScenario({policy: {areCategoriesEnabled: true}}); const {result} = renderHook(() => useGettingStartedItems()); - expect(result.current.items.find((item) => item.key === 'createExpense')?.isComplete).toBe(false); + expect(result.current.items.find((item) => item.key === 'addFirstReceipt')?.isComplete).toBe(false); }); it('should resolve linkPersonalCard to the wallet route and reflect linked-card state', async () => { @@ -1903,7 +1956,7 @@ describe('useGettingStartedItems', () => { it('should hide the section once every to-do is complete', async () => { await Onyx.merge(`${ONYXKEYS.COLLECTION.POLICY_CATEGORIES}${POLICY_ID}`, customCategories); - await Onyx.merge(`${ONYXKEYS.COLLECTION.TRANSACTION}1`, {transactionID: '1', reportID: 'r1'}); + await addOwnExpense(); await Onyx.merge(ONYXKEYS.CARD_LIST, {testCard: {cardID: 1}}); await setupTrackPersonalScenario({policy: {areCategoriesEnabled: true}}); @@ -1992,7 +2045,7 @@ describe('useGettingStartedItems', () => { const {result} = renderHook(() => useGettingStartedItems()); expect(result.current.shouldShowSection).toBe(true); - expect(result.current.items.map((item) => item.key)).toEqual(['customizeExpenseCategories', 'linkPersonalCard']); + expect(result.current.items.map((item) => item.key)).toEqual(['customizeExpenseCategories', 'addFirstReceipt', 'linkPersonalCard']); }); it('should be hidden after the 60-day Getting Started window', async () => { @@ -2024,7 +2077,7 @@ describe('useGettingStartedItems', () => { const {result} = renderHook(() => useGettingStartedItems()); expect(result.current.shouldShowSection).toBe(true); - expect(result.current.items.map((item) => item.key)).toEqual(['customizeExpenseCategories', 'linkPersonalCard']); + expect(result.current.items.map((item) => item.key)).toEqual(['customizeExpenseCategories', 'addFirstReceipt', 'linkPersonalCard']); }); it('should ignore a stale free trial start date left over from an earlier paid workspace', async () => { @@ -2060,12 +2113,12 @@ describe('useGettingStartedItems', () => { }); describe('items and check states', () => { - it('should return the two to-dos in order, without a createWorkspace step', async () => { + it('should return the to-dos in order, without a createWorkspace step', async () => { await setupSubmitScenario(); const {result} = renderHook(() => useGettingStartedItems()); - expect(result.current.items.map((item) => item.key)).toEqual(['customizeExpenseCategories', 'linkPersonalCard']); + expect(result.current.items.map((item) => item.key)).toEqual(['customizeExpenseCategories', 'addFirstReceipt', 'linkPersonalCard']); }); it('should omit customizeExpenseCategories when the Categories feature is disabled', async () => { @@ -2073,7 +2126,30 @@ describe('useGettingStartedItems', () => { const {result} = renderHook(() => useGettingStartedItems()); - expect(result.current.items.map((item) => item.key)).toEqual(['linkPersonalCard']); + expect(result.current.items.map((item) => item.key)).toEqual(['addFirstReceipt', 'linkPersonalCard']); + }); + + it('should mark addFirstReceipt complete once an expense exists and open the Scan tab on press', async () => { + // Given a Submit workspace owner with no expenses yet + startMoneyRequest.mockClear(); + await setupSubmitScenario(); + + // When the hook builds the items + const {result: emptyResult} = renderHook(() => useGettingStartedItems()); + const addFirstReceiptItem = emptyResult.current.items.find((item) => item.key === 'addFirstReceipt'); + + // Then the step is incomplete and pressing it starts the create expense flow on the Scan tab + expect(addFirstReceiptItem?.isComplete).toBe(false); + addFirstReceiptItem?.onPress?.(); + expect(startMoneyRequest).toHaveBeenCalledWith(CONST.IOU.TYPE.CREATE, expect.any(String), expect.any(Array), CONST.IOU.REQUEST_TYPE.SCAN); + + // When the user creates an expense anywhere in the product + await addOwnExpense(); + await waitForBatchedUpdates(); + + // Then the step is marked complete + const {result: withExpense} = renderHook(() => useGettingStartedItems()); + expect(withExpense.current.items.find((item) => item.key === 'addFirstReceipt')?.isComplete).toBe(true); }); it('should resolve customizeExpenseCategories to the categories route', async () => { @@ -2115,6 +2191,7 @@ describe('useGettingStartedItems', () => { it('should hide the section once every to-do is complete', async () => { await Onyx.merge(`${ONYXKEYS.COLLECTION.POLICY_CATEGORIES}${POLICY_ID}`, customCategories); + await addOwnExpense(); await Onyx.merge(ONYXKEYS.CARD_LIST, {testCard: {cardID: 1}}); await setupSubmitScenario(); @@ -2184,6 +2261,7 @@ describe('useGettingStartedItems', () => { 'accountant@test.com': {email: 'accountant@test.com', role: CONST.POLICY.ROLE.USER}, }; await Onyx.merge(`${ONYXKEYS.COLLECTION.POLICY_CATEGORIES}${POLICY_ID}`, customCategory); + await addOwnExpense(); await setupTrackWorkspaceScenario({policy: {areCategoriesEnabled: true, employeeList}}); const {result} = renderHook(() => useGettingStartedItems()); diff --git a/tests/unit/useCreateNavigationSuggestionsTest.ts b/tests/unit/useCreateNavigationSuggestionsTest.ts index 62797609acf9..2462a363bd7b 100644 --- a/tests/unit/useCreateNavigationSuggestionsTest.ts +++ b/tests/unit/useCreateNavigationSuggestionsTest.ts @@ -69,11 +69,12 @@ const mockIcons = { NewWorkspace: mockIcon, }; const mockTranslations = new Map([ - ['homePage.gettingStartedSection.createExpense', 'Create an expense'], + ['homePage.gettingStartedSection.addFirstReceipt', 'Add your first receipt'], ['homePage.gettingStartedSection.createWorkspace', 'Create a workspace'], ['common.chat', 'Chat'], ['common.new', 'New'], ['iou.addExpense', 'Add expense'], + ['iou.createAnExpense', 'Create an expense'], ['iou.createExpense', 'Create expense'], ['iou.trackDistance', 'Track distance'], ['onboarding.workspace.createWorkspace', 'Create workspace'], @@ -278,7 +279,7 @@ describe('useCreateNavigationSuggestions', () => { mockShouldShowPolicy.mockReturnValue(false); const {result} = renderHook(() => useCreateNavigationSuggestions()); - expect(result.current.find((item) => item.keyForList === 'create_expense')?.matchTerms).toEqual(['Create expense', 'Add expense', 'Create an expense']); + expect(result.current.find((item) => item.keyForList === 'create_expense')?.matchTerms).toEqual(['Create expense', 'Add expense', 'Create an expense', 'Add your first receipt']); expect(result.current.find((item) => item.keyForList === 'create_chat')).toMatchObject({ text: 'Start chat', matchTerms: ['Start chat', 'New Chat'],