Skip to content
Merged
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
5 changes: 4 additions & 1 deletion src/components/MoneyReportHeader.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -336,6 +336,8 @@ function MoneyReportHeader({
const canTriggerAutomaticPDFDownload = useRef(false);
const hasFinishedPDFDownload = reportPDFFilename && reportPDFFilename !== CONST.REPORT_DETAILS_MENU_ITEM.ERROR;

const [quickAction] = useOnyx(ONYXKEYS.NVP_QUICK_ACTION_GLOBAL_CREATE, {canBeMissing: true});

useEffect(() => {
canTriggerAutomaticPDFDownload.current = isPDFModalVisible;
}, [isPDFModalVisible]);
Expand Down Expand Up @@ -595,13 +597,14 @@ function MoneyReportHeader({
optimisticChatReportID,
optimisticIOUReportID,
isASAPSubmitBetaEnabled,
quickAction,
defaultExpensePolicy ?? undefined,
activePolicyCategories,
activePolicyExpenseChat,
);
}
},
[activePolicyExpenseChat, allPolicyCategories, defaultExpensePolicy, isASAPSubmitBetaEnabled],
[activePolicyExpenseChat, allPolicyCategories, defaultExpensePolicy, isASAPSubmitBetaEnabled, quickAction],
);

const getStatusIcon: (src: IconAsset) => React.ReactNode = (src) => (
Expand Down
4 changes: 3 additions & 1 deletion src/components/MoneyRequestHeader.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@
import HoldOrRejectEducationalModal from './HoldOrRejectEducationalModal';
import HoldSubmitterEducationalModal from './HoldSubmitterEducationalModal';
import Icon from './Icon';
import * as Expensicons from './Icon/Expensicons';

Check warning on line 75 in src/components/MoneyRequestHeader.tsx

View workflow job for this annotation

GitHub Actions / Changed files ESLint check

'./Icon/Expensicons' import is restricted from being used by a pattern. Direct imports from Icon/Expensicons are deprecated. Please use lazy loading hooks instead. Use `useMemoizedLazyExpensifyIcons` from @hooks/useLazyAsset. See docs/LAZY_ICONS_AND_ILLUSTRATIONS.md for details
import LoadingBar from './LoadingBar';
import type {MoneyRequestHeaderStatusBarProps} from './MoneyRequestHeaderStatusBar';
import MoneyRequestHeaderStatusBar from './MoneyRequestHeaderStatusBar';
Expand Down Expand Up @@ -160,6 +160,7 @@

const {wideRHPRouteKeys} = useContext(WideRHPContext);
const [network] = useOnyx(ONYXKEYS.NETWORK, {canBeMissing: true});
const [quickAction] = useOnyx(ONYXKEYS.NVP_QUICK_ACTION_GLOBAL_CREATE, {canBeMissing: true});

const markAsCash = useCallback(() => {
markAsCashAction(transaction?.transactionID, reportID);
Expand All @@ -182,13 +183,14 @@
optimisticChatReportID,
optimisticIOUReportID,
isASAPSubmitBetaEnabled,
quickAction,
defaultExpensePolicy ?? undefined,
activePolicyCategories,
activePolicyExpenseChat,
);
}
},
[activePolicyExpenseChat, allPolicyCategories, defaultExpensePolicy, isASAPSubmitBetaEnabled],
[activePolicyExpenseChat, allPolicyCategories, defaultExpensePolicy, isASAPSubmitBetaEnabled, quickAction],
);

const getStatusIcon: (src: IconAsset) => ReactNode = (src) => (
Expand Down
26 changes: 23 additions & 3 deletions src/libs/actions/IOU.ts
Original file line number Diff line number Diff line change
Expand Up @@ -675,6 +675,7 @@
shouldPlaySound?: boolean;
shouldHandleNavigation?: boolean;
isASAPSubmitBetaEnabled: boolean;
quickAction: OnyxEntry<OnyxTypes.QuickAction>;
};

type BuildOnyxDataForInvoiceParams = {
Expand Down Expand Up @@ -739,10 +740,11 @@
transactionParams: GetTrackExpenseInformationTransactionParams;
retryParams?: StartSplitBilActionParams | CreateTrackExpenseParams | RequestMoneyInformation | ReplaceReceipt;
isASAPSubmitBetaEnabled: boolean;
quickAction: OnyxEntry<OnyxTypes.QuickAction>;
};

