Skip to content

Commit d1a8c21

Browse files
committed
Merge branch 'main' of github.com:callstack-internal/Expensify-App into perf-send-message-phase-3
2 parents 0d953f9 + e4049b7 commit d1a8c21

46 files changed

Lines changed: 2047 additions & 675 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

src/ROUTES.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2751,10 +2751,17 @@ const ROUTES = {
27512751
},
27522752
WORKSPACE_EXPENSIFY_CARD_SELECT_FEED: {
27532753
route: 'workspaces/:policyID/expensify-card/select-feed',
2754-
27552754
// eslint-disable-next-line no-restricted-syntax -- Legacy route generation
27562755
getRoute: (policyID: string, backTo?: string) => getUrlWithBackToParam(`workspaces/${policyID}/expensify-card/select-feed`, backTo),
27572756
},
2757+
WORKSPACE_EXPENSIFY_CARD_ADD_WORK_EMAIL: {
2758+
route: 'workspaces/:policyID/expensify-card/:fundID/work-email',
2759+
getRoute: (policyID: string, fundID: number) => `workspaces/${policyID}/expensify-card/${encodeURIComponent(fundID)}/work-email` as const,
2760+
},
2761+
WORKSPACE_EXPENSIFY_CARD_VERIFY_WORK_EMAIL: {
2762+
route: 'workspaces/:policyID/expensify-card/:fundID/verify-work-email',
2763+
getRoute: (policyID: string, fundID: number) => `workspaces/${policyID}/expensify-card/${encodeURIComponent(fundID)}/verify-work-email` as const,
2764+
},
27582765
WORKSPACE_EXPENSIFY_CARD_SETTINGS_FREQUENCY: {
27592766
route: 'workspaces/:policyID/expensify-card/settings/frequency',
27602767
getRoute: (policyID: string) => `workspaces/${policyID}/expensify-card/settings/frequency` as const,

src/SCREENS.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -699,6 +699,8 @@ const SCREENS = {
699699
EXPENSIFY_CARD_ISSUE_NEW_CONFIRM_MAGIC_CODE: 'Workspace_ExpensifyCard_New_Confirm_Magic_Code',
700700
EXPENSIFY_CARD_NAME: 'Workspace_ExpensifyCard_Name',
701701
EXPENSIFY_CARD_SELECT_FEED: 'Workspace_ExpensifyCard_Select_Feed',
702+
EXPENSIFY_CARD_ADD_WORK_EMAIL: 'Workspace_ExpensifyCard_Add_Work_Email',
703+
EXPENSIFY_CARD_VERIFY_WORK_EMAIL: 'Workspace_ExpensifyCard_Verify_Work_Email',
702704
EXPENSIFY_CARD_LIMIT_TYPE: 'Workspace_ExpensifyCard_LimitType',
703705
EXPENSIFY_CARD_BANK_ACCOUNT: 'Workspace_ExpensifyCard_BankAccount',
704706
EXPENSIFY_CARD_SETTINGS: 'Workspace_ExpensifyCard_Settings',

src/components/MoneyReportHeader.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -705,6 +705,7 @@ function MoneyReportHeaderContent({reportID: reportIDProp, shouldDisplayBackButt
705705
}
706706
approveMoneyRequest({
707707
expenseReport: moneyRequestReport,
708+
expenseReportPolicy: policy,
708709
policy,
709710
currentUserAccountIDParam: accountID,
710711
currentUserEmailParam: email ?? '',
@@ -1917,6 +1918,7 @@ function MoneyReportHeaderContent({reportID: reportIDProp, shouldDisplayBackButt
19171918
event,
19181919
iouPaymentType,
19191920
triggerKYCFlow,
1921+
expenseReportPolicy: policy,
19201922
policy,
19211923
onPress: confirmPayment,
19221924
currentAccountID: accountID,

src/components/MoneyReportHeaderPrimaryAction/useConfirmApproval.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ function useConfirmApproval(reportID: string | undefined, startApprovedAnimation
4343
startApprovedAnimation();
4444
approveMoneyRequest({
4545
expenseReport: moneyRequestReport,
46+
expenseReportPolicy: policy,
4647
policy,
4748
currentUserAccountIDParam: accountID,
4849
currentUserEmailParam: email ?? '',

src/components/MoneyRequestReportView/MoneyRequestReportActionsList.tsx

Lines changed: 71 additions & 399 deletions
Large diffs are not rendered by default.

src/components/MoneyRequestReportView/SelectionToolbar.tsx

Lines changed: 366 additions & 0 deletions
Large diffs are not rendered by default.

src/components/ReportActionItem/MoneyRequestReportPreview/ApproveActionButton.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ function ApproveActionButton({iouReportID, startApprovedAnimation, onHoldMenuOpe
3232
const [activePolicyID] = useOnyx(ONYXKEYS.NVP_ACTIVE_POLICY_ID);
3333
const activePolicy = usePolicy(activePolicyID);
3434
const [iouReport] = useOnyx(`${ONYXKEYS.COLLECTION.REPORT}${iouReportID}`);
35+
const [expenseReportPolicy] = useOnyx(`${ONYXKEYS.COLLECTION.POLICY}${iouReport?.policyID}`);
3536
const [userBillingGracePeriodEnds] = useOnyx(ONYXKEYS.COLLECTION.SHARED_NVP_PRIVATE_USER_BILLING_GRACE_PERIOD_END);
3637
const [iouReportNextStep] = useOnyx(`${ONYXKEYS.COLLECTION.NEXT_STEP}${iouReportID}`);
3738
const [amountOwed] = useOnyx(ONYXKEYS.NVP_PRIVATE_AMOUNT_OWED);
@@ -51,6 +52,7 @@ function ApproveActionButton({iouReportID, startApprovedAnimation, onHoldMenuOpe
5152
} else {
5253
approveMoneyRequest({
5354
expenseReport: iouReport,
55+
expenseReportPolicy,
5456
policy: activePolicy,
5557
currentUserAccountIDParam: currentUserAccountID,
5658
currentUserEmailParam: currentUserEmail,

src/components/ReportActionItem/MoneyRequestReportPreview/PayActionButton.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,7 @@ function PayActionButton({
116116
} else {
117117
approveMoneyRequest({
118118
expenseReport: iouReport,
119+
expenseReportPolicy: policy,
119120
policy: activePolicy,
120121
currentUserAccountIDParam: currentUserAccountID,
121122
currentUserEmailParam: currentUserEmail,

src/components/SettlementButton/index.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,7 @@ function SettlementButton({
106106
const {translate, localeCompare} = useLocalize();
107107
const {isOffline} = useNetwork();
108108
const policy = usePolicy(policyID);
109+
const expenseReportPolicy = usePolicy(iouReport?.policyID);
109110
const {accountID, email} = useCurrentUserPersonalDetails();
110111

111112
// The app would crash due to subscribing to the entire report collection if chatReportID is an empty string. So we should have a fallback ID here.
@@ -498,6 +499,7 @@ function SettlementButton({
498499
} else {
499500
approveMoneyRequest({
500501
expenseReport: iouReport,
502+
expenseReportPolicy,
501503
policy,
502504
currentUserAccountIDParam: accountID,
503505
currentUserEmailParam: email ?? '',

src/hooks/useDefaultFundID.ts

Lines changed: 21 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,12 @@
11
import {useCallback} from 'react';
22
import type {OnyxCollection} from 'react-native-onyx';
3-
import {getCardSettings, getFundIdFromSettingsKey} from '@libs/CardUtils';
3+
import {
4+
getCardSettings,
5+
getFundIdFromSettingsKey,
6+
getLinkedPolicyIDsFromExpensifyCardSettings,
7+
getPreferredPolicyFromExpensifyCardSettings,
8+
isPolicyIDInLinkedExpensifyCardPolicyList,
9+
} from '@libs/CardUtils';
410
import CONST from '@src/CONST';
511
import ONYXKEYS from '@src/ONYXKEYS';
612
import type {ExpensifyCardSettings} from '@src/types/onyx';
@@ -19,12 +25,21 @@ function useDefaultFundID(policyID: string | undefined) {
1925

2026
const getDomainFundID = useCallback(
2127
(cardSettings: OnyxCollection<ExpensifyCardSettings>) => {
22-
const matchingKey = Object.entries(cardSettings ?? {}).find(
23-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
24-
([key, settings]) => settings?.preferredPolicy && settings.preferredPolicy === policyID && !key.includes(workspaceAccountID.toString()),
25-
);
28+
const eligibleEntries = Object.entries(cardSettings ?? {}).filter(([key, settings]) => !!settings && !key.includes(workspaceAccountID.toString()));
2629

27-
return getFundIdFromSettingsKey(matchingKey?.[0] ?? '');
30+
if (policyID) {
31+
const preferredMatch = eligibleEntries.find(([, settings]) => getPreferredPolicyFromExpensifyCardSettings(settings)?.toUpperCase() === policyID.toUpperCase());
32+
if (preferredMatch) {
33+
return getFundIdFromSettingsKey(preferredMatch[0]);
34+
}
35+
36+
const linkedMatch = eligibleEntries.find(([, settings]) => isPolicyIDInLinkedExpensifyCardPolicyList(getLinkedPolicyIDsFromExpensifyCardSettings(settings), policyID));
37+
if (linkedMatch) {
38+
return getFundIdFromSettingsKey(linkedMatch[0]);
39+
}
40+
}
41+
42+
return getFundIdFromSettingsKey('');
2843
},
2944
[policyID, workspaceAccountID],
3045
);

0 commit comments

Comments
 (0)