let allPersonalDetails: OnyxTypes.PersonalDetailsList = {};
Onyx.connect({

Check warning on line 747 in src/libs/actions/IOU.ts

View workflow job for this annotation

GitHub Actions / Changed files ESLint check

Onyx.connect() is deprecated. Use useOnyx() hook instead and pass the data as parameters to a pure function
key: ONYXKEYS.PERSONAL_DETAILS_LIST,
callback: (value) => {
allPersonalDetails = value ?? {};
Expand Down Expand Up @@ -837,7 +839,7 @@
};

let allTransactions: NonNullable<OnyxCollection<OnyxTypes.Transaction>> = {};
Onyx.connect({

Check warning on line 842 in src/libs/actions/IOU.ts

View workflow job for this annotation

GitHub Actions / Changed files ESLint check

Onyx.connect() is deprecated. Use useOnyx() hook instead and pass the data as parameters to a pure function
key: ONYXKEYS.COLLECTION.TRANSACTION,
waitForCollectionCallback: true,
callback: (value) => {
Expand All @@ -851,7 +853,7 @@
});

let allTransactionDrafts: NonNullable<OnyxCollection<OnyxTypes.Transaction>> = {};
Onyx.connect({

Check warning on line 856 in src/libs/actions/IOU.ts

View workflow job for this annotation

GitHub Actions / Changed files ESLint check

Onyx.connect() is deprecated. Use useOnyx() hook instead and pass the data as parameters to a pure function
key: ONYXKEYS.COLLECTION.TRANSACTION_DRAFT,
waitForCollectionCallback: true,
callback: (value) => {
Expand All @@ -860,7 +862,7 @@
});

let allTransactionViolations: NonNullable<OnyxCollection<OnyxTypes.TransactionViolations>> = {};
Onyx.connect({

Check warning on line 865 in src/libs/actions/IOU.ts

View workflow job for this annotation

GitHub Actions / Changed files ESLint check

Onyx.connect() is deprecated. Use useOnyx() hook instead and pass the data as parameters to a pure function
key: ONYXKEYS.COLLECTION.TRANSACTION_VIOLATIONS,
waitForCollectionCallback: true,
callback: (value) => {
Expand All @@ -874,7 +876,7 @@
});

let allNextSteps: NonNullable<OnyxCollection<OnyxTypes.ReportNextStepDeprecated>> = {};
Onyx.connect({

Check warning on line 879 in src/libs/actions/IOU.ts

View workflow job for this annotation

GitHub Actions / Changed files ESLint check

Onyx.connect() is deprecated. Use useOnyx() hook instead and pass the data as parameters to a pure function
key: ONYXKEYS.COLLECTION.NEXT_STEP,
waitForCollectionCallback: true,
callback: (value) => {
Expand All @@ -886,14 +888,14 @@
// `allRecentlyUsedTags` was moved here temporarily from `src/libs/actions/Policy/Tag.ts` during the `Deprecate Onyx.connect` refactor.
// All uses of this variable should be replaced with `useOnyx`.
let allRecentlyUsedTags: OnyxCollection<RecentlyUsedTags> = {};
Onyx.connect({

Check warning on line 891 in src/libs/actions/IOU.ts

View workflow job for this annotation

GitHub Actions / Changed files ESLint check

Onyx.connect() is deprecated. Use useOnyx() hook instead and pass the data as parameters to a pure function
key: ONYXKEYS.COLLECTION.POLICY_RECENTLY_USED_TAGS,
waitForCollectionCallback: true,
callback: (val) => (allRecentlyUsedTags = val),
});

let allReports: OnyxCollection<OnyxTypes.Report>;
Onyx.connect({

Check warning on line 898 in src/libs/actions/IOU.ts

View workflow job for this annotation

GitHub Actions / Changed files ESLint check

Onyx.connect() is deprecated. Use useOnyx() hook instead and pass the data as parameters to a pure function
key: ONYXKEYS.COLLECTION.REPORT,
waitForCollectionCallback: true,
callback: (value) => {
Expand All @@ -902,7 +904,7 @@
});

let allReportNameValuePairs: OnyxCollection<OnyxTypes.ReportNameValuePairs>;
Onyx.connect({

Check warning on line 907 in src/libs/actions/IOU.ts

View workflow job for this annotation

GitHub Actions / Changed files ESLint check

Onyx.connect() is deprecated. Use useOnyx() hook instead and pass the data as parameters to a pure function
key: ONYXKEYS.COLLECTION.REPORT_NAME_VALUE_PAIRS,
waitForCollectionCallback: true,
callback: (value) => {
Expand All @@ -912,7 +914,7 @@

let userAccountID = -1;
let currentUserEmail = '';
Onyx.connect({

Check warning on line 917 in src/libs/actions/IOU.ts

View workflow job for this annotation

GitHub Actions / Changed files ESLint check

Onyx.connect() is deprecated. Use useOnyx() hook instead and pass the data as parameters to a pure function
key: ONYXKEYS.SESSION,
callback: (value) => {
currentUserEmail = value?.email ?? '';
Expand Down Expand Up @@ -2606,6 +2608,7 @@
retryParams?: StartSplitBilActionParams | CreateTrackExpenseParams | RequestMoneyInformation | ReplaceReceipt;
participant?: Participant;
isASAPSubmitBetaEnabled: boolean;
quickAction: OnyxEntry<OnyxTypes.QuickAction>;
};

/** Builds the Onyx data for track expense */
Expand All @@ -2620,6 +2623,7 @@
retryParams,
participant,
isASAPSubmitBetaEnabled,
quickAction,
}: BuildOnyxDataForTrackExpenseParams): [OnyxUpdate[], OnyxUpdate[], OnyxUpdate[]] {
const {report: chatReport, previewAction: reportPreviewAction} = chat;
const {report: iouReport, createdAction: iouCreatedAction, action: iouAction} = iou;
Expand Down Expand Up @@ -2664,7 +2668,7 @@
value: {
action: newQuickAction,
chatReportID: chatReport.reportID,
isFirstQuickAction: isEmptyObject(deprecatedQuickAction),
isFirstQuickAction: isEmptyObject(quickAction),
},
},
);
Expand Down Expand Up @@ -2893,7 +2897,7 @@
failureData.push({
onyxMethod: Onyx.METHOD.SET,
key: ONYXKEYS.NVP_QUICK_ACTION_GLOBAL_CREATE,
value: deprecatedQuickAction ?? null,
value: quickAction ?? null,
});

if (iouReport) {
Expand Down Expand Up @@ -4049,7 +4053,17 @@
* it creates optimistic versions of them and uses those instead
*/
function getTrackExpenseInformation(params: GetTrackExpenseInformationParams): TrackExpenseInformation | null {
const {parentChatReport, moneyRequestReportID = '', existingTransactionID, participantParams, policyParams, transactionParams, retryParams, isASAPSubmitBetaEnabled} = params;
const {
parentChatReport,
moneyRequestReportID = '',
existingTransactionID,
participantParams,
policyParams,
transactionParams,
retryParams,
isASAPSubmitBetaEnabled,
quickAction,
} = params;
const {payeeAccountID = userAccountID, payeeEmail = currentUserEmail, participant} = participantParams;
const {policy, policyCategories, policyTagList} = policyParams;
const {comment, amount, currency, created, distance, merchant, receipt, category, tag, taxCode, taxAmount, billable, reimbursable, linkedTrackedExpenseReportAction, attendees} =
Expand Down Expand Up @@ -4299,6 +4313,7 @@
actionableTrackExpenseWhisper,
retryParams,
isASAPSubmitBetaEnabled,
quickAction,
});

return {
Expand Down Expand Up @@ -6589,6 +6604,7 @@
shouldHandleNavigation = true,
shouldPlaySound = true,
isASAPSubmitBetaEnabled,
quickAction,
} = params;
const {participant, payeeAccountID, payeeEmail} = participantParams;
const {policy, policyCategories, policyTagList} = policyData;
Expand Down Expand Up @@ -6656,6 +6672,7 @@
linkedTrackedExpenseReportID,
customUnitRateID,
},
quickAction,
};

const {
Expand Down Expand Up @@ -6710,6 +6727,7 @@
},
retryParams,
isASAPSubmitBetaEnabled,
quickAction,
}) ?? {};
const activeReportID = isMoneyRequestReport ? report?.reportID : chatReport?.reportID;

Expand Down Expand Up @@ -6895,6 +6913,7 @@
optimisticChatReportID: string,
optimisticIOUReportID: string,
isASAPSubmitBetaEnabled: boolean,
quickAction: OnyxEntry<OnyxTypes.QuickAction>,
targetPolicy?: OnyxEntry<OnyxTypes.Policy>,
targetPolicyCategories?: OnyxEntry<OnyxTypes.PolicyCategories>,
targetReport?: OnyxTypes.Report,
Expand Down Expand Up @@ -6962,6 +6981,7 @@
},
report: selfDMReport,
isDraftPolicy: false,
quickAction,
};
return trackExpense(trackExpenseParams);
}
Expand Down
2 changes: 2 additions & 0 deletions src/pages/Share/SubmitDetailsPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ function SubmitDetailsPage({
const [policyCategories] = useOnyx(`${ONYXKEYS.COLLECTION.POLICY_CATEGORIES}${getIOURequestPolicyID(transaction, report)}`, {canBeMissing: false});
const [policyTags] = useOnyx(`${ONYXKEYS.COLLECTION.POLICY_TAGS}${getIOURequestPolicyID(transaction, report)}`, {canBeMissing: false});
const [lastLocationPermissionPrompt] = useOnyx(ONYXKEYS.NVP_LAST_LOCATION_PERMISSION_PROMPT, {canBeMissing: false});
const [quickAction] = useOnyx(ONYXKEYS.NVP_QUICK_ACTION_GLOBAL_CREATE, {canBeMissing: true});
const [reportAttributesDerived] = useOnyx(ONYXKEYS.DERIVED.REPORT_ATTRIBUTES, {canBeMissing: true, selector: reportsSelector});
const [currentDate] = useOnyx(ONYXKEYS.CURRENT_DATE, {canBeMissing: true});
const [validFilesToUpload] = useOnyx(ONYXKEYS.VALIDATED_FILE_OBJECT, {canBeMissing: true});
Expand Down Expand Up @@ -140,6 +141,7 @@ function SubmitDetailsPage({
isLinkedTrackedExpenseReportArchived,
},
isASAPSubmitBetaEnabled,
quickAction,
});
} else {
requestMoney({
Expand Down
1 change: 1 addition & 0 deletions src/pages/iou/request/step/IOURequestStepAmount.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -254,6 +254,7 @@ function IOURequestStepAmount({
merchant: CONST.TRANSACTION.PARTIAL_TRANSACTION_MERCHANT,
},
isASAPSubmitBetaEnabled,
quickAction,
});
return;
}
Expand Down
2 changes: 2 additions & 0 deletions src/pages/iou/request/step/IOURequestStepConfirmation.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -748,6 +748,7 @@ function IOURequestStepConfirmation({
},
shouldHandleNavigation: index === transactions.length - 1,
isASAPSubmitBetaEnabled,
quickAction,
});
}
},
Expand All @@ -768,6 +769,7 @@ function IOURequestStepConfirmation({
isManualDistanceRequest,
archivedReportsIdSet,
isASAPSubmitBetaEnabled,
quickAction,
],
);

Expand Down
1 change: 1 addition & 0 deletions src/pages/iou/request/step/IOURequestStepDistance.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -351,6 +351,7 @@ function IOURequestStepDistance({
attendees: transaction?.comment?.attendees,
},
isASAPSubmitBetaEnabled,
quickAction,
});
return;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,7 @@ function IOURequestStepDistanceManual({
attendees: transaction?.comment?.attendees,
},
isASAPSubmitBetaEnabled,
quickAction,
});
return;
}
Expand Down
1 change: 1 addition & 0 deletions src/pages/iou/request/step/IOURequestStepDistanceMap.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -353,6 +353,7 @@ function IOURequestStepDistanceMap({
attendees: transaction?.comment?.attendees,
},
isASAPSubmitBetaEnabled,
quickAction,
});
return;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -337,6 +337,7 @@ function IOURequestStepScan({
...(policyParams ?? {}),
shouldHandleNavigation: index === files.length - 1,
isASAPSubmitBetaEnabled,
quickAction,
});
} else {
requestMoney({
Expand Down Expand Up @@ -378,6 +379,7 @@ function IOURequestStepScan({
shouldGenerateTransactionThreadReport,
isASAPSubmitBetaEnabled,
transactionViolations,
quickAction,
],
);

Expand Down
2 changes: 2 additions & 0 deletions src/pages/iou/request/step/IOURequestStepScan/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -392,6 +392,7 @@ function IOURequestStepScan({
...(policyParams ?? {}),
shouldHandleNavigation: index === files.length - 1,
isASAPSubmitBetaEnabled,
quickAction,
});
} else {
requestMoney({
Expand Down Expand Up @@ -434,6 +435,7 @@ function IOURequestStepScan({
shouldGenerateTransactionThreadReport,
isASAPSubmitBetaEnabled,
transactionViolations,
quickAction,
],
);

Expand Down
11 changes: 11 additions & 0 deletions tests/actions/IOUTest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -519,6 +519,7 @@ describe('actions/IOU', () => {
customUnitRateID: CONST.CUSTOM_UNITS.FAKE_P2P_ID,
},
isASAPSubmitBetaEnabled: false,
quickAction: undefined,
});
await waitForBatchedUpdates();
await mockFetch?.resume?.();
Expand Down Expand Up @@ -612,6 +613,7 @@ describe('actions/IOU', () => {
customUnitRateID: CONST.CUSTOM_UNITS.FAKE_P2P_ID,
},
isASAPSubmitBetaEnabled: false,
quickAction: undefined,
});
await waitForBatchedUpdates();
await mockFetch?.resume?.();
Expand Down Expand Up @@ -690,6 +692,7 @@ describe('actions/IOU', () => {
billable: false,
},
isASAPSubmitBetaEnabled: false,
quickAction: undefined,
});
await waitForBatchedUpdates();

Expand Down Expand Up @@ -737,6 +740,7 @@ describe('actions/IOU', () => {
accountant,
},
isASAPSubmitBetaEnabled: false,
quickAction: undefined,
});
await waitForBatchedUpdates();

Expand Down Expand Up @@ -810,6 +814,7 @@ describe('actions/IOU', () => {
billable: false,
},
isASAPSubmitBetaEnabled: false,
quickAction: undefined,
});
await waitForBatchedUpdates();

Expand Down Expand Up @@ -857,6 +862,7 @@ describe('actions/IOU', () => {
accountant,
},
isASAPSubmitBetaEnabled: false,
quickAction: undefined,
});
await waitForBatchedUpdates();

Expand Down Expand Up @@ -1960,6 +1966,7 @@ describe('actions/IOU', () => {
billable: false,
},
isASAPSubmitBetaEnabled: false,
quickAction: undefined,
});

mockFetch?.resume?.();
Expand Down Expand Up @@ -2020,6 +2027,7 @@ describe('actions/IOU', () => {
accountant,
},
isASAPSubmitBetaEnabled: false,
quickAction: undefined,
});
await waitForBatchedUpdates();

Expand Down Expand Up @@ -6614,6 +6622,7 @@ describe('actions/IOU', () => {
},
accountantParams: action === CONST.IOU.ACTION.SHARE ? {accountant: {accountID: VIT_ACCOUNT_ID, login: VIT_EMAIL}} : undefined,
isASAPSubmitBetaEnabled: false,
quickAction: undefined,
});

await waitForBatchedUpdates();
Expand Down Expand Up @@ -8228,6 +8237,7 @@ describe('actions/IOU', () => {
reimbursable: false,
},
isASAPSubmitBetaEnabled: false,
quickAction: undefined,
});
await getOnyxData({
key: ONYXKEYS.COLLECTION.TRANSACTION,
Expand Down Expand Up @@ -10815,6 +10825,7 @@ describe('actions/IOU', () => {
mockOptimisticChatReportID,
mockOptimisticIOUReportID,
mockIsASAPSubmitBetaEnabled,
undefined,
mockPolicy,
fakePolicyCategories,
policyExpenseChat,
Expand Down
1 change: 1 addition & 0 deletions tests/ui/UnreadIndicatorsTest.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -711,6 +711,7 @@ describe('Unread Indicators', () => {
created: format(new Date(), CONST.DATE.FNS_FORMAT_STRING),
},
isASAPSubmitBetaEnabled: true,
quickAction: undefined,
});
await waitForBatchedUpdates();

Expand Down
1 change: 1 addition & 0 deletions tests/unit/GoogleTagManagerTest.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,7 @@ describe('GoogleTagManagerTest', () => {
linkedTrackedExpenseReportID: 'linkedTrackedExpenseReportID',
},
isASAPSubmitBetaEnabled: false,
quickAction: undefined,
});

await waitForBatchedUpdatesWithAct();
Expand Down
Loading