From 82a0f8ca8db65414ac19260582853c9f085b54a1 Mon Sep 17 00:00:00 2001 From: Alberto <alberto@expensify.com> Date: Tue, 26 Mar 2024 12:39:18 +0100 Subject: [PATCH 001/206] set skip confirmation flag --- src/libs/actions/IOU.ts | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/libs/actions/IOU.ts b/src/libs/actions/IOU.ts index 85ab98bb7819..bae3dc7e39d4 100644 --- a/src/libs/actions/IOU.ts +++ b/src/libs/actions/IOU.ts @@ -325,6 +325,7 @@ function updateMoneyRequestTypeParams(routes: StackNavigationState<ParamListBase // eslint-disable-next-line @typescript-eslint/naming-convention function startMoneyRequest(iouType: ValueOf<typeof CONST.IOU.TYPE>, reportID: string, requestType?: ValueOf<typeof CONST.IOU.REQUEST_TYPE>) { clearMoneyRequest(CONST.IOU.OPTIMISTIC_TRANSACTION_ID); + setSkipConfirmation(CONST.IOU.OPTIMISTIC_TRANSACTION_ID); switch (requestType) { case CONST.IOU.REQUEST_TYPE.MANUAL: Navigation.navigate(ROUTES.MONEY_REQUEST_CREATE_TAB_MANUAL.getRoute(CONST.IOU.ACTION.CREATE, iouType, CONST.IOU.OPTIMISTIC_TRANSACTION_ID, reportID)); @@ -4985,6 +4986,10 @@ function setMoneyRequestTaxAmount(transactionID: string, taxAmount: number) { Onyx.merge(`${ONYXKEYS.COLLECTION.TRANSACTION_DRAFT}${transactionID}`, {taxAmount}); } +function setSkipConfirmation(transactionID: string) { + Onyx.merge(`${ONYXKEYS.COLLECTION.TRANSACTION_DRAFT}${transactionID}`, {skipConfirmation: true}); +} + function setMoneyRequestBillable(billable: boolean) { Onyx.merge(ONYXKEYS.IOU, {billable}); } From a37611633bf3eb376bf38640139b6c6abadffcf0 Mon Sep 17 00:00:00 2001 From: Alberto <alberto@expensify.com> Date: Tue, 26 Mar 2024 12:54:03 +0100 Subject: [PATCH 002/206] add new params to handle skip --- src/libs/actions/IOU.ts | 2 +- src/pages/iou/steps/MoneyRequestAmountForm.tsx | 11 ++++++++++- src/pages/iou/steps/NewRequestAmountPage.js | 2 ++ 3 files changed, 13 insertions(+), 2 deletions(-) diff --git a/src/libs/actions/IOU.ts b/src/libs/actions/IOU.ts index bae3dc7e39d4..53ac13c4e363 100644 --- a/src/libs/actions/IOU.ts +++ b/src/libs/actions/IOU.ts @@ -4987,7 +4987,7 @@ function setMoneyRequestTaxAmount(transactionID: string, taxAmount: number) { } function setSkipConfirmation(transactionID: string) { - Onyx.merge(`${ONYXKEYS.COLLECTION.TRANSACTION_DRAFT}${transactionID}`, {skipConfirmation: true}); + Onyx.merge(ONYXKEYS.IOU, {skipConfirmation: true}); } function setMoneyRequestBillable(billable: boolean) { diff --git a/src/pages/iou/steps/MoneyRequestAmountForm.tsx b/src/pages/iou/steps/MoneyRequestAmountForm.tsx index aec2f4765fd4..1b17c14296a4 100644 --- a/src/pages/iou/steps/MoneyRequestAmountForm.tsx +++ b/src/pages/iou/steps/MoneyRequestAmountForm.tsx @@ -34,6 +34,12 @@ type MoneyRequestAmountFormProps = { /** Whether the amount is being edited or not */ isEditing?: boolean; + /** Whether the confirmation screen should be skipped */ + skipConfirmation?: boolean; + + /** Type of the IOU */ + iouType?: ValueOf<typeof CONST.IOU.TYPE>; + /** Fired when back button pressed, navigates to currency selection page */ onCurrencyButtonPress: () => void; @@ -261,7 +267,10 @@ function MoneyRequestAmountForm( }; const formattedAmount = MoneyRequestUtils.replaceAllDigits(currentAmount, toLocaleDigit); - const buttonText = isEditing ? translate('common.save') : translate('common.next'); + let buttonText = isEditing ? translate('common.save') : translate('common.next'); + if (props.skipConfirmation) { + buttonText = props.iouType === CONST.IOU.TYPE.SPLIT ? 'Split' : 'Request'; + } const canUseTouchScreen = DeviceCapabilities.canUseTouchScreen(); useEffect(() => { diff --git a/src/pages/iou/steps/NewRequestAmountPage.js b/src/pages/iou/steps/NewRequestAmountPage.js index 1df74569e4c3..85881503f2de 100644 --- a/src/pages/iou/steps/NewRequestAmountPage.js +++ b/src/pages/iou/steps/NewRequestAmountPage.js @@ -146,6 +146,8 @@ function NewRequestAmountPage({route, iou, report, selectedTab}) { isEditing={isEditing} currency={currency} amount={iou.amount} + skipConfirmation={iou.skipConfirmation} + iouType={iouType} ref={(e) => (textInput.current = e)} onCurrencyButtonPress={navigateToCurrencySelectionPage} onSubmitButtonPress={navigateToNextPage} From b08993e1494652422d777afc8c1d9be058418ca2 Mon Sep 17 00:00:00 2001 From: Alberto <alberto@expensify.com> Date: Tue, 26 Mar 2024 14:09:26 +0100 Subject: [PATCH 003/206] changing branch --- src/components/transactionPropTypes.js | 2 ++ src/libs/actions/IOU.ts | 5 +++-- src/pages/iou/request/IOURequestStartPage.js | 1 + src/pages/iou/request/step/IOURequestStepAmount.js | 2 ++ src/pages/iou/steps/MoneyRequestAmountForm.tsx | 6 ++++-- src/pages/iou/steps/NewRequestAmountPage.js | 2 ++ 6 files changed, 14 insertions(+), 4 deletions(-) diff --git a/src/components/transactionPropTypes.js b/src/components/transactionPropTypes.js index 7eb1b776358c..db0842e0c83a 100644 --- a/src/components/transactionPropTypes.js +++ b/src/components/transactionPropTypes.js @@ -93,4 +93,6 @@ export default PropTypes.shape({ /** Server side errors keyed by microtime */ errorFields: PropTypes.objectOf(PropTypes.objectOf(translatableTextPropTypes)), + + skipConfirmation: PropTypes.bool, }); diff --git a/src/libs/actions/IOU.ts b/src/libs/actions/IOU.ts index 53ac13c4e363..8946f442490a 100644 --- a/src/libs/actions/IOU.ts +++ b/src/libs/actions/IOU.ts @@ -325,7 +325,7 @@ function updateMoneyRequestTypeParams(routes: StackNavigationState<ParamListBase // eslint-disable-next-line @typescript-eslint/naming-convention function startMoneyRequest(iouType: ValueOf<typeof CONST.IOU.TYPE>, reportID: string, requestType?: ValueOf<typeof CONST.IOU.REQUEST_TYPE>) { clearMoneyRequest(CONST.IOU.OPTIMISTIC_TRANSACTION_ID); - setSkipConfirmation(CONST.IOU.OPTIMISTIC_TRANSACTION_ID); + setSkipConfirmation(); switch (requestType) { case CONST.IOU.REQUEST_TYPE.MANUAL: Navigation.navigate(ROUTES.MONEY_REQUEST_CREATE_TAB_MANUAL.getRoute(CONST.IOU.ACTION.CREATE, iouType, CONST.IOU.OPTIMISTIC_TRANSACTION_ID, reportID)); @@ -4986,7 +4986,7 @@ function setMoneyRequestTaxAmount(transactionID: string, taxAmount: number) { Onyx.merge(`${ONYXKEYS.COLLECTION.TRANSACTION_DRAFT}${transactionID}`, {taxAmount}); } -function setSkipConfirmation(transactionID: string) { +function setSkipConfirmation() { Onyx.merge(ONYXKEYS.IOU, {skipConfirmation: true}); } @@ -5219,6 +5219,7 @@ export { setMoneyRequestTaxAmount, setMoneyRequestTaxRate, setShownHoldUseExplanation, + setSkipConfirmation, navigateToNextPage, updateMoneyRequestDate, updateMoneyRequestBillable, diff --git a/src/pages/iou/request/IOURequestStartPage.js b/src/pages/iou/request/IOURequestStartPage.js index cb078fac133c..b87db2579553 100644 --- a/src/pages/iou/request/IOURequestStartPage.js +++ b/src/pages/iou/request/IOURequestStartPage.js @@ -70,6 +70,7 @@ function IOURequestStartPage({ selectedTab, transaction, }) { + console.log(transaction); const styles = useThemeStyles(); const {translate} = useLocalize(); const navigation = useNavigation(); diff --git a/src/pages/iou/request/step/IOURequestStepAmount.js b/src/pages/iou/request/step/IOURequestStepAmount.js index 9fdd2bea24f4..931f33e19175 100644 --- a/src/pages/iou/request/step/IOURequestStepAmount.js +++ b/src/pages/iou/request/step/IOURequestStepAmount.js @@ -166,6 +166,8 @@ function IOURequestStepAmount({ isEditing={Boolean(backTo)} currency={currency} amount={transaction.amount} + skipConfirmation={transaction.skipConfirmation} + iouType={iouType} ref={(e) => (textInput.current = e)} onCurrencyButtonPress={navigateToCurrencySelectionPage} onSubmitButtonPress={navigateToNextPage} diff --git a/src/pages/iou/steps/MoneyRequestAmountForm.tsx b/src/pages/iou/steps/MoneyRequestAmountForm.tsx index 1b17c14296a4..46da8715bd85 100644 --- a/src/pages/iou/steps/MoneyRequestAmountForm.tsx +++ b/src/pages/iou/steps/MoneyRequestAmountForm.tsx @@ -77,6 +77,8 @@ function MoneyRequestAmountForm( taxAmount = 0, currency = CONST.CURRENCY.USD, isEditing = false, + skipConfirmation = false, + iouType = CONST.IOU.TYPE.REQUEST, onCurrencyButtonPress, onSubmitButtonPress, selectedTab = CONST.TAB_REQUEST.MANUAL, @@ -268,8 +270,8 @@ function MoneyRequestAmountForm( const formattedAmount = MoneyRequestUtils.replaceAllDigits(currentAmount, toLocaleDigit); let buttonText = isEditing ? translate('common.save') : translate('common.next'); - if (props.skipConfirmation) { - buttonText = props.iouType === CONST.IOU.TYPE.SPLIT ? 'Split' : 'Request'; + if (skipConfirmation) { + buttonText = iouType === CONST.IOU.TYPE.SPLIT ? 'Split' : 'Request'; } const canUseTouchScreen = DeviceCapabilities.canUseTouchScreen(); diff --git a/src/pages/iou/steps/NewRequestAmountPage.js b/src/pages/iou/steps/NewRequestAmountPage.js index 85881503f2de..11a9260c4cf8 100644 --- a/src/pages/iou/steps/NewRequestAmountPage.js +++ b/src/pages/iou/steps/NewRequestAmountPage.js @@ -154,6 +154,8 @@ function NewRequestAmountPage({route, iou, report, selectedTab}) { selectedTab={selectedTab} /> ); + console.log(iou); + console.log(iouType); // ScreenWrapper is only needed in edit mode because we have a dedicated route for the edit amount page (MoneyRequestEditAmountPage). // The rest of the cases this component is rendered through <MoneyRequestSelectorPage /> which has it's own ScreenWrapper From 90f96dafea8d8c312acef6a7af78073e0cd880da Mon Sep 17 00:00:00 2001 From: Alberto <alberto@expensify.com> Date: Tue, 26 Mar 2024 17:16:16 +0100 Subject: [PATCH 004/206] Correctly set flag --- src/libs/actions/IOU.ts | 21 ++++++++++---------- src/pages/iou/request/IOURequestStartPage.js | 5 ++--- 2 files changed, 13 insertions(+), 13 deletions(-) diff --git a/src/libs/actions/IOU.ts b/src/libs/actions/IOU.ts index 8946f442490a..b55a57cf13aa 100644 --- a/src/libs/actions/IOU.ts +++ b/src/libs/actions/IOU.ts @@ -258,8 +258,10 @@ Onyx.connect({ * @param policy * @param isFromGlobalCreate * @param iouRequestType one of manual/scan/distance + * @param skipConfirmation if true, skip confirmation step */ -function initMoneyRequest(reportID: string, policy: OnyxEntry<OnyxTypes.Policy>, isFromGlobalCreate: boolean, iouRequestType: IOURequestType = CONST.IOU.REQUEST_TYPE.MANUAL) { +function initMoneyRequest(reportID: string, policy: OnyxEntry<OnyxTypes.Policy>, isFromGlobalCreate: boolean, iouRequestType: IOURequestType = CONST.IOU.REQUEST_TYPE.MANUAL, skipConfirmation = false) { + console.log('this'); // Generate a brand new transactionID const newTransactionID = CONST.IOU.OPTIMISTIC_TRANSACTION_ID; // Disabling this line since currentDate can be an empty string @@ -292,12 +294,17 @@ function initMoneyRequest(reportID: string, policy: OnyxEntry<OnyxTypes.Policy>, reportID, transactionID: newTransactionID, isFromGlobalCreate, + skipConfirmation, merchant: CONST.TRANSACTION.PARTIAL_TRANSACTION_MERCHANT, }); } -function clearMoneyRequest(transactionID: string) { - Onyx.set(`${ONYXKEYS.COLLECTION.TRANSACTION_DRAFT}${transactionID}`, null); +function clearMoneyRequest(transactionID: string, skipConfirmation = false) { + if (skipConfirmation) { + Onyx.set(`${ONYXKEYS.COLLECTION.TRANSACTION_DRAFT}${transactionID}`, {skipConfirmation: true}); + } else { + Onyx.set(`${ONYXKEYS.COLLECTION.TRANSACTION_DRAFT}${transactionID}`, null); + } } /** @@ -324,8 +331,7 @@ function updateMoneyRequestTypeParams(routes: StackNavigationState<ParamListBase // eslint-disable-next-line @typescript-eslint/naming-convention function startMoneyRequest(iouType: ValueOf<typeof CONST.IOU.TYPE>, reportID: string, requestType?: ValueOf<typeof CONST.IOU.REQUEST_TYPE>) { - clearMoneyRequest(CONST.IOU.OPTIMISTIC_TRANSACTION_ID); - setSkipConfirmation(); + clearMoneyRequest(CONST.IOU.OPTIMISTIC_TRANSACTION_ID, true); switch (requestType) { case CONST.IOU.REQUEST_TYPE.MANUAL: Navigation.navigate(ROUTES.MONEY_REQUEST_CREATE_TAB_MANUAL.getRoute(CONST.IOU.ACTION.CREATE, iouType, CONST.IOU.OPTIMISTIC_TRANSACTION_ID, reportID)); @@ -4986,10 +4992,6 @@ function setMoneyRequestTaxAmount(transactionID: string, taxAmount: number) { Onyx.merge(`${ONYXKEYS.COLLECTION.TRANSACTION_DRAFT}${transactionID}`, {taxAmount}); } -function setSkipConfirmation() { - Onyx.merge(ONYXKEYS.IOU, {skipConfirmation: true}); -} - function setMoneyRequestBillable(billable: boolean) { Onyx.merge(ONYXKEYS.IOU, {billable}); } @@ -5219,7 +5221,6 @@ export { setMoneyRequestTaxAmount, setMoneyRequestTaxRate, setShownHoldUseExplanation, - setSkipConfirmation, navigateToNextPage, updateMoneyRequestDate, updateMoneyRequestBillable, diff --git a/src/pages/iou/request/IOURequestStartPage.js b/src/pages/iou/request/IOURequestStartPage.js index b87db2579553..0add953b7b50 100644 --- a/src/pages/iou/request/IOURequestStartPage.js +++ b/src/pages/iou/request/IOURequestStartPage.js @@ -70,7 +70,6 @@ function IOURequestStartPage({ selectedTab, transaction, }) { - console.log(transaction); const styles = useThemeStyles(); const {translate} = useLocalize(); const navigation = useNavigation(); @@ -106,7 +105,7 @@ function IOURequestStartPage({ if (transaction.reportID === reportID) { return; } - IOU.initMoneyRequest(reportID, policy, isFromGlobalCreate, transactionRequestType.current); + IOU.initMoneyRequest(reportID, policy, isFromGlobalCreate, transactionRequestType.current, lodashGet(transaction, 'skipConfirmation', false)); }, [transaction, policy, reportID, iouType, isFromGlobalCreate]); const isExpenseChat = ReportUtils.isPolicyExpenseChat(report); @@ -128,7 +127,7 @@ function IOURequestStartPage({ if (iouType === CONST.IOU.TYPE.SPLIT && transaction.isFromGlobalCreate) { IOU.updateMoneyRequestTypeParams(navigation.getState().routes, CONST.IOU.TYPE.REQUEST, newIouType); } - IOU.initMoneyRequest(reportID, policy, isFromGlobalCreate, newIouType); + IOU.initMoneyRequest(reportID, policy, isFromGlobalCreate, newIouType, lodashGet(transaction, 'skipConfirmation', false)); transactionRequestType.current = newIouType; }, [policy, previousIOURequestType, reportID, isFromGlobalCreate, iouType, navigation, transaction.isFromGlobalCreate], From d24012da390531107bb5d39cba1971b2d96cee9f Mon Sep 17 00:00:00 2001 From: Alberto <alberto@expensify.com> Date: Wed, 27 Mar 2024 11:55:48 +0100 Subject: [PATCH 005/206] handle split --- src/libs/actions/IOU.ts | 5 +-- .../iou/request/step/IOURequestStepAmount.js | 31 +++++++++++++++++-- .../iou/steps/MoneyRequestAmountForm.tsx | 2 +- src/pages/iou/steps/NewRequestAmountPage.js | 1 + 4 files changed, 34 insertions(+), 5 deletions(-) diff --git a/src/libs/actions/IOU.ts b/src/libs/actions/IOU.ts index b55a57cf13aa..c896f030f015 100644 --- a/src/libs/actions/IOU.ts +++ b/src/libs/actions/IOU.ts @@ -261,7 +261,6 @@ Onyx.connect({ * @param skipConfirmation if true, skip confirmation step */ function initMoneyRequest(reportID: string, policy: OnyxEntry<OnyxTypes.Policy>, isFromGlobalCreate: boolean, iouRequestType: IOURequestType = CONST.IOU.REQUEST_TYPE.MANUAL, skipConfirmation = false) { - console.log('this'); // Generate a brand new transactionID const newTransactionID = CONST.IOU.OPTIMISTIC_TRANSACTION_ID; // Disabling this line since currentDate can be an empty string @@ -4959,7 +4958,7 @@ function replaceReceipt(transactionID: string, file: File, source: string) { * @param transactionID of the transaction to set the participants of * @param report attached to the transaction */ -function setMoneyRequestParticipantsFromReport(transactionID: string, report: OnyxTypes.Report) { +function setMoneyRequestParticipantsFromReport(transactionID: string, report: OnyxTypes.Report): Participant[] { // If the report is iou or expense report, we should get the chat report to set participant for request money const chatReport = ReportUtils.isMoneyRequestReport(report) ? ReportUtils.getReport(report.chatReportID) : report; const currentUserAccountID = currentUserPersonalDetails.accountID; @@ -4970,6 +4969,8 @@ function setMoneyRequestParticipantsFromReport(transactionID: string, report: On : (chatReport?.participantAccountIDs ?? []).filter((accountID) => currentUserAccountID !== accountID).map((accountID) => ({accountID, selected: true})); Onyx.merge(`${ONYXKEYS.COLLECTION.TRANSACTION_DRAFT}${transactionID}`, {participants, participantsAutoAssigned: true}); + + return participants; } function setMoneyRequestId(id: string) { diff --git a/src/pages/iou/request/step/IOURequestStepAmount.js b/src/pages/iou/request/step/IOURequestStepAmount.js index 931f33e19175..1e5edf805be8 100644 --- a/src/pages/iou/request/step/IOURequestStepAmount.js +++ b/src/pages/iou/request/step/IOURequestStepAmount.js @@ -22,6 +22,10 @@ import IOURequestStepRoutePropTypes from './IOURequestStepRoutePropTypes'; import StepScreenWrapper from './StepScreenWrapper'; import withFullTransactionOrNotFound from './withFullTransactionOrNotFound'; import withWritableReportOrNotFound from './withWritableReportOrNotFound'; +import { + withCurrentUserPersonalDetailsDefaultProps, + withCurrentUserPersonalDetailsPropTypes +} from "@components/withCurrentUserPersonalDetails"; const propTypes = { /** Navigation route context info provided by react navigation */ @@ -51,12 +55,15 @@ const propTypes = { /** Collection of tax rates attached to a policy */ taxRates: taxPropTypes, }), + + ...withCurrentUserPersonalDetailsPropTypes, }; const defaultProps = { report: {}, transaction: {}, policy: {}, + ...withCurrentUserPersonalDetailsDefaultProps, }; const getTaxAmount = (transaction, defaultTaxValue, amount) => { @@ -72,6 +79,7 @@ function IOURequestStepAmount({ transaction, transaction: {currency}, policy, + currentUserPersonalDetails, }) { const {translate} = useLocalize(); const textInput = useRef(null); @@ -144,8 +152,27 @@ function IOURequestStepAmount({ // inside a report. In this case, the participants can be automatically assigned from the report and the user can skip the participants step and go straight // to the confirm step. if (report.reportID) { - IOU.setMoneyRequestParticipantsFromReport(transactionID, report); - Navigation.navigate(ROUTES.MONEY_REQUEST_STEP_CONFIRMATION.getRoute(iouType, transactionID, reportID)); + const selectedParticipants = IOU.setMoneyRequestParticipantsFromReport(transactionID, report); + + if (transaction.skipConfirmation) { + if (iouType === CONST.IOU.TYPE.SPLIT) { + IOU.splitBillAndOpenReport( + selectedParticipants, + currentUserPersonalDetails.login, + currentUserPersonalDetails.accountID, + transaction.amount, + lodashGet(transaction, 'comment', '').trim(), + transaction.currency, + transaction.category, + transaction.tag, + transaction.merchant, + ); + return; + } + + } else { + Navigation.navigate(ROUTES.MONEY_REQUEST_STEP_CONFIRMATION.getRoute(iouType, transactionID, reportID)); + } return; } diff --git a/src/pages/iou/steps/MoneyRequestAmountForm.tsx b/src/pages/iou/steps/MoneyRequestAmountForm.tsx index 46da8715bd85..d9c76c9f02fe 100644 --- a/src/pages/iou/steps/MoneyRequestAmountForm.tsx +++ b/src/pages/iou/steps/MoneyRequestAmountForm.tsx @@ -271,7 +271,7 @@ function MoneyRequestAmountForm( const formattedAmount = MoneyRequestUtils.replaceAllDigits(currentAmount, toLocaleDigit); let buttonText = isEditing ? translate('common.save') : translate('common.next'); if (skipConfirmation) { - buttonText = iouType === CONST.IOU.TYPE.SPLIT ? 'Split' : 'Request'; + buttonText = iouType === CONST.IOU.TYPE.SPLIT ? translate('iou.split') : translate('iou.request'); } const canUseTouchScreen = DeviceCapabilities.canUseTouchScreen(); diff --git a/src/pages/iou/steps/NewRequestAmountPage.js b/src/pages/iou/steps/NewRequestAmountPage.js index 11a9260c4cf8..296624a4c232 100644 --- a/src/pages/iou/steps/NewRequestAmountPage.js +++ b/src/pages/iou/steps/NewRequestAmountPage.js @@ -138,6 +138,7 @@ function NewRequestAmountPage({route, iou, report, selectedTab}) { return; } + if () IOU.navigateToNextPage(iou, iouType, report); }; From bd1f325e8a114741f48145f803a2a1d04b154301 Mon Sep 17 00:00:00 2001 From: Alberto <alberto@expensify.com> Date: Wed, 27 Mar 2024 12:17:49 +0100 Subject: [PATCH 006/206] correctly set flag --- src/libs/actions/IOU.ts | 4 ++-- .../SidebarScreen/FloatingActionButtonAndPopover.js | 12 ++++++------ 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/libs/actions/IOU.ts b/src/libs/actions/IOU.ts index c896f030f015..4e5158cf7b20 100644 --- a/src/libs/actions/IOU.ts +++ b/src/libs/actions/IOU.ts @@ -329,8 +329,8 @@ function updateMoneyRequestTypeParams(routes: StackNavigationState<ParamListBase } // eslint-disable-next-line @typescript-eslint/naming-convention -function startMoneyRequest(iouType: ValueOf<typeof CONST.IOU.TYPE>, reportID: string, requestType?: ValueOf<typeof CONST.IOU.REQUEST_TYPE>) { - clearMoneyRequest(CONST.IOU.OPTIMISTIC_TRANSACTION_ID, true); +function startMoneyRequest(iouType: ValueOf<typeof CONST.IOU.TYPE>, reportID: string, requestType?: ValueOf<typeof CONST.IOU.REQUEST_TYPE>, skipConfirmation = false) { + clearMoneyRequest(CONST.IOU.OPTIMISTIC_TRANSACTION_ID, skipConfirmation); switch (requestType) { case CONST.IOU.REQUEST_TYPE.MANUAL: Navigation.navigate(ROUTES.MONEY_REQUEST_CREATE_TAB_MANUAL.getRoute(CONST.IOU.ACTION.CREATE, iouType, CONST.IOU.OPTIMISTIC_TRANSACTION_ID, reportID)); diff --git a/src/pages/home/sidebar/SidebarScreen/FloatingActionButtonAndPopover.js b/src/pages/home/sidebar/SidebarScreen/FloatingActionButtonAndPopover.js index 117083293b5d..33d199f6aa4f 100644 --- a/src/pages/home/sidebar/SidebarScreen/FloatingActionButtonAndPopover.js +++ b/src/pages/home/sidebar/SidebarScreen/FloatingActionButtonAndPopover.js @@ -157,22 +157,22 @@ function FloatingActionButtonAndPopover(props) { const navigateToQuickAction = () => { switch (props.quickAction.action) { case CONST.QUICK_ACTIONS.REQUEST_MANUAL: - IOU.startMoneyRequest(CONST.IOU.TYPE.REQUEST, props.quickAction.chatReportID, CONST.IOU.REQUEST_TYPE.MANUAL); + IOU.startMoneyRequest(CONST.IOU.TYPE.REQUEST, props.quickAction.chatReportID, CONST.IOU.REQUEST_TYPE.MANUAL, true); return; case CONST.QUICK_ACTIONS.REQUEST_SCAN: - IOU.startMoneyRequest(CONST.IOU.TYPE.REQUEST, props.quickAction.chatReportID, CONST.IOU.REQUEST_TYPE.SCAN); + IOU.startMoneyRequest(CONST.IOU.TYPE.REQUEST, props.quickAction.chatReportID, CONST.IOU.REQUEST_TYPE.SCAN, true); return; case CONST.QUICK_ACTIONS.REQUEST_DISTANCE: - IOU.startMoneyRequest(CONST.IOU.TYPE.REQUEST, props.quickAction.chatReportID, CONST.IOU.REQUEST_TYPE.DISTANCE); + IOU.startMoneyRequest(CONST.IOU.TYPE.REQUEST, props.quickAction.chatReportID, CONST.IOU.REQUEST_TYPE.DISTANCE, true); return; case CONST.QUICK_ACTIONS.SPLIT_MANUAL: - IOU.startMoneyRequest(CONST.IOU.TYPE.SPLIT, props.quickAction.chatReportID, CONST.IOU.REQUEST_TYPE.MANUAL); + IOU.startMoneyRequest(CONST.IOU.TYPE.SPLIT, props.quickAction.chatReportID, CONST.IOU.REQUEST_TYPE.MANUAL, true); return; case CONST.QUICK_ACTIONS.SPLIT_SCAN: - IOU.startMoneyRequest(CONST.IOU.TYPE.SPLIT, props.quickAction.chatReportID, CONST.IOU.REQUEST_TYPE.SCAN); + IOU.startMoneyRequest(CONST.IOU.TYPE.SPLIT, props.quickAction.chatReportID, CONST.IOU.REQUEST_TYPE.SCAN, true); return; case CONST.QUICK_ACTIONS.SPLIT_DISTANCE: - IOU.startMoneyRequest(CONST.IOU.TYPE.SPLIT, props.quickAction.chatReportID, CONST.IOU.REQUEST_TYPE.DISTANCE); + IOU.startMoneyRequest(CONST.IOU.TYPE.SPLIT, props.quickAction.chatReportID, CONST.IOU.REQUEST_TYPE.DISTANCE, true); return; case CONST.QUICK_ACTIONS.SEND_MONEY: IOU.startMoneyRequest(CONST.IOU.TYPE.SEND, props.quickAction.chatReportID); From 33cba717b2f9a2a92f18992cc004b97697c76074 Mon Sep 17 00:00:00 2001 From: Alberto <alberto@expensify.com> Date: Wed, 27 Mar 2024 12:18:08 +0100 Subject: [PATCH 007/206] handle money request --- .../iou/request/step/IOURequestStepAmount.js | 39 ++++++++++++++++++- src/pages/iou/steps/NewRequestAmountPage.js | 2 - 2 files changed, 37 insertions(+), 4 deletions(-) diff --git a/src/pages/iou/request/step/IOURequestStepAmount.js b/src/pages/iou/request/step/IOURequestStepAmount.js index 1e5edf805be8..7fa10b80096e 100644 --- a/src/pages/iou/request/step/IOURequestStepAmount.js +++ b/src/pages/iou/request/step/IOURequestStepAmount.js @@ -26,6 +26,8 @@ import { withCurrentUserPersonalDetailsDefaultProps, withCurrentUserPersonalDetailsPropTypes } from "@components/withCurrentUserPersonalDetails"; +import tagPropTypes from "@components/tagPropTypes"; +import categoryPropTypes from "@components/categoryPropTypes"; const propTypes = { /** Navigation route context info provided by react navigation */ @@ -56,6 +58,10 @@ const propTypes = { taxRates: taxPropTypes, }), + policyTags: tagPropTypes, + + policyCategories: PropTypes.objectOf(categoryPropTypes), + ...withCurrentUserPersonalDetailsPropTypes, }; @@ -63,6 +69,8 @@ const defaultProps = { report: {}, transaction: {}, policy: {}, + policyCategories: {}, + policyTags: {}, ...withCurrentUserPersonalDetailsDefaultProps, }; @@ -79,6 +87,8 @@ function IOURequestStepAmount({ transaction, transaction: {currency}, policy, + policyCategories, + policyTags, currentUserPersonalDetails, }) { const {translate} = useLocalize(); @@ -153,6 +163,7 @@ function IOURequestStepAmount({ // to the confirm step. if (report.reportID) { const selectedParticipants = IOU.setMoneyRequestParticipantsFromReport(transactionID, report); + const comment = lodashGet(transaction, 'comment.comment', ''); if (transaction.skipConfirmation) { if (iouType === CONST.IOU.TYPE.SPLIT) { @@ -161,15 +172,33 @@ function IOURequestStepAmount({ currentUserPersonalDetails.login, currentUserPersonalDetails.accountID, transaction.amount, - lodashGet(transaction, 'comment', '').trim(), + comment.trim(), transaction.currency, transaction.category, transaction.tag, transaction.merchant, ); return; + } else { + IOU.requestMoney( + report, + transaction.amount, + transaction.currency, + transaction.created, + transaction.merchant, + currentUserPersonalDetails.login, + currentUserPersonalDetails.accountID, + selectedParticipants[0], + comment.trim(), + null, + transaction.category, + transaction.tag, + transaction.billable, + policy, + policyTags, + policyCategories, + ); } - } else { Navigation.navigate(ROUTES.MONEY_REQUEST_STEP_CONFIRMATION.getRoute(iouType, transactionID, reportID)); } @@ -215,5 +244,11 @@ export default compose( policy: { key: ({report}) => `${ONYXKEYS.COLLECTION.POLICY}${report ? report.policyID : '0'}`, }, + policyCategories: { + key: ({report}) => `${ONYXKEYS.COLLECTION.POLICY_CATEGORIES}${report ? report.policyID : '0'}`, + }, + policyTags: { + key: ({report}) => `${ONYXKEYS.COLLECTION.POLICY_TAGS}${report ? report.policyID : '0'}`, + }, }), )(IOURequestStepAmount); diff --git a/src/pages/iou/steps/NewRequestAmountPage.js b/src/pages/iou/steps/NewRequestAmountPage.js index 296624a4c232..bbd0051f7fa0 100644 --- a/src/pages/iou/steps/NewRequestAmountPage.js +++ b/src/pages/iou/steps/NewRequestAmountPage.js @@ -137,8 +137,6 @@ function NewRequestAmountPage({route, iou, report, selectedTab}) { Navigation.goBack(ROUTES.MONEY_REQUEST_CONFIRMATION.getRoute(iouType, reportID)); return; } - - if () IOU.navigateToNextPage(iou, iouType, report); }; From 63414c1b868b5faf221641d27ab0dc1a7de4c4ce Mon Sep 17 00:00:00 2001 From: Alberto <alberto@expensify.com> Date: Wed, 27 Mar 2024 12:34:40 +0100 Subject: [PATCH 008/206] cleanup params --- .../iou/request/step/IOURequestStepAmount.js | 23 +++++++------------ 1 file changed, 8 insertions(+), 15 deletions(-) diff --git a/src/pages/iou/request/step/IOURequestStepAmount.js b/src/pages/iou/request/step/IOURequestStepAmount.js index 7fa10b80096e..87913ccebfab 100644 --- a/src/pages/iou/request/step/IOURequestStepAmount.js +++ b/src/pages/iou/request/step/IOURequestStepAmount.js @@ -163,7 +163,6 @@ function IOURequestStepAmount({ // to the confirm step. if (report.reportID) { const selectedParticipants = IOU.setMoneyRequestParticipantsFromReport(transactionID, report); - const comment = lodashGet(transaction, 'comment.comment', ''); if (transaction.skipConfirmation) { if (iouType === CONST.IOU.TYPE.SPLIT) { @@ -171,32 +170,26 @@ function IOURequestStepAmount({ selectedParticipants, currentUserPersonalDetails.login, currentUserPersonalDetails.accountID, - transaction.amount, - comment.trim(), + amount, + '', transaction.currency, - transaction.category, - transaction.tag, - transaction.merchant, + '', + '', + '', ); return; } else { IOU.requestMoney( report, - transaction.amount, + amount, transaction.currency, transaction.created, - transaction.merchant, + '', currentUserPersonalDetails.login, currentUserPersonalDetails.accountID, selectedParticipants[0], - comment.trim(), + '', null, - transaction.category, - transaction.tag, - transaction.billable, - policy, - policyTags, - policyCategories, ); } } else { From e9643692c227e2dc52bb61a93fac0a74c754b2c5 Mon Sep 17 00:00:00 2001 From: Alberto <alberto@expensify.com> Date: Wed, 27 Mar 2024 13:46:02 +0100 Subject: [PATCH 009/206] change branches --- .../iou/request/step/IOURequestStepAmount.js | 21 +++++++---- .../iou/steps/MoneyRequestAmountForm.tsx | 35 ++++++++++++++++++- 2 files changed, 49 insertions(+), 7 deletions(-) diff --git a/src/pages/iou/request/step/IOURequestStepAmount.js b/src/pages/iou/request/step/IOURequestStepAmount.js index 87913ccebfab..afea223e1c7c 100644 --- a/src/pages/iou/request/step/IOURequestStepAmount.js +++ b/src/pages/iou/request/step/IOURequestStepAmount.js @@ -141,8 +141,9 @@ function IOURequestStepAmount({ /** * @param {Number} amount */ - const navigateToNextPage = ({amount}) => { + const navigateToNextPage = ({amount, paymentMethod}) => { isSaveButtonPressed.current = true; + console.log(paymentMethod); const amountInSmallestCurrencyUnits = CurrencyUtils.convertToBackendAmount(Number.parseFloat(amount)); if ((iouRequestType === CONST.IOU.REQUEST_TYPE.MANUAL || backTo) && isTaxTrackingEnabled) { @@ -163,6 +164,7 @@ function IOURequestStepAmount({ // to the confirm step. if (report.reportID) { const selectedParticipants = IOU.setMoneyRequestParticipantsFromReport(transactionID, report); + const backendAmount = CurrencyUtils.convertToBackendAmount(Number.parseFloat(amount)); if (transaction.skipConfirmation) { if (iouType === CONST.IOU.TYPE.SPLIT) { @@ -170,7 +172,7 @@ function IOURequestStepAmount({ selectedParticipants, currentUserPersonalDetails.login, currentUserPersonalDetails.accountID, - amount, + backendAmount, '', transaction.currency, '', @@ -178,10 +180,15 @@ function IOURequestStepAmount({ '', ); return; - } else { + } + if (iouType === CONST.IOU.TYPE.SEND) { + + return; + } + if (iouType === CONST.IOU.TYPE.REQUEST) { IOU.requestMoney( report, - amount, + backendAmount, transaction.currency, transaction.created, '', @@ -191,10 +198,10 @@ function IOURequestStepAmount({ '', null, ); + return; } - } else { - Navigation.navigate(ROUTES.MONEY_REQUEST_STEP_CONFIRMATION.getRoute(iouType, transactionID, reportID)); } + Navigation.navigate(ROUTES.MONEY_REQUEST_STEP_CONFIRMATION.getRoute(iouType, transactionID, reportID)); return; } @@ -217,6 +224,8 @@ function IOURequestStepAmount({ amount={transaction.amount} skipConfirmation={transaction.skipConfirmation} iouType={iouType} + policyID={policy.policyID} + bankAccountRoute={ReportUtils.getBankAccountRoute(report)} ref={(e) => (textInput.current = e)} onCurrencyButtonPress={navigateToCurrencySelectionPage} onSubmitButtonPress={navigateToNextPage} diff --git a/src/pages/iou/steps/MoneyRequestAmountForm.tsx b/src/pages/iou/steps/MoneyRequestAmountForm.tsx index d9c76c9f02fe..0685273c628f 100644 --- a/src/pages/iou/steps/MoneyRequestAmountForm.tsx +++ b/src/pages/iou/steps/MoneyRequestAmountForm.tsx @@ -20,6 +20,8 @@ import * as MoneyRequestUtils from '@libs/MoneyRequestUtils'; import Navigation from '@libs/Navigation/Navigation'; import type {BaseTextInputRef} from '@src/components/TextInput/BaseTextInput/types'; import CONST from '@src/CONST'; +import SettlementButton from "@components/SettlementButton"; +import ROUTES, {AllRoutes} from "@src/ROUTES"; type MoneyRequestAmountFormProps = { /** IOU amount saved in Onyx */ @@ -40,6 +42,12 @@ type MoneyRequestAmountFormProps = { /** Type of the IOU */ iouType?: ValueOf<typeof CONST.IOU.TYPE>; + /** The policyID of the request */ + policyID?: string; + + /** Depending on expense report or personal IOU report, respective bank account route */ + bankAccountRoute?: AllRoutes; + /** Fired when back button pressed, navigates to currency selection page */ onCurrencyButtonPress: () => void; @@ -79,6 +87,8 @@ function MoneyRequestAmountForm( isEditing = false, skipConfirmation = false, iouType = CONST.IOU.TYPE.REQUEST, + policyID = '', + bankAccountRoute = '', onCurrencyButtonPress, onSubmitButtonPress, selectedTab = CONST.TAB_REQUEST.MANUAL, @@ -248,7 +258,7 @@ function MoneyRequestAmountForm( const backendAmount = CurrencyUtils.convertToBackendAmount(Number.parseFloat(currentAmount)); initializeAmount(backendAmount); - onSubmitButtonPress({amount: currentAmount, currency}); + onSubmitButtonPress({amount: currentAmount, currency, paymentMethod}); }, [onSubmitButtonPress, currentAmount, taxAmount, currency, isTaxAmountForm, formattedTaxAmount, initializeAmount]); /** @@ -334,6 +344,28 @@ function MoneyRequestAmountForm( longPressHandlerStateChanged={updateLongPressHandlerState} /> ) : null} + {iouType === CONST.IOU.TYPE.SEND && skipConfirmation ? ( + <SettlementButton + pressOnEnter + onPress={submitAndNavigateToNextPage} + enablePaymentsRoute={ROUTES.IOU_SEND_ENABLE_PAYMENTS} + addBankAccountRoute={bankAccountRoute} + addDebitCardRoute={ROUTES.IOU_SEND_ADD_DEBIT_CARD} + currency + policyID + buttonSize={CONST.DROPDOWN_BUTTON_SIZE.LARGE} + kycWallAnchorAlignment={{ + horizontal: CONST.MODAL.ANCHOR_ORIGIN_HORIZONTAL.LEFT, + vertical: CONST.MODAL.ANCHOR_ORIGIN_VERTICAL.BOTTOM, + }} + paymentMethodDropdownAnchorAlignment={{ + horizontal: CONST.MODAL.ANCHOR_ORIGIN_HORIZONTAL.RIGHT, + vertical: CONST.MODAL.ANCHOR_ORIGIN_VERTICAL.BOTTOM, + }} + shouldShowPersonalBankAccountOption + enterKeyEventListenerPriority={1} + /> + ) : ( <Button success // Prevent bubbling on edit amount Page to prevent double page submission when two CTA are stacked. @@ -345,6 +377,7 @@ function MoneyRequestAmountForm( onPress={submitAndNavigateToNextPage} text={buttonText} /> + )} </View> </ScrollView> ); From a3845e46022eb79860e2c32620a78157238c84e6 Mon Sep 17 00:00:00 2001 From: Alberto <alberto@expensify.com> Date: Wed, 27 Mar 2024 14:10:15 +0100 Subject: [PATCH 010/206] display correct button for send --- .../sidebar/SidebarScreen/FloatingActionButtonAndPopover.js | 2 +- src/pages/iou/request/step/IOURequestStepAmount.js | 5 ++--- src/pages/iou/steps/MoneyRequestAmountForm.tsx | 6 +++--- 3 files changed, 6 insertions(+), 7 deletions(-) diff --git a/src/pages/home/sidebar/SidebarScreen/FloatingActionButtonAndPopover.js b/src/pages/home/sidebar/SidebarScreen/FloatingActionButtonAndPopover.js index 4b3ace91a5d9..05d840a1016e 100644 --- a/src/pages/home/sidebar/SidebarScreen/FloatingActionButtonAndPopover.js +++ b/src/pages/home/sidebar/SidebarScreen/FloatingActionButtonAndPopover.js @@ -175,7 +175,7 @@ function FloatingActionButtonAndPopover(props) { IOU.startMoneyRequest(CONST.IOU.TYPE.SPLIT, props.quickAction.chatReportID, CONST.IOU.REQUEST_TYPE.DISTANCE, true); return; case CONST.QUICK_ACTIONS.SEND_MONEY: - IOU.startMoneyRequest(CONST.IOU.TYPE.SEND, props.quickAction.chatReportID); + IOU.startMoneyRequest(CONST.IOU.TYPE.SEND, props.quickAction.chatReportID, CONST.IOU.REQUEST_TYPE.MANUAL, true); return; case CONST.QUICK_ACTIONS.ASSIGN_TASK: Task.clearOutTaskInfoAndNavigate(props.quickAction.chatReportID, _.get(props.quickAction, 'targetAccountID', 0)); diff --git a/src/pages/iou/request/step/IOURequestStepAmount.js b/src/pages/iou/request/step/IOURequestStepAmount.js index afea223e1c7c..71d846b80101 100644 --- a/src/pages/iou/request/step/IOURequestStepAmount.js +++ b/src/pages/iou/request/step/IOURequestStepAmount.js @@ -141,9 +141,8 @@ function IOURequestStepAmount({ /** * @param {Number} amount */ - const navigateToNextPage = ({amount, paymentMethod}) => { + const navigateToNextPage = ({amount}) => { isSaveButtonPressed.current = true; - console.log(paymentMethod); const amountInSmallestCurrencyUnits = CurrencyUtils.convertToBackendAmount(Number.parseFloat(amount)); if ((iouRequestType === CONST.IOU.REQUEST_TYPE.MANUAL || backTo) && isTaxTrackingEnabled) { @@ -220,7 +219,7 @@ function IOURequestStepAmount({ > <MoneyRequestAmountForm isEditing={Boolean(backTo)} - currency={currency} + currency={transaction.currency} amount={transaction.amount} skipConfirmation={transaction.skipConfirmation} iouType={iouType} diff --git a/src/pages/iou/steps/MoneyRequestAmountForm.tsx b/src/pages/iou/steps/MoneyRequestAmountForm.tsx index 0685273c628f..174318b368cd 100644 --- a/src/pages/iou/steps/MoneyRequestAmountForm.tsx +++ b/src/pages/iou/steps/MoneyRequestAmountForm.tsx @@ -258,7 +258,7 @@ function MoneyRequestAmountForm( const backendAmount = CurrencyUtils.convertToBackendAmount(Number.parseFloat(currentAmount)); initializeAmount(backendAmount); - onSubmitButtonPress({amount: currentAmount, currency, paymentMethod}); + onSubmitButtonPress({amount: currentAmount, currency}); }, [onSubmitButtonPress, currentAmount, taxAmount, currency, isTaxAmountForm, formattedTaxAmount, initializeAmount]); /** @@ -351,8 +351,8 @@ function MoneyRequestAmountForm( enablePaymentsRoute={ROUTES.IOU_SEND_ENABLE_PAYMENTS} addBankAccountRoute={bankAccountRoute} addDebitCardRoute={ROUTES.IOU_SEND_ADD_DEBIT_CARD} - currency - policyID + currency = {currency ?? CONST.CURRENCY.USD} + policyID = {policyID ?? ''} buttonSize={CONST.DROPDOWN_BUTTON_SIZE.LARGE} kycWallAnchorAlignment={{ horizontal: CONST.MODAL.ANCHOR_ORIGIN_HORIZONTAL.LEFT, From 39e4599b91f0aab3a5c2cb5cc7c03e4c1112f7b5 Mon Sep 17 00:00:00 2001 From: Alberto <alberto@expensify.com> Date: Wed, 27 Mar 2024 16:16:51 +0100 Subject: [PATCH 011/206] pass back payment method --- src/pages/iou/steps/MoneyRequestAmountForm.tsx | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/pages/iou/steps/MoneyRequestAmountForm.tsx b/src/pages/iou/steps/MoneyRequestAmountForm.tsx index 174318b368cd..334709c21c93 100644 --- a/src/pages/iou/steps/MoneyRequestAmountForm.tsx +++ b/src/pages/iou/steps/MoneyRequestAmountForm.tsx @@ -22,6 +22,7 @@ import type {BaseTextInputRef} from '@src/components/TextInput/BaseTextInput/typ import CONST from '@src/CONST'; import SettlementButton from "@components/SettlementButton"; import ROUTES, {AllRoutes} from "@src/ROUTES"; +import paymentMethod from "@src/types/onyx/PaymentMethod"; type MoneyRequestAmountFormProps = { /** IOU amount saved in Onyx */ @@ -52,7 +53,7 @@ type MoneyRequestAmountFormProps = { onCurrencyButtonPress: () => void; /** Fired when submit button pressed, saves the given amount and navigates to the next page */ - onSubmitButtonPress: ({amount, currency}: {amount: string; currency: string}) => void; + onSubmitButtonPress: ({amount, currency, paymentMethod}: {amount: string; currency: string; paymentMethod: string}) => void; /** The current tab we have navigated to in the request modal. String that corresponds to the request type. */ selectedTab?: ValueOf<typeof CONST.TAB_REQUEST>; @@ -242,7 +243,7 @@ function MoneyRequestAmountForm( /** * Submit amount and navigate to a proper page */ - const submitAndNavigateToNextPage = useCallback(() => { + const submitAndNavigateToNextPage = useCallback((iouPaymentType) => { if (isAmountInvalid(currentAmount)) { setFormError('iou.error.invalidAmount'); return; @@ -258,7 +259,7 @@ function MoneyRequestAmountForm( const backendAmount = CurrencyUtils.convertToBackendAmount(Number.parseFloat(currentAmount)); initializeAmount(backendAmount); - onSubmitButtonPress({amount: currentAmount, currency}); + onSubmitButtonPress({amount: currentAmount, paymentMethod: iouPaymentType}); }, [onSubmitButtonPress, currentAmount, taxAmount, currency, isTaxAmountForm, formattedTaxAmount, initializeAmount]); /** From cd8ee1d1755f6a7667bc77c31549c019b6611e88 Mon Sep 17 00:00:00 2001 From: Alberto <alberto@expensify.com> Date: Wed, 27 Mar 2024 16:21:25 +0100 Subject: [PATCH 012/206] wrap up send money --- src/pages/iou/request/step/IOURequestStepAmount.js | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/pages/iou/request/step/IOURequestStepAmount.js b/src/pages/iou/request/step/IOURequestStepAmount.js index 71d846b80101..bb6449805486 100644 --- a/src/pages/iou/request/step/IOURequestStepAmount.js +++ b/src/pages/iou/request/step/IOURequestStepAmount.js @@ -141,7 +141,7 @@ function IOURequestStepAmount({ /** * @param {Number} amount */ - const navigateToNextPage = ({amount}) => { + const navigateToNextPage = ({amount, paymentMethod}) => { isSaveButtonPressed.current = true; const amountInSmallestCurrencyUnits = CurrencyUtils.convertToBackendAmount(Number.parseFloat(amount)); @@ -181,7 +181,12 @@ function IOURequestStepAmount({ return; } if (iouType === CONST.IOU.TYPE.SEND) { - + if (paymentMethod && paymentMethod === CONST.IOU.PAYMENT_TYPE.EXPENSIFY) { + IOU.sendMoneyWithWallet(report, backendAmount, transaction.currency, '', currentUserPersonalDetails.accountID, selectedParticipants[0]); + return; + } + + IOU.sendMoneyElsewhere(report, backendAmount, transaction.currency, '', currentUserPersonalDetails.accountID, selectedParticipants[0]); return; } if (iouType === CONST.IOU.TYPE.REQUEST) { From ca6d0ed07734eaafb8eebcf5ff009acc492541d7 Mon Sep 17 00:00:00 2001 From: Alberto <alberto@expensify.com> Date: Wed, 27 Mar 2024 17:16:05 +0100 Subject: [PATCH 013/206] fix split --- .../iou/request/step/IOURequestStepAmount.js | 39 +++++++++---------- 1 file changed, 19 insertions(+), 20 deletions(-) diff --git a/src/pages/iou/request/step/IOURequestStepAmount.js b/src/pages/iou/request/step/IOURequestStepAmount.js index bb6449805486..70afac0d9477 100644 --- a/src/pages/iou/request/step/IOURequestStepAmount.js +++ b/src/pages/iou/request/step/IOURequestStepAmount.js @@ -1,6 +1,7 @@ import {useFocusEffect} from '@react-navigation/native'; import lodashGet from 'lodash/get'; import PropTypes from 'prop-types'; +import _ from 'underscore'; import React, {useCallback, useEffect, useRef} from 'react'; import {withOnyx} from 'react-native-onyx'; import taxPropTypes from '@components/taxPropTypes'; @@ -26,8 +27,8 @@ import { withCurrentUserPersonalDetailsDefaultProps, withCurrentUserPersonalDetailsPropTypes } from "@components/withCurrentUserPersonalDetails"; -import tagPropTypes from "@components/tagPropTypes"; -import categoryPropTypes from "@components/categoryPropTypes"; +import * as OptionsListUtils from "@libs/OptionsListUtils"; +import personalDetailsPropType from "@pages/personalDetailsPropType"; const propTypes = { /** Navigation route context info provided by react navigation */ @@ -58,9 +59,8 @@ const propTypes = { taxRates: taxPropTypes, }), - policyTags: tagPropTypes, - - policyCategories: PropTypes.objectOf(categoryPropTypes), + /** Personal details of all users */ + personalDetails: personalDetailsPropType, ...withCurrentUserPersonalDetailsPropTypes, }; @@ -69,8 +69,7 @@ const defaultProps = { report: {}, transaction: {}, policy: {}, - policyCategories: {}, - policyTags: {}, + personalDetails: {}, ...withCurrentUserPersonalDetailsDefaultProps, }; @@ -87,8 +86,7 @@ function IOURequestStepAmount({ transaction, transaction: {currency}, policy, - policyCategories, - policyTags, + personalDetails, currentUserPersonalDetails, }) { const {translate} = useLocalize(); @@ -163,12 +161,16 @@ function IOURequestStepAmount({ // to the confirm step. if (report.reportID) { const selectedParticipants = IOU.setMoneyRequestParticipantsFromReport(transactionID, report); + const participants = _.map(selectedParticipants, (participant) => { + const participantAccountID = lodashGet(participant, 'accountID', 0); + return participantAccountID ? OptionsListUtils.getParticipantsOption(participant, personalDetails) : OptionsListUtils.getReportOption(participant); + }); const backendAmount = CurrencyUtils.convertToBackendAmount(Number.parseFloat(amount)); if (transaction.skipConfirmation) { if (iouType === CONST.IOU.TYPE.SPLIT) { IOU.splitBillAndOpenReport( - selectedParticipants, + participants, currentUserPersonalDetails.login, currentUserPersonalDetails.accountID, backendAmount, @@ -182,11 +184,11 @@ function IOURequestStepAmount({ } if (iouType === CONST.IOU.TYPE.SEND) { if (paymentMethod && paymentMethod === CONST.IOU.PAYMENT_TYPE.EXPENSIFY) { - IOU.sendMoneyWithWallet(report, backendAmount, transaction.currency, '', currentUserPersonalDetails.accountID, selectedParticipants[0]); + IOU.sendMoneyWithWallet(report, backendAmount, transaction.currency, '', currentUserPersonalDetails.accountID, participants[0]); return; } - - IOU.sendMoneyElsewhere(report, backendAmount, transaction.currency, '', currentUserPersonalDetails.accountID, selectedParticipants[0]); + + IOU.sendMoneyElsewhere(report, backendAmount, transaction.currency, '', currentUserPersonalDetails.accountID, participants[0]); return; } if (iouType === CONST.IOU.TYPE.REQUEST) { @@ -198,7 +200,7 @@ function IOURequestStepAmount({ '', currentUserPersonalDetails.login, currentUserPersonalDetails.accountID, - selectedParticipants[0], + participants[0], '', null, ); @@ -247,14 +249,11 @@ export default compose( withWritableReportOrNotFound, withFullTransactionOrNotFound, withOnyx({ + personalDetails: { + key: ONYXKEYS.PERSONAL_DETAILS_LIST, + }, policy: { key: ({report}) => `${ONYXKEYS.COLLECTION.POLICY}${report ? report.policyID : '0'}`, }, - policyCategories: { - key: ({report}) => `${ONYXKEYS.COLLECTION.POLICY_CATEGORIES}${report ? report.policyID : '0'}`, - }, - policyTags: { - key: ({report}) => `${ONYXKEYS.COLLECTION.POLICY_TAGS}${report ? report.policyID : '0'}`, - }, }), )(IOURequestStepAmount); From c5bafb296a3074bb6518ea53b0820a912aa703d0 Mon Sep 17 00:00:00 2001 From: Alberto <alberto@expensify.com> Date: Thu, 28 Mar 2024 14:47:46 +0100 Subject: [PATCH 014/206] changing branches --- src/pages/iou/request/step/IOURequestStepAmount.js | 5 +++-- src/pages/iou/request/step/IOURequestStepDistance.js | 2 ++ 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/src/pages/iou/request/step/IOURequestStepAmount.js b/src/pages/iou/request/step/IOURequestStepAmount.js index 70afac0d9477..ee514e5485b9 100644 --- a/src/pages/iou/request/step/IOURequestStepAmount.js +++ b/src/pages/iou/request/step/IOURequestStepAmount.js @@ -99,6 +99,7 @@ function IOURequestStepAmount({ const taxRates = lodashGet(policy, 'taxRates', {}); const isPolicyExpenseChat = ReportUtils.isPolicyExpenseChat(ReportUtils.getRootParentReport(report)); const isTaxTrackingEnabled = isPolicyExpenseChat && lodashGet(policy, 'tax.trackingEnabled', policy.isTaxTrackingEnabled); + const skipConfirmation = transaction.skipConfirmation && !ReportUtils.isArchivedRoom(report); useFocusEffect( useCallback(() => { @@ -167,7 +168,7 @@ function IOURequestStepAmount({ }); const backendAmount = CurrencyUtils.convertToBackendAmount(Number.parseFloat(amount)); - if (transaction.skipConfirmation) { + if (skipConfirmation) { if (iouType === CONST.IOU.TYPE.SPLIT) { IOU.splitBillAndOpenReport( participants, @@ -228,7 +229,7 @@ function IOURequestStepAmount({ isEditing={Boolean(backTo)} currency={transaction.currency} amount={transaction.amount} - skipConfirmation={transaction.skipConfirmation} + skipConfirmation={skipConfirmation} iouType={iouType} policyID={policy.policyID} bankAccountRoute={ReportUtils.getBankAccountRoute(report)} diff --git a/src/pages/iou/request/step/IOURequestStepDistance.js b/src/pages/iou/request/step/IOURequestStepDistance.js index dad610cbc636..228e5480693a 100644 --- a/src/pages/iou/request/step/IOURequestStepDistance.js +++ b/src/pages/iou/request/step/IOURequestStepDistance.js @@ -29,6 +29,7 @@ import IOURequestStepRoutePropTypes from './IOURequestStepRoutePropTypes'; import StepScreenWrapper from './StepScreenWrapper'; import withFullTransactionOrNotFound from './withFullTransactionOrNotFound'; import withWritableReportOrNotFound from './withWritableReportOrNotFound'; +import * as ReportUtils from "@libs/ReportUtils"; const propTypes = { /** Navigation route context info provided by react navigation */ @@ -85,6 +86,7 @@ function IOURequestStepDistance({ const atLeastTwoDifferentWaypointsError = useMemo(() => _.size(validatedWaypoints) < 2, [validatedWaypoints]); const isEditing = action === CONST.IOU.ACTION.EDIT; const isCreatingNewRequest = Navigation.getActiveRoute().includes('start'); + const skipConfirmation = transaction.skipConfirmation && !ReportUtils.isArchivedRoom(report); useEffect(() => { MapboxToken.init(); From fea5996e82377084ba8954fe64915454ec452f3a Mon Sep 17 00:00:00 2001 From: Alberto <alberto@expensify.com> Date: Mon, 1 Apr 2024 13:26:30 +0200 Subject: [PATCH 015/206] remove console --- src/pages/iou/steps/NewRequestAmountPage.tsx | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/pages/iou/steps/NewRequestAmountPage.tsx b/src/pages/iou/steps/NewRequestAmountPage.tsx index 7fb9975572a9..c3d5c93d4b18 100644 --- a/src/pages/iou/steps/NewRequestAmountPage.tsx +++ b/src/pages/iou/steps/NewRequestAmountPage.tsx @@ -137,8 +137,6 @@ function NewRequestAmountPage({route, iou, report, selectedTab}: NewRequestAmoun selectedTab={selectedTab ?? CONST.TAB_REQUEST.MANUAL} /> ); - console.log(iou); - console.log(iouType); // ScreenWrapper is only needed in edit mode because we have a dedicated route for the edit amount page (MoneyRequestEditAmountPage). // The rest of the cases this component is rendered through <MoneyRequestSelectorPage /> which has it's own ScreenWrapper From 2320f0aba253310f7f0d16ed9218b0d3fa915626 Mon Sep 17 00:00:00 2001 From: Alberto <alberto@expensify.com> Date: Mon, 1 Apr 2024 17:59:59 +0200 Subject: [PATCH 016/206] handle distance requests --- src/libs/actions/IOU.ts | 6 ++-- .../request/step/IOURequestStepDistance.js | 31 +++++++++++++++++-- 2 files changed, 32 insertions(+), 5 deletions(-) diff --git a/src/libs/actions/IOU.ts b/src/libs/actions/IOU.ts index c2fb3d388780..1ccab026c30a 100644 --- a/src/libs/actions/IOU.ts +++ b/src/libs/actions/IOU.ts @@ -1353,9 +1353,9 @@ function createDistanceRequest( merchant: string, billable: boolean | undefined, validWaypoints: WaypointCollection, - policy: OnyxEntry<OnyxTypes.Policy>, - policyTagList: OnyxEntry<OnyxTypes.PolicyTagList>, - policyCategories: OnyxEntry<OnyxTypes.PolicyCategories>, + policy?: OnyxEntry<OnyxTypes.Policy>, + policyTagList?: OnyxEntry<OnyxTypes.PolicyTagList>, + policyCategories?: OnyxEntry<OnyxTypes.PolicyCategories>, ) { // If the report is an iou or expense report, we should get the linked chat report to be passed to the getMoneyRequestInformation function const isMoneyRequestReport = ReportUtils.isMoneyRequestReport(report); diff --git a/src/pages/iou/request/step/IOURequestStepDistance.js b/src/pages/iou/request/step/IOURequestStepDistance.js index 85d96395612a..b7cecd6294b3 100644 --- a/src/pages/iou/request/step/IOURequestStepDistance.js +++ b/src/pages/iou/request/step/IOURequestStepDistance.js @@ -30,6 +30,8 @@ import StepScreenWrapper from './StepScreenWrapper'; import withFullTransactionOrNotFound from './withFullTransactionOrNotFound'; import withWritableReportOrNotFound from './withWritableReportOrNotFound'; import * as ReportUtils from "@libs/ReportUtils"; +import DistanceRequestUtils from "@libs/DistanceRequestUtils"; +import * as OptionsListUtils from "@libs/OptionsListUtils"; const propTypes = { /** Navigation route context info provided by react navigation */ @@ -87,6 +89,10 @@ function IOURequestStepDistance({ const isEditing = action === CONST.IOU.ACTION.EDIT; const isCreatingNewRequest = !(backTo || isEditing); const skipConfirmation = transaction.skipConfirmation && !ReportUtils.isArchivedRoom(report); + let buttonText = !isCreatingNewRequest ? translate('common.save') : translate('common.next'); + if (skipConfirmation) { + buttonText = iouType === CONST.IOU.TYPE.SPLIT ? translate('iou.split') : translate('iou.request'); + } useEffect(() => { MapboxToken.init(); @@ -136,7 +142,28 @@ function IOURequestStepDistance({ // inside a report. In this case, the participants can be automatically assigned from the report and the user can skip the participants step and go straight // to the confirm step. if (report.reportID) { - IOU.setMoneyRequestParticipantsFromReport(transactionID, report); + const selectedParticipants = IOU.setMoneyRequestParticipantsFromReport(transactionID, report); + const participants = _.map(selectedParticipants, (participant) => { + const participantAccountID = lodashGet(participant, 'accountID', 0); + return participantAccountID ? OptionsListUtils.getParticipantsOption(participant, personalDetails) : OptionsListUtils.getReportOption(participant); + }); + if (skipConfirmation) { + IOU.setMoneyRequestPendingFields(transactionID, {waypoints: CONST.RED_BRICK_ROAD_PENDING_ACTION.ADD}); + IOU.setMoneyRequestMerchant(transactionID, translate('iou.routePending'), false); + IOU.createDistanceRequest( + report, + participants[0], + '', + transaction.created, + '', + '', + 0, + transaction.currency || 'USD', + '', + false, + TransactionUtils.getValidWaypoints(transaction.comment.waypoints, true), + ); + } Navigation.navigate(ROUTES.MONEY_REQUEST_STEP_CONFIRMATION.getRoute(iouType, transactionID, reportID)); return; } @@ -276,7 +303,7 @@ function IOURequestStepDistance({ large style={[styles.w100, styles.mb4, styles.ph4, styles.flexShrink0]} onPress={submitWaypoints} - text={translate(!isCreatingNewRequest ? 'common.save' : 'common.next')} + text={buttonText} isLoading={!isOffline && (isLoadingRoute || shouldFetchRoute || isLoading)} /> </View> From 0ca38547ec07944b2007bb080747ad69316868e8 Mon Sep 17 00:00:00 2001 From: Alberto <alberto@expensify.com> Date: Mon, 1 Apr 2024 18:18:03 +0200 Subject: [PATCH 017/206] make distance work --- .../iou/request/step/IOURequestStepDistance.js | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/src/pages/iou/request/step/IOURequestStepDistance.js b/src/pages/iou/request/step/IOURequestStepDistance.js index b7cecd6294b3..dd72c360560d 100644 --- a/src/pages/iou/request/step/IOURequestStepDistance.js +++ b/src/pages/iou/request/step/IOURequestStepDistance.js @@ -32,6 +32,7 @@ import withWritableReportOrNotFound from './withWritableReportOrNotFound'; import * as ReportUtils from "@libs/ReportUtils"; import DistanceRequestUtils from "@libs/DistanceRequestUtils"; import * as OptionsListUtils from "@libs/OptionsListUtils"; +import personalDetailsPropType from "@pages/personalDetailsPropType"; const propTypes = { /** Navigation route context info provided by react navigation */ @@ -46,12 +47,16 @@ const propTypes = { /** backup version of the original transaction */ transactionBackup: transactionPropTypes, + + /** Personal details of all users */ + personalDetails: personalDetailsPropType, }; const defaultProps = { report: {}, transaction: {}, transactionBackup: {}, + personalDetails: {}, }; function IOURequestStepDistance({ @@ -61,6 +66,7 @@ function IOURequestStepDistance({ }, transaction, transactionBackup, + personalDetails, }) { const styles = useThemeStyles(); const {isOffline} = useNetwork(); @@ -158,11 +164,12 @@ function IOURequestStepDistance({ '', '', 0, - transaction.currency || 'USD', - '', + transaction.currency, + translate('iou.routePending'), false, - TransactionUtils.getValidWaypoints(transaction.comment.waypoints, true), + TransactionUtils.getValidWaypoints(waypoints, true), ); + return; } Navigation.navigate(ROUTES.MONEY_REQUEST_STEP_CONFIRMATION.getRoute(iouType, transactionID, reportID)); return; @@ -171,7 +178,7 @@ function IOURequestStepDistance({ // If there was no reportID, then that means the user started this flow from the global + menu // and an optimistic reportID was generated. In that case, the next step is to select the participants for this request. Navigation.navigate(ROUTES.MONEY_REQUEST_STEP_PARTICIPANTS.getRoute(iouType, transactionID, reportID)); - }, [report, iouType, reportID, transactionID, backTo]); + }, [report, iouType, reportID, transactionID, backTo, waypoints]); const getError = () => { // Get route error if available else show the invalid number of waypoints error. @@ -320,6 +327,9 @@ export default compose( withWritableReportOrNotFound, withFullTransactionOrNotFound, withOnyx({ + personalDetails: { + key: ONYXKEYS.PERSONAL_DETAILS_LIST, + }, transactionBackup: { key: (props) => `${ONYXKEYS.COLLECTION.TRANSACTION_DRAFT}${props.transactionID}`, }, From 5c7728babc8477b0006a90bb3838c3ff215d9012 Mon Sep 17 00:00:00 2001 From: Alberto <alberto@expensify.com> Date: Mon, 1 Apr 2024 18:42:14 +0200 Subject: [PATCH 018/206] handle splits --- .../iou/request/step/IOURequestStepAmount.js | 3 ++- .../step/IOURequestStepConfirmation.js | 2 ++ .../request/step/IOURequestStepDistance.js | 20 +++++++++++++++++++ 3 files changed, 24 insertions(+), 1 deletion(-) diff --git a/src/pages/iou/request/step/IOURequestStepAmount.js b/src/pages/iou/request/step/IOURequestStepAmount.js index ee514e5485b9..da3715d2c837 100644 --- a/src/pages/iou/request/step/IOURequestStepAmount.js +++ b/src/pages/iou/request/step/IOURequestStepAmount.js @@ -23,7 +23,7 @@ import IOURequestStepRoutePropTypes from './IOURequestStepRoutePropTypes'; import StepScreenWrapper from './StepScreenWrapper'; import withFullTransactionOrNotFound from './withFullTransactionOrNotFound'; import withWritableReportOrNotFound from './withWritableReportOrNotFound'; -import { +import withCurrentUserPersonalDetails, { withCurrentUserPersonalDetailsDefaultProps, withCurrentUserPersonalDetailsPropTypes } from "@components/withCurrentUserPersonalDetails"; @@ -247,6 +247,7 @@ IOURequestStepAmount.defaultProps = defaultProps; IOURequestStepAmount.displayName = 'IOURequestStepAmount'; export default compose( + withCurrentUserPersonalDetails, withWritableReportOrNotFound, withFullTransactionOrNotFound, withOnyx({ diff --git a/src/pages/iou/request/step/IOURequestStepConfirmation.js b/src/pages/iou/request/step/IOURequestStepConfirmation.js index 435121a76028..ed0f1a0bc865 100644 --- a/src/pages/iou/request/step/IOURequestStepConfirmation.js +++ b/src/pages/iou/request/step/IOURequestStepConfirmation.js @@ -309,6 +309,7 @@ function IOURequestStepConfirmation({ // If we have a receipt let's start the split bill by creating only the action, the transaction, and the group DM if needed if (iouType === CONST.IOU.TYPE.SPLIT && receiptFile) { + console.log('there'); IOU.startSplitBill( selectedParticipants, currentUserPersonalDetails.login, @@ -430,6 +431,7 @@ function IOURequestStepConfirmation({ } if (requestType === CONST.IOU.REQUEST_TYPE.DISTANCE) { + console.log('here'); createDistanceRequest(selectedParticipants, trimmedComment); return; } diff --git a/src/pages/iou/request/step/IOURequestStepDistance.js b/src/pages/iou/request/step/IOURequestStepDistance.js index dd72c360560d..4da6e105b3d3 100644 --- a/src/pages/iou/request/step/IOURequestStepDistance.js +++ b/src/pages/iou/request/step/IOURequestStepDistance.js @@ -33,6 +33,7 @@ import * as ReportUtils from "@libs/ReportUtils"; import DistanceRequestUtils from "@libs/DistanceRequestUtils"; import * as OptionsListUtils from "@libs/OptionsListUtils"; import personalDetailsPropType from "@pages/personalDetailsPropType"; +import withCurrentUserPersonalDetails, {withCurrentUserPersonalDetailsDefaultProps} from "@components/withCurrentUserPersonalDetails"; const propTypes = { /** Navigation route context info provided by react navigation */ @@ -50,6 +51,8 @@ const propTypes = { /** Personal details of all users */ personalDetails: personalDetailsPropType, + + ...withCurrentUserPersonalDetailsDefaultProps, }; const defaultProps = { @@ -57,6 +60,7 @@ const defaultProps = { transaction: {}, transactionBackup: {}, personalDetails: {}, + ...withCurrentUserPersonalDetailsDefaultProps, }; function IOURequestStepDistance({ @@ -67,6 +71,7 @@ function IOURequestStepDistance({ transaction, transactionBackup, personalDetails, + currentUserPersonalDetails, }) { const styles = useThemeStyles(); const {isOffline} = useNetwork(); @@ -154,6 +159,20 @@ function IOURequestStepDistance({ return participantAccountID ? OptionsListUtils.getParticipantsOption(participant, personalDetails) : OptionsListUtils.getReportOption(participant); }); if (skipConfirmation) { + if (iouType === CONST.IOU.TYPE.SPLIT) { + IOU.splitBillAndOpenReport( + participants, + currentUserPersonalDetails.login, + currentUserPersonalDetails.accountID, + 0, + '', + transaction.currency, + translate('iou.routePending'), + transaction.created, + '', + ); + return; + } IOU.setMoneyRequestPendingFields(transactionID, {waypoints: CONST.RED_BRICK_ROAD_PENDING_ACTION.ADD}); IOU.setMoneyRequestMerchant(transactionID, translate('iou.routePending'), false); IOU.createDistanceRequest( @@ -324,6 +343,7 @@ IOURequestStepDistance.propTypes = propTypes; IOURequestStepDistance.defaultProps = defaultProps; export default compose( + withCurrentUserPersonalDetails, withWritableReportOrNotFound, withFullTransactionOrNotFound, withOnyx({ From 3d129414b08249aa5fd41817ce789cb091b2c450 Mon Sep 17 00:00:00 2001 From: tienifr <christianwen18@gmail.com> Date: Tue, 2 Apr 2024 17:33:58 +0700 Subject: [PATCH 019/206] block executing assignee and mark as complete at the same time --- src/components/TaskHeaderActionButton.tsx | 17 ++- src/pages/home/ReportScreen.tsx | 151 +++++++++++----------- 2 files changed, 91 insertions(+), 77 deletions(-) diff --git a/src/components/TaskHeaderActionButton.tsx b/src/components/TaskHeaderActionButton.tsx index 2d964f58c253..1a614faf6df5 100644 --- a/src/components/TaskHeaderActionButton.tsx +++ b/src/components/TaskHeaderActionButton.tsx @@ -1,4 +1,4 @@ -import React from 'react'; +import React, {useContext} from 'react'; import {View} from 'react-native'; import type {OnyxEntry} from 'react-native-onyx'; import {withOnyx} from 'react-native-onyx'; @@ -10,6 +10,7 @@ import * as Task from '@userActions/Task'; import ONYXKEYS from '@src/ONYXKEYS'; import type * as OnyxTypes from '@src/types/onyx'; import Button from './Button'; +import {MenuItemGroupContext} from './MenuItemGroup'; type TaskHeaderActionButtonOnyxProps = { /** Current user session */ @@ -24,15 +25,25 @@ type TaskHeaderActionButtonProps = TaskHeaderActionButtonOnyxProps & { function TaskHeaderActionButton({report, session}: TaskHeaderActionButtonProps) { const {translate} = useLocalize(); const styles = useThemeStyles(); + const {isExecuting, singleExecution, waitForNavigate} = useContext(MenuItemGroupContext) ?? {}; + + const onPressAction = () => { + const onPress = () => (ReportUtils.isCompletedTaskReport(report) ? Task.reopenTask(report) : Task.completeTask(report)); + if (!singleExecution || !waitForNavigate) { + onPress(); + return; + } + singleExecution(waitForNavigate(onPress))(); + }; return ( <View style={[styles.flexRow, styles.alignItemsCenter, styles.justifyContentEnd]}> <Button success - isDisabled={!Task.canModifyTask(report, session?.accountID ?? 0)} + isDisabled={!Task.canModifyTask(report, session?.accountID ?? 0) || isExecuting} medium text={translate(ReportUtils.isCompletedTaskReport(report) ? 'task.markAsIncomplete' : 'task.markAsComplete')} - onPress={Session.checkIfActionIsAllowed(() => (ReportUtils.isCompletedTaskReport(report) ? Task.reopenTask(report) : Task.completeTask(report)))} + onPress={Session.checkIfActionIsAllowed(onPressAction)} style={styles.flex1} /> </View> diff --git a/src/pages/home/ReportScreen.tsx b/src/pages/home/ReportScreen.tsx index 152b02366227..69f9ee071bff 100644 --- a/src/pages/home/ReportScreen.tsx +++ b/src/pages/home/ReportScreen.tsx @@ -12,6 +12,7 @@ import BlockingView from '@components/BlockingViews/BlockingView'; import FullPageNotFoundView from '@components/BlockingViews/FullPageNotFoundView'; import DragAndDropProvider from '@components/DragAndDrop/Provider'; import * as Illustrations from '@components/Icon/Illustrations'; +import MenuItemGroup from '@components/MenuItemGroup'; import MoneyReportHeader from '@components/MoneyReportHeader'; import MoneyRequestHeader from '@components/MoneyRequestHeader'; import OfflineWithFeedback from '@components/OfflineWithFeedback'; @@ -600,85 +601,87 @@ function ReportScreen({ return ( <ActionListContext.Provider value={actionListValue}> <ReactionListContext.Provider value={reactionListRef}> - <ScreenWrapper - navigation={navigation} - style={screenWrapperStyle} - shouldEnableKeyboardAvoidingView={isTopMostReportId} - testID={ReportScreen.displayName} - > - <FullPageNotFoundView - shouldShow={shouldShowNotFoundPage} - subtitleKey="notFound.noAccess" - shouldShowBackButton={isSmallScreenWidth} - onBackButtonPress={Navigation.goBack} - shouldShowLink={false} + <MenuItemGroup> + <ScreenWrapper + navigation={navigation} + style={screenWrapperStyle} + shouldEnableKeyboardAvoidingView={isTopMostReportId} + testID={ReportScreen.displayName} > - <OfflineWithFeedback - pendingAction={reportPendingAction} - errors={reportErrors} - shouldShowErrorMessages={false} - needsOffscreenAlphaCompositing + <FullPageNotFoundView + shouldShow={shouldShowNotFoundPage} + subtitleKey="notFound.noAccess" + shouldShowBackButton={isSmallScreenWidth} + onBackButtonPress={Navigation.goBack} + shouldShowLink={false} > - {headerView} - {ReportUtils.isTaskReport(report) && isSmallScreenWidth && ReportUtils.isOpenTaskReport(report, parentReportAction) && ( - <View style={[styles.borderBottom]}> - <View style={[styles.appBG, styles.pl0]}> - <View style={[styles.ph5, styles.pb3]}> - <TaskHeaderActionButton report={report} /> + <OfflineWithFeedback + pendingAction={reportPendingAction} + errors={reportErrors} + shouldShowErrorMessages={false} + needsOffscreenAlphaCompositing + > + {headerView} + {ReportUtils.isTaskReport(report) && isSmallScreenWidth && ReportUtils.isOpenTaskReport(report, parentReportAction) && ( + <View style={[styles.borderBottom]}> + <View style={[styles.appBG, styles.pl0]}> + <View style={[styles.ph5, styles.pb3]}> + <TaskHeaderActionButton report={report} /> + </View> </View> </View> - </View> - )} - </OfflineWithFeedback> - {!!accountManagerReportID && ReportUtils.isConciergeChatReport(report) && isBannerVisible && ( - <Banner - containerStyles={[styles.mh4, styles.mt4, styles.p4, styles.bgDark]} - textStyles={[styles.colorReversed]} - text={translate('reportActionsView.chatWithAccountManager')} - onClose={dismissBanner} - onPress={chatWithAccountManager} - shouldShowCloseButton - /> - )} - <DragAndDropProvider isDisabled={!isCurrentReportLoadedFromOnyx || !ReportUtils.canUserPerformWriteAction(report)}> - <View - style={[styles.flex1, styles.justifyContentEnd, styles.overflowHidden]} - onLayout={onListLayout} - > - {shouldShowReportActionList && ( - <ReportActionsView - reportActions={reportActions} - report={report} - parentReportAction={parentReportAction} - isLoadingInitialReportActions={reportMetadata?.isLoadingInitialReportActions} - isLoadingNewerReportActions={reportMetadata?.isLoadingNewerReportActions} - isLoadingOlderReportActions={reportMetadata?.isLoadingOlderReportActions} - isReadyForCommentLinking={!shouldShowSkeleton} - transactionThreadReportID={ReportActionsUtils.getOneTransactionThreadReportID(reportActions ?? [])} - /> )} - - {/* Note: The ReportActionsSkeletonView should be allowed to mount even if the initial report actions are not loaded. - If we prevent rendering the report while they are loading then - we'll unnecessarily unmount the ReportActionsView which will clear the new marker lines initial state. */} - {shouldShowSkeleton && <ReportActionsSkeletonView />} - - {isCurrentReportLoadedFromOnyx ? ( - <ReportFooter - onComposerFocus={() => setIsComposerFocus(true)} - onComposerBlur={() => setIsComposerFocus(false)} - report={report} - pendingAction={reportPendingAction} - isComposerFullSize={!!isComposerFullSize} - listHeight={listHeight} - isEmptyChat={isEmptyChat} - lastReportAction={lastReportAction} - /> - ) : null} - </View> - </DragAndDropProvider> - </FullPageNotFoundView> - </ScreenWrapper> + </OfflineWithFeedback> + {!!accountManagerReportID && ReportUtils.isConciergeChatReport(report) && isBannerVisible && ( + <Banner + containerStyles={[styles.mh4, styles.mt4, styles.p4, styles.bgDark]} + textStyles={[styles.colorReversed]} + text={translate('reportActionsView.chatWithAccountManager')} + onClose={dismissBanner} + onPress={chatWithAccountManager} + shouldShowCloseButton + /> + )} + <DragAndDropProvider isDisabled={!isCurrentReportLoadedFromOnyx || !ReportUtils.canUserPerformWriteAction(report)}> + <View + style={[styles.flex1, styles.justifyContentEnd, styles.overflowHidden]} + onLayout={onListLayout} + > + {shouldShowReportActionList && ( + <ReportActionsView + reportActions={reportActions} + report={report} + parentReportAction={parentReportAction} + isLoadingInitialReportActions={reportMetadata?.isLoadingInitialReportActions} + isLoadingNewerReportActions={reportMetadata?.isLoadingNewerReportActions} + isLoadingOlderReportActions={reportMetadata?.isLoadingOlderReportActions} + isReadyForCommentLinking={!shouldShowSkeleton} + transactionThreadReportID={ReportActionsUtils.getOneTransactionThreadReportID(reportActions ?? [])} + /> + )} + + {/* Note: The ReportActionsSkeletonView should be allowed to mount even if the initial report actions are not loaded. + If we prevent rendering the report while they are loading then + we'll unnecessarily unmount the ReportActionsView which will clear the new marker lines initial state. */} + {shouldShowSkeleton && <ReportActionsSkeletonView />} + + {isCurrentReportLoadedFromOnyx ? ( + <ReportFooter + onComposerFocus={() => setIsComposerFocus(true)} + onComposerBlur={() => setIsComposerFocus(false)} + report={report} + pendingAction={reportPendingAction} + isComposerFullSize={!!isComposerFullSize} + listHeight={listHeight} + isEmptyChat={isEmptyChat} + lastReportAction={lastReportAction} + /> + ) : null} + </View> + </DragAndDropProvider> + </FullPageNotFoundView> + </ScreenWrapper> + </MenuItemGroup> </ReactionListContext.Provider> </ActionListContext.Provider> ); From d0bd498ffee79797805f3587183340c6aa6e3002 Mon Sep 17 00:00:00 2001 From: Alberto <alberto@expensify.com> Date: Tue, 2 Apr 2024 13:25:53 +0200 Subject: [PATCH 020/206] add params for receipt --- .../request/step/IOURequestStepScan/index.js | 60 ++++++++++++++++++- 1 file changed, 59 insertions(+), 1 deletion(-) diff --git a/src/pages/iou/request/step/IOURequestStepScan/index.js b/src/pages/iou/request/step/IOURequestStepScan/index.js index 49c5f0a782fc..9c0ddffbf156 100644 --- a/src/pages/iou/request/step/IOURequestStepScan/index.js +++ b/src/pages/iou/request/step/IOURequestStepScan/index.js @@ -34,6 +34,13 @@ import * as IOU from '@userActions/IOU'; import CONST from '@src/CONST'; import ROUTES from '@src/ROUTES'; import NavigationAwareCamera from './NavigationAwareCamera'; +import * as ReportUtils from "@libs/ReportUtils"; +import withCurrentUserPersonalDetails, { + withCurrentUserPersonalDetailsDefaultProps, withCurrentUserPersonalDetailsPropTypes +} from "@components/withCurrentUserPersonalDetails"; +import personalDetailsPropType from "@pages/personalDetailsPropType"; +import {withOnyx} from "react-native-onyx"; +import ONYXKEYS from "@src/ONYXKEYS"; const propTypes = { /** Navigation route context info provided by react navigation */ @@ -45,11 +52,19 @@ const propTypes = { /** The transaction (or draft transaction) being changed */ transaction: transactionPropTypes, + + /** Personal details of all users */ + personalDetails: personalDetailsPropType, + + /** The personal details of the current user */ + ...withCurrentUserPersonalDetailsPropTypes, }; const defaultProps = { report: {}, transaction: {}, + personalDetails: {}, + ...withCurrentUserPersonalDetailsDefaultProps, }; function IOURequestStepScan({ @@ -57,7 +72,10 @@ function IOURequestStepScan({ route: { params: {action, iouType, reportID, transactionID, backTo}, }, + transaction, transaction: {isFromGlobalCreate}, + personalDetails, + currentUserPersonalDetails, }) { const theme = useTheme(); const styles = useThemeStyles(); @@ -84,6 +102,7 @@ function IOURequestStepScan({ const [videoConstraints, setVideoConstraints] = useState(null); const tabIndex = 1; const isTabActive = useTabNavigatorFocus({tabIndex}); + const skipConfirmation = transaction.skipConfirmation && !ReportUtils.isArchivedRoom(report); /** * On phones that have ultra-wide lens, react-webcam uses ultra-wide by default. @@ -238,6 +257,36 @@ function IOURequestStepScan({ const source = URL.createObjectURL(file); IOU.setMoneyRequestReceipt(transactionID, source, file.name, action !== CONST.IOU.ACTION.EDIT); + if (skipConfirmation) { + if (iouType === CONST.IOU.TYPE.SPLIT) { + IOU.splitBillAndOpenReport( + participants, + currentUserPersonalDetails.login, + currentUserPersonalDetails.accountID, + backendAmount, + '', + transaction.currency, + '', + '', + '', + ); + return; + } + IOU.requestMoney( + report, + 0, + transaction.currency, + transaction.created, + '', + currentUserPersonalDetails.login, + currentUserPersonalDetails.accountID, + participants[0], + '', + null, + ); + return; + } + if (action === CONST.IOU.ACTION.EDIT) { updateScanAndNavigate(file, source); return; @@ -493,4 +542,13 @@ IOURequestStepScan.defaultProps = defaultProps; IOURequestStepScan.propTypes = propTypes; IOURequestStepScan.displayName = 'IOURequestStepScan'; -export default compose(withWritableReportOrNotFound, withFullTransactionOrNotFound)(IOURequestStepScan); +export default compose( + withWritableReportOrNotFound, + withFullTransactionOrNotFound, + withCurrentUserPersonalDetails, + withOnyx({ + personalDetails: { + key: ONYXKEYS.PERSONAL_DETAILS_LIST, + }, + }), +)(IOURequestStepScan); From c4465bca60917d94f2aa83f1419898368700e8c5 Mon Sep 17 00:00:00 2001 From: Alberto <alberto@expensify.com> Date: Tue, 2 Apr 2024 16:05:19 +0200 Subject: [PATCH 021/206] more receipt handling --- .../step/IOURequestStepConfirmation.js | 1 - .../request/step/IOURequestStepScan/index.js | 72 ++++++++++--------- 2 files changed, 40 insertions(+), 33 deletions(-) diff --git a/src/pages/iou/request/step/IOURequestStepConfirmation.js b/src/pages/iou/request/step/IOURequestStepConfirmation.js index ed0f1a0bc865..cb637876d7c8 100644 --- a/src/pages/iou/request/step/IOURequestStepConfirmation.js +++ b/src/pages/iou/request/step/IOURequestStepConfirmation.js @@ -309,7 +309,6 @@ function IOURequestStepConfirmation({ // If we have a receipt let's start the split bill by creating only the action, the transaction, and the group DM if needed if (iouType === CONST.IOU.TYPE.SPLIT && receiptFile) { - console.log('there'); IOU.startSplitBill( selectedParticipants, currentUserPersonalDetails.login, diff --git a/src/pages/iou/request/step/IOURequestStepScan/index.js b/src/pages/iou/request/step/IOURequestStepScan/index.js index 9c0ddffbf156..5fd42b1b8121 100644 --- a/src/pages/iou/request/step/IOURequestStepScan/index.js +++ b/src/pages/iou/request/step/IOURequestStepScan/index.js @@ -41,6 +41,7 @@ import withCurrentUserPersonalDetails, { import personalDetailsPropType from "@pages/personalDetailsPropType"; import {withOnyx} from "react-native-onyx"; import ONYXKEYS from "@src/ONYXKEYS"; +import * as OptionsListUtils from "@libs/OptionsListUtils"; const propTypes = { /** Navigation route context info provided by react navigation */ @@ -218,57 +219,40 @@ function IOURequestStepScan({ Navigation.goBack(backTo); }; - const navigateToConfirmationStep = useCallback(() => { + const navigateToConfirmationStep = useCallback((file, source) => { if (backTo) { Navigation.goBack(backTo); return; } // If the transaction was created from the global create, the person needs to select participants, so take them there. - if (isFromGlobalCreate && iouType !== CONST.IOU.TYPE.TRACK_EXPENSE) { + if (isFromGlobalCreate && iouType !== CONST.IOU.TYPE.TRACK_EXPENSE && !report.reportID) { Navigation.navigate(ROUTES.MONEY_REQUEST_STEP_PARTICIPANTS.getRoute(iouType, transactionID, reportID)); return; } // If the transaction was created from the + menu from the composer inside of a chat, the participants can automatically // be added to the transaction (taken from the chat report participants) and then the person is taken to the confirmation step. - IOU.setMoneyRequestParticipantsFromReport(transactionID, report); - Navigation.navigate(ROUTES.MONEY_REQUEST_STEP_CONFIRMATION.getRoute(iouType, transactionID, reportID)); - }, [iouType, report, reportID, transactionID, isFromGlobalCreate, backTo]); - - const updateScanAndNavigate = useCallback( - (file, source) => { - IOU.replaceReceipt(transactionID, file, source); - Navigation.dismissModal(); - }, - [transactionID], - ); - - /** - * Sets the Receipt objects and navigates the user to the next page - * @param {Object} file - */ - const setReceiptAndNavigate = (file) => { - if (!validateReceipt(file)) { - return; - } - - // Store the receipt on the transaction object in Onyx - const source = URL.createObjectURL(file); - IOU.setMoneyRequestReceipt(transactionID, source, file.name, action !== CONST.IOU.ACTION.EDIT); + const selectedParticipants = IOU.setMoneyRequestParticipantsFromReport(transactionID, report); + const participants = _.map(selectedParticipants, (participant) => { + const participantAccountID = lodashGet(participant, 'accountID', 0); + return participantAccountID ? OptionsListUtils.getParticipantsOption(participant, personalDetails) : OptionsListUtils.getReportOption(participant); + }); if (skipConfirmation) { + const receipt = file; + receipt.source = source; + receipt.state = CONST.IOU.RECEIPT_STATE.SCANREADY; if (iouType === CONST.IOU.TYPE.SPLIT) { - IOU.splitBillAndOpenReport( + IOU.startSplitBill( participants, currentUserPersonalDetails.login, currentUserPersonalDetails.accountID, - backendAmount, - '', - transaction.currency, '', '', '', + receipt, + reportID, ); return; } @@ -282,17 +266,41 @@ function IOURequestStepScan({ currentUserPersonalDetails.accountID, participants[0], '', - null, + receipt, ); return; } + Navigation.navigate(ROUTES.MONEY_REQUEST_STEP_CONFIRMATION.getRoute(iouType, transactionID, reportID)); + }, [iouType, report, reportID, transactionID, isFromGlobalCreate, backTo]); + + const updateScanAndNavigate = useCallback( + (file, source) => { + IOU.replaceReceipt(transactionID, file, source); + Navigation.dismissModal(); + }, + [transactionID], + ); + + /** + * Sets the Receipt objects and navigates the user to the next page + * @param {Object} file + */ + const setReceiptAndNavigate = (file) => { + if (!validateReceipt(file)) { + return; + } + + // Store the receipt on the transaction object in Onyx + const source = URL.createObjectURL(file); + IOU.setMoneyRequestReceipt(transactionID, source, file.name, action !== CONST.IOU.ACTION.EDIT); + if (action === CONST.IOU.ACTION.EDIT) { updateScanAndNavigate(file, source); return; } - navigateToConfirmationStep(); + navigateToConfirmationStep(file, source); }; const setupCameraPermissionsAndCapabilities = (stream) => { From e9d7d84ec2b4f547523483ce651c6a229290d565 Mon Sep 17 00:00:00 2001 From: Alberto <alberto@expensify.com> Date: Wed, 3 Apr 2024 16:22:10 +0200 Subject: [PATCH 022/206] more fixes after merge main --- .../iou/request/step/IOURequestStepAmount.js | 32 +++++-------------- 1 file changed, 8 insertions(+), 24 deletions(-) diff --git a/src/pages/iou/request/step/IOURequestStepAmount.js b/src/pages/iou/request/step/IOURequestStepAmount.js index 5187a4e021c5..5e0f84edb95b 100644 --- a/src/pages/iou/request/step/IOURequestStepAmount.js +++ b/src/pages/iou/request/step/IOURequestStepAmount.js @@ -45,22 +45,14 @@ const propTypes = { /** The draft transaction that holds data to be persisted on the current transaction */ splitDraftTransaction: transactionPropTypes, - /** Whether or not the policy has tax tracking enabled */ - tax: PropTypes.shape({ - trackingEnabled: PropTypes.bool, - }), - - /** Collection of tax rates attached to a policy */ - taxRates: taxPropTypes, - }), + /** The draft transaction object being modified in Onyx */ + draftTransaction: transactionPropTypes, /** Personal details of all users */ personalDetails: personalDetailsPropType, ...withCurrentUserPersonalDetailsPropTypes, - /** The draft transaction object being modified in Onyx */ - draftTransaction: transactionPropTypes, }; const defaultProps = { @@ -71,18 +63,12 @@ const defaultProps = { ...withCurrentUserPersonalDetailsDefaultProps, }; -const getTaxAmount = (transaction, defaultTaxValue, amount) => { - const percentage = (transaction.taxRate ? transaction.taxRate.data.value : defaultTaxValue) || ''; - return TransactionUtils.calculateTaxAmount(percentage, amount); - splitDraftTransaction: {}, - draftTransaction: {}, -}; - function IOURequestStepAmount({ report, route: { params: {iouType, reportID, transactionID, backTo, action}, }, + transaction, policy, personalDetails, currentUserPersonalDetails, @@ -96,9 +82,6 @@ function IOURequestStepAmount({ const originalCurrency = useRef(null); const iouRequestType = getRequestType(transaction); - const taxRates = lodashGet(policy, 'taxRates', {}); - const isPolicyExpenseChat = ReportUtils.isPolicyExpenseChat(ReportUtils.getRootParentReport(report)); - const isTaxTrackingEnabled = isPolicyExpenseChat && lodashGet(policy, 'tax.trackingEnabled', policy.isTaxTrackingEnabled); const isEditing = action === CONST.IOU.ACTION.EDIT; const isSplitBill = iouType === CONST.IOU.TYPE.SPLIT; const isEditingSplitBill = isEditing && isSplitBill; @@ -188,7 +171,7 @@ function IOURequestStepAmount({ currentUserPersonalDetails.accountID, backendAmount, '', - transaction.currency, + currency, '', '', '', @@ -197,18 +180,18 @@ function IOURequestStepAmount({ } if (iouType === CONST.IOU.TYPE.SEND) { if (paymentMethod && paymentMethod === CONST.IOU.PAYMENT_TYPE.EXPENSIFY) { - IOU.sendMoneyWithWallet(report, backendAmount, transaction.currency, '', currentUserPersonalDetails.accountID, participants[0]); + IOU.sendMoneyWithWallet(report, backendAmount, currency, '', currentUserPersonalDetails.accountID, participants[0]); return; } - IOU.sendMoneyElsewhere(report, backendAmount, transaction.currency, '', currentUserPersonalDetails.accountID, participants[0]); + IOU.sendMoneyElsewhere(report, backendAmount, currency, '', currentUserPersonalDetails.accountID, participants[0]); return; } if (iouType === CONST.IOU.TYPE.REQUEST) { IOU.requestMoney( report, backendAmount, - transaction.currency, + currency, transaction.created, '', currentUserPersonalDetails.login, @@ -293,6 +276,7 @@ export default compose( }, policy: { key: ({report}) => `${ONYXKEYS.COLLECTION.POLICY}${report ? report.policyID : '0'}`, + }, splitDraftTransaction: { key: ({route}) => { const transactionID = lodashGet(route, 'params.transactionID', 0); From 0345b7dd7c09f3b87d0a240983750cf307374cbf Mon Sep 17 00:00:00 2001 From: Alberto <alberto@expensify.com> Date: Wed, 3 Apr 2024 16:50:16 +0200 Subject: [PATCH 023/206] set flag for task --- src/libs/actions/Task.ts | 12 ++++++++---- src/pages/tasks/NewTaskTitlePage.tsx | 3 +++ src/types/onyx/Task.ts | 3 +++ 3 files changed, 14 insertions(+), 4 deletions(-) diff --git a/src/libs/actions/Task.ts b/src/libs/actions/Task.ts index bb80bc767cb3..be3e026db74e 100644 --- a/src/libs/actions/Task.ts +++ b/src/libs/actions/Task.ts @@ -90,8 +90,12 @@ Onyx.connect({ /** * Clears out the task info from the store */ -function clearOutTaskInfo() { - Onyx.set(ONYXKEYS.TASK, null); +function clearOutTaskInfo(skipConfirmation = false) { + if (skipConfirmation) { + Onyx.set(ONYXKEYS.TASK, {skipConfirmation: true}); + } else { + Onyx.set(ONYXKEYS.TASK, null); + } } /** @@ -725,8 +729,8 @@ function setParentReportID(parentReportID: string) { /** * Clears out the task info from the store and navigates to the NewTaskDetails page */ -function clearOutTaskInfoAndNavigate(reportID: string, chatReport: OnyxEntry<OnyxTypes.Report>, accountID = 0) { - clearOutTaskInfo(); +function clearOutTaskInfoAndNavigate(reportID: string, chatReport: OnyxEntry<OnyxTypes.Report>, accountID = 0, skipConfirmation = false) { + clearOutTaskInfo(skipConfirmation); if (reportID && reportID !== '0') { setParentReportID(reportID); } diff --git a/src/pages/tasks/NewTaskTitlePage.tsx b/src/pages/tasks/NewTaskTitlePage.tsx index 582d2a5c6500..3a1e2fafc95f 100644 --- a/src/pages/tasks/NewTaskTitlePage.tsx +++ b/src/pages/tasks/NewTaskTitlePage.tsx @@ -22,6 +22,7 @@ import ROUTES from '@src/ROUTES'; import type SCREENS from '@src/SCREENS'; import INPUT_IDS from '@src/types/form/NewTaskForm'; import type {Task} from '@src/types/onyx'; +import * as ReportUtils from "@libs/ReportUtils"; type NewTaskTitlePageOnyxProps = { /** Task Creation Data */ @@ -35,6 +36,8 @@ function NewTaskTitlePage({task}: NewTaskTitlePageProps) { const {translate} = useLocalize(); + const skipConfirmation = task.skipConfirmation; + const validate = (values: FormOnyxValues<typeof ONYXKEYS.FORMS.NEW_TASK_FORM>): FormInputErrors<typeof ONYXKEYS.FORMS.NEW_TASK_FORM> => { const errors = {}; diff --git a/src/types/onyx/Task.ts b/src/types/onyx/Task.ts index 50a871b7ea07..ee3b8e8abd87 100644 --- a/src/types/onyx/Task.ts +++ b/src/types/onyx/Task.ts @@ -25,6 +25,9 @@ type Task = { /** Chat report with assignee of task */ assigneeChatReport?: Report; + + /** If set, skip confirmation when creating the task */ + skipConfirmation?: boolean; }; export default Task; From 3b7111c5ee067886f0a63b685f64c4368fe75cad Mon Sep 17 00:00:00 2001 From: Alberto <alberto@expensify.com> Date: Wed, 3 Apr 2024 17:11:40 +0200 Subject: [PATCH 024/206] wrap up task --- .../FloatingActionButtonAndPopover.js | 2 +- .../iou/request/step/IOURequestStepAmount.js | 9 +++------ src/pages/tasks/NewTaskDetailsPage.tsx | 20 ++++++++++++++++++- src/pages/tasks/NewTaskTitlePage.tsx | 2 -- 4 files changed, 23 insertions(+), 10 deletions(-) diff --git a/src/pages/home/sidebar/SidebarScreen/FloatingActionButtonAndPopover.js b/src/pages/home/sidebar/SidebarScreen/FloatingActionButtonAndPopover.js index ba28a653d283..0e395f0e8834 100644 --- a/src/pages/home/sidebar/SidebarScreen/FloatingActionButtonAndPopover.js +++ b/src/pages/home/sidebar/SidebarScreen/FloatingActionButtonAndPopover.js @@ -190,7 +190,7 @@ function FloatingActionButtonAndPopover(props) { IOU.startMoneyRequest(CONST.IOU.TYPE.SEND, props.quickAction.chatReportID, CONST.IOU.REQUEST_TYPE.MANUAL, true); return; case CONST.QUICK_ACTIONS.ASSIGN_TASK: - Task.clearOutTaskInfoAndNavigate(props.quickAction.chatReportID, quickActionReport, _.get(props.quickAction, 'targetAccountID', 0)); + Task.clearOutTaskInfoAndNavigate(props.quickAction.chatReportID, quickActionReport, _.get(props.quickAction, 'targetAccountID', 0), true); return; default: return ''; diff --git a/src/pages/iou/request/step/IOURequestStepAmount.js b/src/pages/iou/request/step/IOURequestStepAmount.js index 5e0f84edb95b..179a0b7f86b8 100644 --- a/src/pages/iou/request/step/IOURequestStepAmount.js +++ b/src/pages/iou/request/step/IOURequestStepAmount.js @@ -24,12 +24,9 @@ import IOURequestStepRoutePropTypes from './IOURequestStepRoutePropTypes'; import StepScreenWrapper from './StepScreenWrapper'; import withFullTransactionOrNotFound from './withFullTransactionOrNotFound'; import withWritableReportOrNotFound from './withWritableReportOrNotFound'; -import withCurrentUserPersonalDetails, { - withCurrentUserPersonalDetailsDefaultProps, - withCurrentUserPersonalDetailsPropTypes -} from "@components/withCurrentUserPersonalDetails"; -import * as OptionsListUtils from "@libs/OptionsListUtils"; -import personalDetailsPropType from "@pages/personalDetailsPropType"; +import withCurrentUserPersonalDetails, {withCurrentUserPersonalDetailsDefaultProps, withCurrentUserPersonalDetailsPropTypes} from '@components/withCurrentUserPersonalDetails'; +import * as OptionsListUtils from '@libs/OptionsListUtils'; +import personalDetailsPropType from '@pages/personalDetailsPropType'; const propTypes = { /** Navigation route context info provided by react navigation */ diff --git a/src/pages/tasks/NewTaskDetailsPage.tsx b/src/pages/tasks/NewTaskDetailsPage.tsx index 15612e20afd7..a5b479060bdf 100644 --- a/src/pages/tasks/NewTaskDetailsPage.tsx +++ b/src/pages/tasks/NewTaskDetailsPage.tsx @@ -23,6 +23,7 @@ import ROUTES from '@src/ROUTES'; import type SCREENS from '@src/SCREENS'; import INPUT_IDS from '@src/types/form/NewTaskForm'; import type {Task} from '@src/types/onyx'; +import playSound, {SOUNDS} from '@libs/Sound'; type NewTaskDetailsPageOnyxProps = { /** Task Creation Data */ @@ -41,6 +42,8 @@ function NewTaskDetailsPage({task}: NewTaskDetailsPageProps) { const {inputCallbackRef} = useAutoFocusInput(); + const skipConfirmation = task?.skipConfirmation && task?.assigneeAccountID && task?.parentReportID; + useEffect(() => { setTaskTitle(task?.title ?? ''); setTaskDescription(parser.htmlToMarkdown(parser.replace(task?.description ?? ''))); @@ -66,7 +69,22 @@ function NewTaskDetailsPage({task}: NewTaskDetailsPageProps) { // the response const onSubmit = (values: FormOnyxValues<typeof ONYXKEYS.FORMS.NEW_TASK_FORM>) => { TaskActions.setDetailsValue(values.taskTitle, values.taskDescription); - Navigation.navigate(ROUTES.NEW_TASK); + + if (skipConfirmation) { + TaskActions.setShareDestinationValue(task?.parentReportID ?? ''); + playSound(SOUNDS.DONE); + TaskActions.createTaskAndNavigate( + task?.parentReportID ?? '', + values.taskTitle, + values.taskDescription ?? '', + task?.assignee ?? '', + task.assigneeAccountID, + task.assigneeChatReport, + ); + + } else { + Navigation.navigate(ROUTES.NEW_TASK); + } }; return ( diff --git a/src/pages/tasks/NewTaskTitlePage.tsx b/src/pages/tasks/NewTaskTitlePage.tsx index 3a1e2fafc95f..38eca84d31c8 100644 --- a/src/pages/tasks/NewTaskTitlePage.tsx +++ b/src/pages/tasks/NewTaskTitlePage.tsx @@ -36,8 +36,6 @@ function NewTaskTitlePage({task}: NewTaskTitlePageProps) { const {translate} = useLocalize(); - const skipConfirmation = task.skipConfirmation; - const validate = (values: FormOnyxValues<typeof ONYXKEYS.FORMS.NEW_TASK_FORM>): FormInputErrors<typeof ONYXKEYS.FORMS.NEW_TASK_FORM> => { const errors = {}; From 6b9981f21b86cbaea592c444e39c84a943ca6ec4 Mon Sep 17 00:00:00 2001 From: Alberto <alberto@expensify.com> Date: Wed, 3 Apr 2024 17:16:33 +0200 Subject: [PATCH 025/206] add scan native --- .../request/step/IOURequestStepDistance.js | 14 ++++--- .../request/step/IOURequestStepScan/index.js | 13 +++--- .../step/IOURequestStepScan/index.native.js | 42 ++++++++++++++++++- 3 files changed, 54 insertions(+), 15 deletions(-) diff --git a/src/pages/iou/request/step/IOURequestStepDistance.js b/src/pages/iou/request/step/IOURequestStepDistance.js index a9d25e33926e..af72fea8f15c 100644 --- a/src/pages/iou/request/step/IOURequestStepDistance.js +++ b/src/pages/iou/request/step/IOURequestStepDistance.js @@ -29,11 +29,13 @@ import IOURequestStepRoutePropTypes from './IOURequestStepRoutePropTypes'; import StepScreenWrapper from './StepScreenWrapper'; import withFullTransactionOrNotFound from './withFullTransactionOrNotFound'; import withWritableReportOrNotFound from './withWritableReportOrNotFound'; -import * as ReportUtils from "@libs/ReportUtils"; -import DistanceRequestUtils from "@libs/DistanceRequestUtils"; -import * as OptionsListUtils from "@libs/OptionsListUtils"; -import personalDetailsPropType from "@pages/personalDetailsPropType"; -import withCurrentUserPersonalDetails, {withCurrentUserPersonalDetailsDefaultProps} from "@components/withCurrentUserPersonalDetails"; +import * as ReportUtils from '@libs/ReportUtils'; +import * as OptionsListUtils from '@libs/OptionsListUtils'; +import personalDetailsPropType from '@pages/personalDetailsPropType'; +import withCurrentUserPersonalDetails, { + withCurrentUserPersonalDetailsDefaultProps, + withCurrentUserPersonalDetailsPropTypes +} from "@components/withCurrentUserPersonalDetails"; const propTypes = { /** Navigation route context info provided by react navigation */ @@ -52,7 +54,7 @@ const propTypes = { /** Personal details of all users */ personalDetails: personalDetailsPropType, - ...withCurrentUserPersonalDetailsDefaultProps, + ...withCurrentUserPersonalDetailsPropTypes, }; const defaultProps = { diff --git a/src/pages/iou/request/step/IOURequestStepScan/index.js b/src/pages/iou/request/step/IOURequestStepScan/index.js index 38e2f2ab3c65..cc3ad4884b43 100644 --- a/src/pages/iou/request/step/IOURequestStepScan/index.js +++ b/src/pages/iou/request/step/IOURequestStepScan/index.js @@ -34,14 +34,14 @@ import * as IOU from '@userActions/IOU'; import CONST from '@src/CONST'; import ROUTES from '@src/ROUTES'; import NavigationAwareCamera from './NavigationAwareCamera'; -import * as ReportUtils from "@libs/ReportUtils"; +import * as ReportUtils from '@libs/ReportUtils'; import withCurrentUserPersonalDetails, { withCurrentUserPersonalDetailsDefaultProps, withCurrentUserPersonalDetailsPropTypes -} from "@components/withCurrentUserPersonalDetails"; -import personalDetailsPropType from "@pages/personalDetailsPropType"; -import {withOnyx} from "react-native-onyx"; -import ONYXKEYS from "@src/ONYXKEYS"; -import * as OptionsListUtils from "@libs/OptionsListUtils"; +} from '@components/withCurrentUserPersonalDetails'; +import personalDetailsPropType from '@pages/personalDetailsPropType'; +import {withOnyx} from 'react-native-onyx'; +import ONYXKEYS from '@src/ONYXKEYS'; +import * as OptionsListUtils from '@libs/OptionsListUtils'; const propTypes = { /** Navigation route context info provided by react navigation */ @@ -270,7 +270,6 @@ function IOURequestStepScan({ ); return; } - IOU.setMoneyRequestParticipantsFromReport(transactionID, report); Navigation.navigate(ROUTES.MONEY_REQUEST_STEP_CONFIRMATION.getRoute(CONST.IOU.ACTION.CREATE, iouType, transactionID, reportID)); }, [iouType, report, reportID, transactionID, isFromGlobalCreate, backTo]); diff --git a/src/pages/iou/request/step/IOURequestStepScan/index.native.js b/src/pages/iou/request/step/IOURequestStepScan/index.native.js index 738fbb00167d..326221282422 100644 --- a/src/pages/iou/request/step/IOURequestStepScan/index.native.js +++ b/src/pages/iou/request/step/IOURequestStepScan/index.native.js @@ -33,6 +33,8 @@ import CONST from '@src/CONST'; import ROUTES from '@src/ROUTES'; import * as CameraPermission from './CameraPermission'; import NavigationAwareCamera from './NavigationAwareCamera'; +import _ from "@types/underscore"; +import * as OptionsListUtils from "@libs/OptionsListUtils"; const propTypes = { /** Navigation route context info provided by react navigation */ @@ -182,14 +184,50 @@ function IOURequestStepScan({ } // If the transaction was created from the global create, the person needs to select participants, so take them there. - if (isFromGlobalCreate && iouType !== CONST.IOU.TYPE.TRACK_EXPENSE) { + if (isFromGlobalCreate && iouType !== CONST.IOU.TYPE.TRACK_EXPENSE && !report.reportID) { Navigation.navigate(ROUTES.MONEY_REQUEST_STEP_PARTICIPANTS.getRoute(iouType, transactionID, reportID)); return; } // If the transaction was created from the + menu from the composer inside of a chat, the participants can automatically // be added to the transaction (taken from the chat report participants) and then the person is taken to the confirmation step. - IOU.setMoneyRequestParticipantsFromReport(transactionID, report); + const selectedParticipants = IOU.setMoneyRequestParticipantsFromReport(transactionID, report); + const participants = _.map(selectedParticipants, (participant) => { + const participantAccountID = lodashGet(participant, 'accountID', 0); + return participantAccountID ? OptionsListUtils.getParticipantsOption(participant, personalDetails) : OptionsListUtils.getReportOption(participant); + }); + + if (skipConfirmation) { + const receipt = file; + receipt.source = source; + receipt.state = CONST.IOU.RECEIPT_STATE.SCANREADY; + if (iouType === CONST.IOU.TYPE.SPLIT) { + IOU.startSplitBill( + participants, + currentUserPersonalDetails.login, + currentUserPersonalDetails.accountID, + '', + '', + '', + receipt, + reportID, + ); + return; + } + IOU.requestMoney( + report, + 0, + transaction.currency, + transaction.created, + '', + currentUserPersonalDetails.login, + currentUserPersonalDetails.accountID, + participants[0], + '', + receipt, + ); + return; + } Navigation.navigate(ROUTES.MONEY_REQUEST_STEP_CONFIRMATION.getRoute(CONST.IOU.ACTION.CREATE, iouType, transactionID, reportID)); }, [iouType, report, reportID, transactionID, isFromGlobalCreate, backTo]); From 95bbf6855f95957915aa3292c33f1d1e5c9aa7e9 Mon Sep 17 00:00:00 2001 From: Alberto <alberto@expensify.com> Date: Wed, 3 Apr 2024 17:24:56 +0200 Subject: [PATCH 026/206] more scn native --- .../request/step/IOURequestStepScan/index.js | 2 +- .../step/IOURequestStepScan/index.native.js | 49 +++++++++++++++---- 2 files changed, 40 insertions(+), 11 deletions(-) diff --git a/src/pages/iou/request/step/IOURequestStepScan/index.js b/src/pages/iou/request/step/IOURequestStepScan/index.js index cc3ad4884b43..3a8c11caba79 100644 --- a/src/pages/iou/request/step/IOURequestStepScan/index.js +++ b/src/pages/iou/request/step/IOURequestStepScan/index.js @@ -331,7 +331,7 @@ function IOURequestStepScan({ return; } - navigateToConfirmationStep(); + navigateToConfirmationStep(file, source); }, [action, transactionID, updateScanAndNavigate, navigateToConfirmationStep, requestCameraPermission]); const clearTorchConstraints = useCallback(() => { diff --git a/src/pages/iou/request/step/IOURequestStepScan/index.native.js b/src/pages/iou/request/step/IOURequestStepScan/index.native.js index 326221282422..61fa5a85ef07 100644 --- a/src/pages/iou/request/step/IOURequestStepScan/index.native.js +++ b/src/pages/iou/request/step/IOURequestStepScan/index.native.js @@ -35,6 +35,14 @@ import * as CameraPermission from './CameraPermission'; import NavigationAwareCamera from './NavigationAwareCamera'; import _ from "@types/underscore"; import * as OptionsListUtils from "@libs/OptionsListUtils"; +import * as ReportUtils from "@libs/ReportUtils"; +import withCurrentUserPersonalDetails, { + withCurrentUserPersonalDetailsDefaultProps, + withCurrentUserPersonalDetailsPropTypes +} from "@components/withCurrentUserPersonalDetails"; +import {withOnyx} from "react-native-onyx"; +import ONYXKEYS from "@src/ONYXKEYS"; +import personalDetailsPropType from "@pages/personalDetailsPropType"; const propTypes = { /** Navigation route context info provided by react navigation */ @@ -46,11 +54,19 @@ const propTypes = { /** The transaction (or draft transaction) being changed */ transaction: transactionPropTypes, + + /** Personal details of all users */ + personalDetails: personalDetailsPropType, + + /** The personal details of the current user */ + ...withCurrentUserPersonalDetailsPropTypes, }; const defaultProps = { report: {}, transaction: {}, + personalDetails: {}, + ...withCurrentUserPersonalDetailsDefaultProps, }; function IOURequestStepScan({ @@ -58,7 +74,10 @@ function IOURequestStepScan({ route: { params: {action, iouType, reportID, transactionID, backTo}, }, + transaction, transaction: {isFromGlobalCreate}, + personalDetails, + currentUserPersonalDetails, }) { const theme = useTheme(); const styles = useThemeStyles(); @@ -71,6 +90,7 @@ function IOURequestStepScan({ const [flash, setFlash] = useState(false); const [cameraPermissionStatus, setCameraPermissionStatus] = useState(undefined); const [didCapturePhoto, setDidCapturePhoto] = useState(false); + const skipConfirmation = transaction.skipConfirmation && !ReportUtils.isArchivedRoom(report); const {translate} = useLocalize(); @@ -177,7 +197,7 @@ function IOURequestStepScan({ Navigation.goBack(); }; - const navigateToConfirmationStep = useCallback(() => { + const navigateToConfirmationStep = useCallback((file, source) => { if (backTo) { Navigation.goBack(backTo); return; @@ -258,7 +278,7 @@ function IOURequestStepScan({ return; } - navigateToConfirmationStep(); + navigateToConfirmationStep(file, file.uri); }; const capturePhoto = useCallback(() => { @@ -289,15 +309,15 @@ function IOURequestStepScan({ const source = `file://${photo.path}`; IOU.setMoneyRequestReceipt(transactionID, source, photo.path, action !== CONST.IOU.ACTION.EDIT); - if (action === CONST.IOU.ACTION.EDIT) { - FileUtils.readFileAsync(source, photo.path, (file) => { + FileUtils.readFileAsync(source, photo.path, (file) => { + if (action === CONST.IOU.ACTION.EDIT) { updateScanAndNavigate(file, source); - }); - return; - } + return; + } + setDidCapturePhoto(true); + navigateToConfirmationStep(file, source); + }); - setDidCapturePhoto(true); - navigateToConfirmationStep(); }) .catch((error) => { setDidCapturePhoto(false); @@ -428,4 +448,13 @@ IOURequestStepScan.defaultProps = defaultProps; IOURequestStepScan.propTypes = propTypes; IOURequestStepScan.displayName = 'IOURequestStepScan'; -export default compose(withWritableReportOrNotFound, withFullTransactionOrNotFound)(IOURequestStepScan); +export default compose( + withWritableReportOrNotFound, + withFullTransactionOrNotFound, + withCurrentUserPersonalDetails, + withOnyx({ + personalDetails: { + key: ONYXKEYS.PERSONAL_DETAILS_LIST, + }, + }), +)(IOURequestStepScan); From 80d05077b6f2df5dd150e5a24cbb46a3367a492e Mon Sep 17 00:00:00 2001 From: Alberto <alberto@expensify.com> Date: Wed, 3 Apr 2024 17:26:08 +0200 Subject: [PATCH 027/206] cleanup --- .../step/IOURequestStepScan/index.native.js | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/src/pages/iou/request/step/IOURequestStepScan/index.native.js b/src/pages/iou/request/step/IOURequestStepScan/index.native.js index 61fa5a85ef07..63be372755eb 100644 --- a/src/pages/iou/request/step/IOURequestStepScan/index.native.js +++ b/src/pages/iou/request/step/IOURequestStepScan/index.native.js @@ -33,16 +33,13 @@ import CONST from '@src/CONST'; import ROUTES from '@src/ROUTES'; import * as CameraPermission from './CameraPermission'; import NavigationAwareCamera from './NavigationAwareCamera'; -import _ from "@types/underscore"; -import * as OptionsListUtils from "@libs/OptionsListUtils"; -import * as ReportUtils from "@libs/ReportUtils"; -import withCurrentUserPersonalDetails, { - withCurrentUserPersonalDetailsDefaultProps, - withCurrentUserPersonalDetailsPropTypes -} from "@components/withCurrentUserPersonalDetails"; -import {withOnyx} from "react-native-onyx"; -import ONYXKEYS from "@src/ONYXKEYS"; -import personalDetailsPropType from "@pages/personalDetailsPropType"; +import _ from '@types/underscore'; +import * as OptionsListUtils from '@libs/OptionsListUtils'; +import * as ReportUtils from '@libs/ReportUtils'; +import withCurrentUserPersonalDetails, {withCurrentUserPersonalDetailsDefaultProps, withCurrentUserPersonalDetailsPropTypes} from '@components/withCurrentUserPersonalDetails'; +import {withOnyx} from 'react-native-onyx'; +import ONYXKEYS from '@src/ONYXKEYS'; +import personalDetailsPropType from '@pages/personalDetailsPropType'; const propTypes = { /** Navigation route context info provided by react navigation */ From 7a23b4bb483eff1a4d4717b6c2c661a2f78ad18e Mon Sep 17 00:00:00 2001 From: Alberto <alberto@expensify.com> Date: Wed, 3 Apr 2024 17:26:58 +0200 Subject: [PATCH 028/206] prettier --- src/libs/actions/IOU.ts | 8 +- .../iou/request/step/IOURequestStepAmount.js | 23 ++-- .../request/step/IOURequestStepDistance.js | 11 +- .../request/step/IOURequestStepScan/index.js | 94 ++++++++-------- .../step/IOURequestStepScan/index.native.js | 95 ++++++++-------- .../iou/steps/MoneyRequestAmountForm.tsx | 101 +++++++++--------- src/pages/tasks/NewTaskDetailsPage.tsx | 3 +- src/pages/tasks/NewTaskTitlePage.tsx | 2 +- 8 files changed, 158 insertions(+), 179 deletions(-) diff --git a/src/libs/actions/IOU.ts b/src/libs/actions/IOU.ts index 0c4bd5dab69e..cd9d3240881d 100644 --- a/src/libs/actions/IOU.ts +++ b/src/libs/actions/IOU.ts @@ -257,7 +257,13 @@ Onyx.connect({ * @param iouRequestType one of manual/scan/distance * @param skipConfirmation if true, skip confirmation step */ -function initMoneyRequest(reportID: string, policy: OnyxEntry<OnyxTypes.Policy>, isFromGlobalCreate: boolean, iouRequestType: IOURequestType = CONST.IOU.REQUEST_TYPE.MANUAL, skipConfirmation = false) { +function initMoneyRequest( + reportID: string, + policy: OnyxEntry<OnyxTypes.Policy>, + isFromGlobalCreate: boolean, + iouRequestType: IOURequestType = CONST.IOU.REQUEST_TYPE.MANUAL, + skipConfirmation = false, +) { // Generate a brand new transactionID const newTransactionID = CONST.IOU.OPTIMISTIC_TRANSACTION_ID; // Disabling this line since currentDate can be an empty string diff --git a/src/pages/iou/request/step/IOURequestStepAmount.js b/src/pages/iou/request/step/IOURequestStepAmount.js index 179a0b7f86b8..4609969709c6 100644 --- a/src/pages/iou/request/step/IOURequestStepAmount.js +++ b/src/pages/iou/request/step/IOURequestStepAmount.js @@ -1,20 +1,23 @@ import {useFocusEffect} from '@react-navigation/native'; import lodashGet from 'lodash/get'; -import PropTypes from 'prop-types'; -import _ from 'underscore'; import lodashIsEmpty from 'lodash/isEmpty'; +import PropTypes from 'prop-types'; import React, {useCallback, useEffect, useRef} from 'react'; import {withOnyx} from 'react-native-onyx'; +import _ from 'underscore'; import transactionPropTypes from '@components/transactionPropTypes'; +import withCurrentUserPersonalDetails, {withCurrentUserPersonalDetailsDefaultProps, withCurrentUserPersonalDetailsPropTypes} from '@components/withCurrentUserPersonalDetails'; import useLocalize from '@hooks/useLocalize'; import * as TransactionEdit from '@libs/actions/TransactionEdit'; import compose from '@libs/compose'; import * as CurrencyUtils from '@libs/CurrencyUtils'; import Navigation from '@libs/Navigation/Navigation'; +import * as OptionsListUtils from '@libs/OptionsListUtils'; import * as ReportUtils from '@libs/ReportUtils'; import {getRequestType} from '@libs/TransactionUtils'; import * as TransactionUtils from '@libs/TransactionUtils'; import MoneyRequestAmountForm from '@pages/iou/steps/MoneyRequestAmountForm'; +import personalDetailsPropType from '@pages/personalDetailsPropType'; import reportPropTypes from '@pages/reportPropTypes'; import * as IOU from '@userActions/IOU'; import CONST from '@src/CONST'; @@ -24,9 +27,6 @@ import IOURequestStepRoutePropTypes from './IOURequestStepRoutePropTypes'; import StepScreenWrapper from './StepScreenWrapper'; import withFullTransactionOrNotFound from './withFullTransactionOrNotFound'; import withWritableReportOrNotFound from './withWritableReportOrNotFound'; -import withCurrentUserPersonalDetails, {withCurrentUserPersonalDetailsDefaultProps, withCurrentUserPersonalDetailsPropTypes} from '@components/withCurrentUserPersonalDetails'; -import * as OptionsListUtils from '@libs/OptionsListUtils'; -import personalDetailsPropType from '@pages/personalDetailsPropType'; const propTypes = { /** Navigation route context info provided by react navigation */ @@ -49,7 +49,6 @@ const propTypes = { personalDetails: personalDetailsPropType, ...withCurrentUserPersonalDetailsPropTypes, - }; const defaultProps = { @@ -162,17 +161,7 @@ function IOURequestStepAmount({ if (skipConfirmation) { if (iouType === CONST.IOU.TYPE.SPLIT) { - IOU.splitBillAndOpenReport( - participants, - currentUserPersonalDetails.login, - currentUserPersonalDetails.accountID, - backendAmount, - '', - currency, - '', - '', - '', - ); + IOU.splitBillAndOpenReport(participants, currentUserPersonalDetails.login, currentUserPersonalDetails.accountID, backendAmount, '', currency, '', '', ''); return; } if (iouType === CONST.IOU.TYPE.SEND) { diff --git a/src/pages/iou/request/step/IOURequestStepDistance.js b/src/pages/iou/request/step/IOURequestStepDistance.js index af72fea8f15c..4edd39061059 100644 --- a/src/pages/iou/request/step/IOURequestStepDistance.js +++ b/src/pages/iou/request/step/IOURequestStepDistance.js @@ -9,6 +9,7 @@ import DistanceRequestRenderItem from '@components/DistanceRequest/DistanceReque import DotIndicatorMessage from '@components/DotIndicatorMessage'; import DraggableList from '@components/DraggableList'; import transactionPropTypes from '@components/transactionPropTypes'; +import withCurrentUserPersonalDetails, {withCurrentUserPersonalDetailsDefaultProps, withCurrentUserPersonalDetailsPropTypes} from '@components/withCurrentUserPersonalDetails'; import useLocalize from '@hooks/useLocalize'; import useNetwork from '@hooks/useNetwork'; import usePrevious from '@hooks/usePrevious'; @@ -16,7 +17,10 @@ import useThemeStyles from '@hooks/useThemeStyles'; import compose from '@libs/compose'; import * as ErrorUtils from '@libs/ErrorUtils'; import Navigation from '@libs/Navigation/Navigation'; +import * as OptionsListUtils from '@libs/OptionsListUtils'; +import * as ReportUtils from '@libs/ReportUtils'; import * as TransactionUtils from '@libs/TransactionUtils'; +import personalDetailsPropType from '@pages/personalDetailsPropType'; import reportPropTypes from '@pages/reportPropTypes'; import variables from '@styles/variables'; import * as IOU from '@userActions/IOU'; @@ -29,13 +33,6 @@ import IOURequestStepRoutePropTypes from './IOURequestStepRoutePropTypes'; import StepScreenWrapper from './StepScreenWrapper'; import withFullTransactionOrNotFound from './withFullTransactionOrNotFound'; import withWritableReportOrNotFound from './withWritableReportOrNotFound'; -import * as ReportUtils from '@libs/ReportUtils'; -import * as OptionsListUtils from '@libs/OptionsListUtils'; -import personalDetailsPropType from '@pages/personalDetailsPropType'; -import withCurrentUserPersonalDetails, { - withCurrentUserPersonalDetailsDefaultProps, - withCurrentUserPersonalDetailsPropTypes -} from "@components/withCurrentUserPersonalDetails"; const propTypes = { /** Navigation route context info provided by react navigation */ diff --git a/src/pages/iou/request/step/IOURequestStepScan/index.js b/src/pages/iou/request/step/IOURequestStepScan/index.js index 3a8c11caba79..5389193dc132 100644 --- a/src/pages/iou/request/step/IOURequestStepScan/index.js +++ b/src/pages/iou/request/step/IOURequestStepScan/index.js @@ -1,6 +1,7 @@ import lodashGet from 'lodash/get'; import React, {useCallback, useContext, useEffect, useReducer, useRef, useState} from 'react'; import {ActivityIndicator, PanResponder, PixelRatio, View} from 'react-native'; +import {withOnyx} from 'react-native-onyx'; import _ from 'underscore'; import Hand from '@assets/images/hand.svg'; import ReceiptUpload from '@assets/images/receipt-upload.svg'; @@ -15,6 +16,7 @@ import * as Expensicons from '@components/Icon/Expensicons'; import PressableWithFeedback from '@components/Pressable/PressableWithFeedback'; import Text from '@components/Text'; import transactionPropTypes from '@components/transactionPropTypes'; +import withCurrentUserPersonalDetails, {withCurrentUserPersonalDetailsDefaultProps, withCurrentUserPersonalDetailsPropTypes} from '@components/withCurrentUserPersonalDetails'; import useLocalize from '@hooks/useLocalize'; import useTabNavigatorFocus from '@hooks/useTabNavigatorFocus'; import useTheme from '@hooks/useTheme'; @@ -24,24 +26,20 @@ import * as Browser from '@libs/Browser'; import compose from '@libs/compose'; import * as FileUtils from '@libs/fileDownload/FileUtils'; import Navigation from '@libs/Navigation/Navigation'; +import * as OptionsListUtils from '@libs/OptionsListUtils'; +import * as ReportUtils from '@libs/ReportUtils'; import ReceiptDropUI from '@pages/iou/ReceiptDropUI'; import IOURequestStepRoutePropTypes from '@pages/iou/request/step/IOURequestStepRoutePropTypes'; import StepScreenDragAndDropWrapper from '@pages/iou/request/step/StepScreenDragAndDropWrapper'; import withFullTransactionOrNotFound from '@pages/iou/request/step/withFullTransactionOrNotFound'; import withWritableReportOrNotFound from '@pages/iou/request/step/withWritableReportOrNotFound'; +import personalDetailsPropType from '@pages/personalDetailsPropType'; import reportPropTypes from '@pages/reportPropTypes'; import * as IOU from '@userActions/IOU'; import CONST from '@src/CONST'; +import ONYXKEYS from '@src/ONYXKEYS'; import ROUTES from '@src/ROUTES'; import NavigationAwareCamera from './NavigationAwareCamera'; -import * as ReportUtils from '@libs/ReportUtils'; -import withCurrentUserPersonalDetails, { - withCurrentUserPersonalDetailsDefaultProps, withCurrentUserPersonalDetailsPropTypes -} from '@components/withCurrentUserPersonalDetails'; -import personalDetailsPropType from '@pages/personalDetailsPropType'; -import {withOnyx} from 'react-native-onyx'; -import ONYXKEYS from '@src/ONYXKEYS'; -import * as OptionsListUtils from '@libs/OptionsListUtils'; const propTypes = { /** Navigation route context info provided by react navigation */ @@ -219,59 +217,53 @@ function IOURequestStepScan({ Navigation.goBack(backTo); }; - const navigateToConfirmationStep = useCallback((file, source) => { - if (backTo) { - Navigation.goBack(backTo); - return; - } + const navigateToConfirmationStep = useCallback( + (file, source) => { + if (backTo) { + Navigation.goBack(backTo); + return; + } - // If the transaction was created from the global create, the person needs to select participants, so take them there. - if (isFromGlobalCreate && iouType !== CONST.IOU.TYPE.TRACK_EXPENSE && !report.reportID) { - Navigation.navigate(ROUTES.MONEY_REQUEST_STEP_PARTICIPANTS.getRoute(iouType, transactionID, reportID)); - return; - } + // If the transaction was created from the global create, the person needs to select participants, so take them there. + if (isFromGlobalCreate && iouType !== CONST.IOU.TYPE.TRACK_EXPENSE && !report.reportID) { + Navigation.navigate(ROUTES.MONEY_REQUEST_STEP_PARTICIPANTS.getRoute(iouType, transactionID, reportID)); + return; + } - // If the transaction was created from the + menu from the composer inside of a chat, the participants can automatically - // be added to the transaction (taken from the chat report participants) and then the person is taken to the confirmation step. - const selectedParticipants = IOU.setMoneyRequestParticipantsFromReport(transactionID, report); - const participants = _.map(selectedParticipants, (participant) => { - const participantAccountID = lodashGet(participant, 'accountID', 0); - return participantAccountID ? OptionsListUtils.getParticipantsOption(participant, personalDetails) : OptionsListUtils.getReportOption(participant); - }); + // If the transaction was created from the + menu from the composer inside of a chat, the participants can automatically + // be added to the transaction (taken from the chat report participants) and then the person is taken to the confirmation step. + const selectedParticipants = IOU.setMoneyRequestParticipantsFromReport(transactionID, report); + const participants = _.map(selectedParticipants, (participant) => { + const participantAccountID = lodashGet(participant, 'accountID', 0); + return participantAccountID ? OptionsListUtils.getParticipantsOption(participant, personalDetails) : OptionsListUtils.getReportOption(participant); + }); - if (skipConfirmation) { - const receipt = file; - receipt.source = source; - receipt.state = CONST.IOU.RECEIPT_STATE.SCANREADY; - if (iouType === CONST.IOU.TYPE.SPLIT) { - IOU.startSplitBill( - participants, + if (skipConfirmation) { + const receipt = file; + receipt.source = source; + receipt.state = CONST.IOU.RECEIPT_STATE.SCANREADY; + if (iouType === CONST.IOU.TYPE.SPLIT) { + IOU.startSplitBill(participants, currentUserPersonalDetails.login, currentUserPersonalDetails.accountID, '', '', '', receipt, reportID); + return; + } + IOU.requestMoney( + report, + 0, + transaction.currency, + transaction.created, + '', currentUserPersonalDetails.login, currentUserPersonalDetails.accountID, - '', - '', + participants[0], '', receipt, - reportID, ); return; } - IOU.requestMoney( - report, - 0, - transaction.currency, - transaction.created, - '', - currentUserPersonalDetails.login, - currentUserPersonalDetails.accountID, - participants[0], - '', - receipt, - ); - return; - } - Navigation.navigate(ROUTES.MONEY_REQUEST_STEP_CONFIRMATION.getRoute(CONST.IOU.ACTION.CREATE, iouType, transactionID, reportID)); - }, [iouType, report, reportID, transactionID, isFromGlobalCreate, backTo]); + Navigation.navigate(ROUTES.MONEY_REQUEST_STEP_CONFIRMATION.getRoute(CONST.IOU.ACTION.CREATE, iouType, transactionID, reportID)); + }, + [iouType, report, reportID, transactionID, isFromGlobalCreate, backTo], + ); const updateScanAndNavigate = useCallback( (file, source) => { diff --git a/src/pages/iou/request/step/IOURequestStepScan/index.native.js b/src/pages/iou/request/step/IOURequestStepScan/index.native.js index 63be372755eb..810934a86cd0 100644 --- a/src/pages/iou/request/step/IOURequestStepScan/index.native.js +++ b/src/pages/iou/request/step/IOURequestStepScan/index.native.js @@ -1,8 +1,10 @@ import {useFocusEffect} from '@react-navigation/core'; +import _ from '@types/underscore'; import lodashGet from 'lodash/get'; import React, {useCallback, useRef, useState} from 'react'; import {ActivityIndicator, Alert, AppState, InteractionManager, View} from 'react-native'; import {Gesture, GestureDetector} from 'react-native-gesture-handler'; +import {withOnyx} from 'react-native-onyx'; import {RESULTS} from 'react-native-permissions'; import Animated, {runOnJS, useAnimatedStyle, useSharedValue, withDelay, withSequence, withSpring, withTiming} from 'react-native-reanimated'; import {useCameraDevice} from 'react-native-vision-camera'; @@ -16,6 +18,7 @@ import ImageSVG from '@components/ImageSVG'; import PressableWithFeedback from '@components/Pressable/PressableWithFeedback'; import Text from '@components/Text'; import transactionPropTypes from '@components/transactionPropTypes'; +import withCurrentUserPersonalDetails, {withCurrentUserPersonalDetailsDefaultProps, withCurrentUserPersonalDetailsPropTypes} from '@components/withCurrentUserPersonalDetails'; import useLocalize from '@hooks/useLocalize'; import useTheme from '@hooks/useTheme'; import useThemeStyles from '@hooks/useThemeStyles'; @@ -23,23 +26,20 @@ import compose from '@libs/compose'; import * as FileUtils from '@libs/fileDownload/FileUtils'; import Log from '@libs/Log'; import Navigation from '@libs/Navigation/Navigation'; +import * as OptionsListUtils from '@libs/OptionsListUtils'; +import * as ReportUtils from '@libs/ReportUtils'; import IOURequestStepRoutePropTypes from '@pages/iou/request/step/IOURequestStepRoutePropTypes'; import StepScreenWrapper from '@pages/iou/request/step/StepScreenWrapper'; import withFullTransactionOrNotFound from '@pages/iou/request/step/withFullTransactionOrNotFound'; import withWritableReportOrNotFound from '@pages/iou/request/step/withWritableReportOrNotFound'; +import personalDetailsPropType from '@pages/personalDetailsPropType'; import reportPropTypes from '@pages/reportPropTypes'; import * as IOU from '@userActions/IOU'; import CONST from '@src/CONST'; +import ONYXKEYS from '@src/ONYXKEYS'; import ROUTES from '@src/ROUTES'; import * as CameraPermission from './CameraPermission'; import NavigationAwareCamera from './NavigationAwareCamera'; -import _ from '@types/underscore'; -import * as OptionsListUtils from '@libs/OptionsListUtils'; -import * as ReportUtils from '@libs/ReportUtils'; -import withCurrentUserPersonalDetails, {withCurrentUserPersonalDetailsDefaultProps, withCurrentUserPersonalDetailsPropTypes} from '@components/withCurrentUserPersonalDetails'; -import {withOnyx} from 'react-native-onyx'; -import ONYXKEYS from '@src/ONYXKEYS'; -import personalDetailsPropType from '@pages/personalDetailsPropType'; const propTypes = { /** Navigation route context info provided by react navigation */ @@ -194,59 +194,53 @@ function IOURequestStepScan({ Navigation.goBack(); }; - const navigateToConfirmationStep = useCallback((file, source) => { - if (backTo) { - Navigation.goBack(backTo); - return; - } + const navigateToConfirmationStep = useCallback( + (file, source) => { + if (backTo) { + Navigation.goBack(backTo); + return; + } - // If the transaction was created from the global create, the person needs to select participants, so take them there. - if (isFromGlobalCreate && iouType !== CONST.IOU.TYPE.TRACK_EXPENSE && !report.reportID) { - Navigation.navigate(ROUTES.MONEY_REQUEST_STEP_PARTICIPANTS.getRoute(iouType, transactionID, reportID)); - return; - } + // If the transaction was created from the global create, the person needs to select participants, so take them there. + if (isFromGlobalCreate && iouType !== CONST.IOU.TYPE.TRACK_EXPENSE && !report.reportID) { + Navigation.navigate(ROUTES.MONEY_REQUEST_STEP_PARTICIPANTS.getRoute(iouType, transactionID, reportID)); + return; + } - // If the transaction was created from the + menu from the composer inside of a chat, the participants can automatically - // be added to the transaction (taken from the chat report participants) and then the person is taken to the confirmation step. - const selectedParticipants = IOU.setMoneyRequestParticipantsFromReport(transactionID, report); - const participants = _.map(selectedParticipants, (participant) => { - const participantAccountID = lodashGet(participant, 'accountID', 0); - return participantAccountID ? OptionsListUtils.getParticipantsOption(participant, personalDetails) : OptionsListUtils.getReportOption(participant); - }); + // If the transaction was created from the + menu from the composer inside of a chat, the participants can automatically + // be added to the transaction (taken from the chat report participants) and then the person is taken to the confirmation step. + const selectedParticipants = IOU.setMoneyRequestParticipantsFromReport(transactionID, report); + const participants = _.map(selectedParticipants, (participant) => { + const participantAccountID = lodashGet(participant, 'accountID', 0); + return participantAccountID ? OptionsListUtils.getParticipantsOption(participant, personalDetails) : OptionsListUtils.getReportOption(participant); + }); - if (skipConfirmation) { - const receipt = file; - receipt.source = source; - receipt.state = CONST.IOU.RECEIPT_STATE.SCANREADY; - if (iouType === CONST.IOU.TYPE.SPLIT) { - IOU.startSplitBill( - participants, + if (skipConfirmation) { + const receipt = file; + receipt.source = source; + receipt.state = CONST.IOU.RECEIPT_STATE.SCANREADY; + if (iouType === CONST.IOU.TYPE.SPLIT) { + IOU.startSplitBill(participants, currentUserPersonalDetails.login, currentUserPersonalDetails.accountID, '', '', '', receipt, reportID); + return; + } + IOU.requestMoney( + report, + 0, + transaction.currency, + transaction.created, + '', currentUserPersonalDetails.login, currentUserPersonalDetails.accountID, - '', - '', + participants[0], '', receipt, - reportID, ); return; } - IOU.requestMoney( - report, - 0, - transaction.currency, - transaction.created, - '', - currentUserPersonalDetails.login, - currentUserPersonalDetails.accountID, - participants[0], - '', - receipt, - ); - return; - } - Navigation.navigate(ROUTES.MONEY_REQUEST_STEP_CONFIRMATION.getRoute(CONST.IOU.ACTION.CREATE, iouType, transactionID, reportID)); - }, [iouType, report, reportID, transactionID, isFromGlobalCreate, backTo]); + Navigation.navigate(ROUTES.MONEY_REQUEST_STEP_CONFIRMATION.getRoute(CONST.IOU.ACTION.CREATE, iouType, transactionID, reportID)); + }, + [iouType, report, reportID, transactionID, isFromGlobalCreate, backTo], + ); const updateScanAndNavigate = useCallback( (file, source) => { @@ -314,7 +308,6 @@ function IOURequestStepScan({ setDidCapturePhoto(true); navigateToConfirmationStep(file, source); }); - }) .catch((error) => { setDidCapturePhoto(false); diff --git a/src/pages/iou/steps/MoneyRequestAmountForm.tsx b/src/pages/iou/steps/MoneyRequestAmountForm.tsx index 11242746f0c7..6986cc418519 100644 --- a/src/pages/iou/steps/MoneyRequestAmountForm.tsx +++ b/src/pages/iou/steps/MoneyRequestAmountForm.tsx @@ -6,6 +6,7 @@ import BigNumberPad from '@components/BigNumberPad'; import Button from '@components/Button'; import FormHelpMessage from '@components/FormHelpMessage'; import ScrollView from '@components/ScrollView'; +import SettlementButton from '@components/SettlementButton'; import TextInputWithCurrencySymbol from '@components/TextInputWithCurrencySymbol'; import useLocalize from '@hooks/useLocalize'; import useThemeStyles from '@hooks/useThemeStyles'; @@ -19,10 +20,9 @@ import * as MoneyRequestUtils from '@libs/MoneyRequestUtils'; import Navigation from '@libs/Navigation/Navigation'; import type {BaseTextInputRef} from '@src/components/TextInput/BaseTextInput/types'; import CONST from '@src/CONST'; -import SettlementButton from "@components/SettlementButton"; -import ROUTES, {AllRoutes} from "@src/ROUTES"; -import paymentMethod from "@src/types/onyx/PaymentMethod"; +import ROUTES, {AllRoutes} from '@src/ROUTES'; import type {SelectedTabRequest} from '@src/types/onyx'; +import paymentMethod from '@src/types/onyx/PaymentMethod'; type MoneyRequestAmountFormProps = { /** IOU amount saved in Onyx */ @@ -247,24 +247,27 @@ function MoneyRequestAmountForm( /** * Submit amount and navigate to a proper page */ - const submitAndNavigateToNextPage = useCallback((iouPaymentType) => { - if (isAmountInvalid(currentAmount)) { - setFormError('iou.error.invalidAmount'); - return; - } + const submitAndNavigateToNextPage = useCallback( + (iouPaymentType) => { + if (isAmountInvalid(currentAmount)) { + setFormError('iou.error.invalidAmount'); + return; + } - if (isTaxAmountInvalid(currentAmount, taxAmount, isTaxAmountForm)) { - setFormError(['iou.error.invalidTaxAmount', {amount: formattedTaxAmount}]); - return; - } + if (isTaxAmountInvalid(currentAmount, taxAmount, isTaxAmountForm)) { + setFormError(['iou.error.invalidTaxAmount', {amount: formattedTaxAmount}]); + return; + } - // Update display amount string post-edit to ensure consistency with backend amount - // Reference: https://github.com/Expensify/App/issues/30505 - const backendAmount = CurrencyUtils.convertToBackendAmount(Number.parseFloat(currentAmount)); - initializeAmount(backendAmount); + // Update display amount string post-edit to ensure consistency with backend amount + // Reference: https://github.com/Expensify/App/issues/30505 + const backendAmount = CurrencyUtils.convertToBackendAmount(Number.parseFloat(currentAmount)); + initializeAmount(backendAmount); - onSubmitButtonPress({amount: currentAmount, paymentMethod: iouPaymentType}); - }, [onSubmitButtonPress, currentAmount, taxAmount, currency, isTaxAmountForm, formattedTaxAmount, initializeAmount]); + onSubmitButtonPress({amount: currentAmount, paymentMethod: iouPaymentType}); + }, + [onSubmitButtonPress, currentAmount, taxAmount, currency, isTaxAmountForm, formattedTaxAmount, initializeAmount], + ); /** * Input handler to check for a forward-delete key (or keyboard shortcut) press. @@ -350,38 +353,38 @@ function MoneyRequestAmountForm( /> ) : null} {iouType === CONST.IOU.TYPE.SEND && skipConfirmation ? ( - <SettlementButton - pressOnEnter - onPress={submitAndNavigateToNextPage} - enablePaymentsRoute={ROUTES.IOU_SEND_ENABLE_PAYMENTS} - addBankAccountRoute={bankAccountRoute} - addDebitCardRoute={ROUTES.IOU_SEND_ADD_DEBIT_CARD} - currency = {currency ?? CONST.CURRENCY.USD} - policyID = {policyID ?? ''} - buttonSize={CONST.DROPDOWN_BUTTON_SIZE.LARGE} - kycWallAnchorAlignment={{ - horizontal: CONST.MODAL.ANCHOR_ORIGIN_HORIZONTAL.LEFT, - vertical: CONST.MODAL.ANCHOR_ORIGIN_VERTICAL.BOTTOM, - }} - paymentMethodDropdownAnchorAlignment={{ - horizontal: CONST.MODAL.ANCHOR_ORIGIN_HORIZONTAL.RIGHT, - vertical: CONST.MODAL.ANCHOR_ORIGIN_VERTICAL.BOTTOM, - }} - shouldShowPersonalBankAccountOption - enterKeyEventListenerPriority={1} - /> + <SettlementButton + pressOnEnter + onPress={submitAndNavigateToNextPage} + enablePaymentsRoute={ROUTES.IOU_SEND_ENABLE_PAYMENTS} + addBankAccountRoute={bankAccountRoute} + addDebitCardRoute={ROUTES.IOU_SEND_ADD_DEBIT_CARD} + currency={currency ?? CONST.CURRENCY.USD} + policyID={policyID ?? ''} + buttonSize={CONST.DROPDOWN_BUTTON_SIZE.LARGE} + kycWallAnchorAlignment={{ + horizontal: CONST.MODAL.ANCHOR_ORIGIN_HORIZONTAL.LEFT, + vertical: CONST.MODAL.ANCHOR_ORIGIN_VERTICAL.BOTTOM, + }} + paymentMethodDropdownAnchorAlignment={{ + horizontal: CONST.MODAL.ANCHOR_ORIGIN_HORIZONTAL.RIGHT, + vertical: CONST.MODAL.ANCHOR_ORIGIN_VERTICAL.BOTTOM, + }} + shouldShowPersonalBankAccountOption + enterKeyEventListenerPriority={1} + /> ) : ( - <Button - success - // Prevent bubbling on edit amount Page to prevent double page submission when two CTA are stacked. - allowBubble={!isEditing} - pressOnEnter - medium={isExtraSmallScreenHeight} - large={!isExtraSmallScreenHeight} - style={[styles.w100, canUseTouchScreen ? styles.mt5 : styles.mt3]} - onPress={submitAndNavigateToNextPage} - text={buttonText} - /> + <Button + success + // Prevent bubbling on edit amount Page to prevent double page submission when two CTA are stacked. + allowBubble={!isEditing} + pressOnEnter + medium={isExtraSmallScreenHeight} + large={!isExtraSmallScreenHeight} + style={[styles.w100, canUseTouchScreen ? styles.mt5 : styles.mt3]} + onPress={submitAndNavigateToNextPage} + text={buttonText} + /> )} </View> </ScrollView> diff --git a/src/pages/tasks/NewTaskDetailsPage.tsx b/src/pages/tasks/NewTaskDetailsPage.tsx index a5b479060bdf..2c866ebf47bb 100644 --- a/src/pages/tasks/NewTaskDetailsPage.tsx +++ b/src/pages/tasks/NewTaskDetailsPage.tsx @@ -16,6 +16,7 @@ import useThemeStyles from '@hooks/useThemeStyles'; import * as ErrorUtils from '@libs/ErrorUtils'; import Navigation from '@libs/Navigation/Navigation'; import type {NewTaskNavigatorParamList} from '@libs/Navigation/types'; +import playSound, {SOUNDS} from '@libs/Sound'; import * as TaskActions from '@userActions/Task'; import CONST from '@src/CONST'; import ONYXKEYS from '@src/ONYXKEYS'; @@ -23,7 +24,6 @@ import ROUTES from '@src/ROUTES'; import type SCREENS from '@src/SCREENS'; import INPUT_IDS from '@src/types/form/NewTaskForm'; import type {Task} from '@src/types/onyx'; -import playSound, {SOUNDS} from '@libs/Sound'; type NewTaskDetailsPageOnyxProps = { /** Task Creation Data */ @@ -81,7 +81,6 @@ function NewTaskDetailsPage({task}: NewTaskDetailsPageProps) { task.assigneeAccountID, task.assigneeChatReport, ); - } else { Navigation.navigate(ROUTES.NEW_TASK); } diff --git a/src/pages/tasks/NewTaskTitlePage.tsx b/src/pages/tasks/NewTaskTitlePage.tsx index 38eca84d31c8..f9c2d5d2e128 100644 --- a/src/pages/tasks/NewTaskTitlePage.tsx +++ b/src/pages/tasks/NewTaskTitlePage.tsx @@ -15,6 +15,7 @@ import useThemeStyles from '@hooks/useThemeStyles'; import * as ErrorUtils from '@libs/ErrorUtils'; import Navigation from '@libs/Navigation/Navigation'; import type {NewTaskNavigatorParamList} from '@libs/Navigation/types'; +import * as ReportUtils from '@libs/ReportUtils'; import * as TaskActions from '@userActions/Task'; import CONST from '@src/CONST'; import ONYXKEYS from '@src/ONYXKEYS'; @@ -22,7 +23,6 @@ import ROUTES from '@src/ROUTES'; import type SCREENS from '@src/SCREENS'; import INPUT_IDS from '@src/types/form/NewTaskForm'; import type {Task} from '@src/types/onyx'; -import * as ReportUtils from "@libs/ReportUtils"; type NewTaskTitlePageOnyxProps = { /** Task Creation Data */ From 4350aaa85bd189b84f510defe8d935d0229ca268 Mon Sep 17 00:00:00 2001 From: Alberto <alberto@expensify.com> Date: Wed, 3 Apr 2024 17:41:25 +0200 Subject: [PATCH 029/206] do not skip for manual workspace requests --- src/pages/iou/request/step/IOURequestStepAmount.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pages/iou/request/step/IOURequestStepAmount.js b/src/pages/iou/request/step/IOURequestStepAmount.js index 4609969709c6..9aec21dc9543 100644 --- a/src/pages/iou/request/step/IOURequestStepAmount.js +++ b/src/pages/iou/request/step/IOURequestStepAmount.js @@ -83,7 +83,7 @@ function IOURequestStepAmount({ const isEditingSplitBill = isEditing && isSplitBill; const {amount: transactionAmount} = ReportUtils.getTransactionDetails(isEditingSplitBill && !lodashIsEmpty(splitDraftTransaction) ? splitDraftTransaction : transaction); const {currency} = ReportUtils.getTransactionDetails(isEditing ? draftTransaction : transaction); - const skipConfirmation = draftTransaction.skipConfirmation && !ReportUtils.isArchivedRoom(report); + const skipConfirmation = draftTransaction.skipConfirmation && !ReportUtils.isArchivedRoom(report) && !ReportUtils.isPolicyExpenseChat(report); useFocusEffect( useCallback(() => { From 53bde59ddf549ec1ef6ee5d5d8bec026557f0092 Mon Sep 17 00:00:00 2001 From: Alberto <alberto@expensify.com> Date: Wed, 3 Apr 2024 18:03:28 +0200 Subject: [PATCH 030/206] dont skip when categories are requires --- .../iou/request/step/IOURequestStepAmount.js | 3 +++ .../iou/request/step/IOURequestStepDistance.js | 17 ++++++++++++++++- .../request/step/IOURequestStepScan/index.js | 17 ++++++++++++++++- .../step/IOURequestStepScan/index.native.js | 17 ++++++++++++++++- 4 files changed, 51 insertions(+), 3 deletions(-) diff --git a/src/pages/iou/request/step/IOURequestStepAmount.js b/src/pages/iou/request/step/IOURequestStepAmount.js index 9aec21dc9543..a7eaf8b77f30 100644 --- a/src/pages/iou/request/step/IOURequestStepAmount.js +++ b/src/pages/iou/request/step/IOURequestStepAmount.js @@ -83,6 +83,9 @@ function IOURequestStepAmount({ const isEditingSplitBill = isEditing && isSplitBill; const {amount: transactionAmount} = ReportUtils.getTransactionDetails(isEditingSplitBill && !lodashIsEmpty(splitDraftTransaction) ? splitDraftTransaction : transaction); const {currency} = ReportUtils.getTransactionDetails(isEditing ? draftTransaction : transaction); + + // For quick button actions, we'll skip the confirmation page unless the report is archived or this is a workspace request, as + // the user will have to add a merchant. const skipConfirmation = draftTransaction.skipConfirmation && !ReportUtils.isArchivedRoom(report) && !ReportUtils.isPolicyExpenseChat(report); useFocusEffect( diff --git a/src/pages/iou/request/step/IOURequestStepDistance.js b/src/pages/iou/request/step/IOURequestStepDistance.js index 4edd39061059..3bd3597e24cc 100644 --- a/src/pages/iou/request/step/IOURequestStepDistance.js +++ b/src/pages/iou/request/step/IOURequestStepDistance.js @@ -22,6 +22,7 @@ import * as ReportUtils from '@libs/ReportUtils'; import * as TransactionUtils from '@libs/TransactionUtils'; import personalDetailsPropType from '@pages/personalDetailsPropType'; import reportPropTypes from '@pages/reportPropTypes'; +import {policyPropTypes} from '@pages/workspace/withPolicy'; import variables from '@styles/variables'; import * as IOU from '@userActions/IOU'; import * as MapboxToken from '@userActions/MapboxToken'; @@ -42,6 +43,9 @@ const propTypes = { /** The report that the transaction belongs to */ report: reportPropTypes, + /** The policy of the report */ + ...policyPropTypes, + /** The transaction object being modified in Onyx */ transaction: transactionPropTypes, @@ -56,6 +60,7 @@ const propTypes = { const defaultProps = { report: {}, + policy: null, transaction: {}, transactionBackup: {}, personalDetails: {}, @@ -64,6 +69,7 @@ const defaultProps = { function IOURequestStepDistance({ report, + policy, route: { params: {action, iouType, reportID, transactionID, backTo}, }, @@ -98,7 +104,13 @@ function IOURequestStepDistance({ const atLeastTwoDifferentWaypointsError = useMemo(() => _.size(validatedWaypoints) < 2, [validatedWaypoints]); const isEditing = action === CONST.IOU.ACTION.EDIT; const isCreatingNewRequest = !(backTo || isEditing); - const skipConfirmation = transaction.skipConfirmation && !ReportUtils.isArchivedRoom(report); + + // For quick button actions, we'll skip the confirmation page unless the report is archived or this is a workspace + // request and the workspace requires a category or a tag + const skipConfirmation = + transaction.skipConfirmation && + !ReportUtils.isArchivedRoom(report) && + !(ReportUtils.isPolicyExpenseChat(reportID) && (lodashGet(policy, 'requiresCategory', false) || lodashGet(policy, 'requiresTag', false))); let buttonText = !isCreatingNewRequest ? translate('common.save') : translate('common.next'); if (skipConfirmation) { buttonText = iouType === CONST.IOU.TYPE.SPLIT ? translate('iou.split') : translate('iou.request'); @@ -347,6 +359,9 @@ export default compose( withWritableReportOrNotFound, withFullTransactionOrNotFound, withOnyx({ + policy: { + key: ({report}) => `${ONYXKEYS.COLLECTION.POLICY}${report ? report.policyID : '0'}`, + }, personalDetails: { key: ONYXKEYS.PERSONAL_DETAILS_LIST, }, diff --git a/src/pages/iou/request/step/IOURequestStepScan/index.js b/src/pages/iou/request/step/IOURequestStepScan/index.js index 5389193dc132..08cf5e8a6a3a 100644 --- a/src/pages/iou/request/step/IOURequestStepScan/index.js +++ b/src/pages/iou/request/step/IOURequestStepScan/index.js @@ -35,6 +35,7 @@ import withFullTransactionOrNotFound from '@pages/iou/request/step/withFullTrans import withWritableReportOrNotFound from '@pages/iou/request/step/withWritableReportOrNotFound'; import personalDetailsPropType from '@pages/personalDetailsPropType'; import reportPropTypes from '@pages/reportPropTypes'; +import {policyPropTypes} from '@pages/workspace/withPolicy'; import * as IOU from '@userActions/IOU'; import CONST from '@src/CONST'; import ONYXKEYS from '@src/ONYXKEYS'; @@ -49,6 +50,9 @@ const propTypes = { /** The report that the transaction belongs to */ report: reportPropTypes, + /** The policy of the report */ + ...policyPropTypes, + /** The transaction (or draft transaction) being changed */ transaction: transactionPropTypes, @@ -61,6 +65,7 @@ const propTypes = { const defaultProps = { report: {}, + policy: null, transaction: {}, personalDetails: {}, ...withCurrentUserPersonalDetailsDefaultProps, @@ -68,6 +73,7 @@ const defaultProps = { function IOURequestStepScan({ report, + policy, route: { params: {action, iouType, reportID, transactionID, backTo}, }, @@ -101,7 +107,13 @@ function IOURequestStepScan({ const [videoConstraints, setVideoConstraints] = useState(null); const tabIndex = 1; const isTabActive = useTabNavigatorFocus({tabIndex}); - const skipConfirmation = transaction.skipConfirmation && !ReportUtils.isArchivedRoom(report); + + // For quick button actions, we'll skip the confirmation page unless the report is archived or this is a workspace + // request and the workspace requires a category or a tag + const skipConfirmation = + transaction.skipConfirmation && + !ReportUtils.isArchivedRoom(report) && + !(ReportUtils.isPolicyExpenseChat(reportID) && (lodashGet(policy, 'requiresCategory', false) || lodashGet(policy, 'requiresTag', false))); /** * On phones that have ultra-wide lens, react-webcam uses ultra-wide by default. @@ -546,6 +558,9 @@ export default compose( withFullTransactionOrNotFound, withCurrentUserPersonalDetails, withOnyx({ + policy: { + key: ({report}) => `${ONYXKEYS.COLLECTION.POLICY}${report ? report.policyID : '0'}`, + }, personalDetails: { key: ONYXKEYS.PERSONAL_DETAILS_LIST, }, diff --git a/src/pages/iou/request/step/IOURequestStepScan/index.native.js b/src/pages/iou/request/step/IOURequestStepScan/index.native.js index 810934a86cd0..2dc22273b7f0 100644 --- a/src/pages/iou/request/step/IOURequestStepScan/index.native.js +++ b/src/pages/iou/request/step/IOURequestStepScan/index.native.js @@ -34,6 +34,7 @@ import withFullTransactionOrNotFound from '@pages/iou/request/step/withFullTrans import withWritableReportOrNotFound from '@pages/iou/request/step/withWritableReportOrNotFound'; import personalDetailsPropType from '@pages/personalDetailsPropType'; import reportPropTypes from '@pages/reportPropTypes'; +import {policyPropTypes} from '@pages/workspace/withPolicy'; import * as IOU from '@userActions/IOU'; import CONST from '@src/CONST'; import ONYXKEYS from '@src/ONYXKEYS'; @@ -49,6 +50,9 @@ const propTypes = { /** The report that the transaction belongs to */ report: reportPropTypes, + /** The policy of the report */ + ...policyPropTypes, + /** The transaction (or draft transaction) being changed */ transaction: transactionPropTypes, @@ -61,6 +65,7 @@ const propTypes = { const defaultProps = { report: {}, + policy: null, transaction: {}, personalDetails: {}, ...withCurrentUserPersonalDetailsDefaultProps, @@ -68,6 +73,7 @@ const defaultProps = { function IOURequestStepScan({ report, + policy, route: { params: {action, iouType, reportID, transactionID, backTo}, }, @@ -87,7 +93,13 @@ function IOURequestStepScan({ const [flash, setFlash] = useState(false); const [cameraPermissionStatus, setCameraPermissionStatus] = useState(undefined); const [didCapturePhoto, setDidCapturePhoto] = useState(false); - const skipConfirmation = transaction.skipConfirmation && !ReportUtils.isArchivedRoom(report); + + // For quick button actions, we'll skip the confirmation page unless the report is archived or this is a workspace + // request and the workspace requires a category or a tag + const skipConfirmation = + transaction.skipConfirmation && + !ReportUtils.isArchivedRoom(report) && + !(ReportUtils.isPolicyExpenseChat(reportID) && (lodashGet(policy, 'requiresCategory', false) || lodashGet(policy, 'requiresTag', false))); const {translate} = useLocalize(); @@ -443,6 +455,9 @@ export default compose( withFullTransactionOrNotFound, withCurrentUserPersonalDetails, withOnyx({ + policy: { + key: ({report}) => `${ONYXKEYS.COLLECTION.POLICY}${report ? report.policyID : '0'}`, + }, personalDetails: { key: ONYXKEYS.PERSONAL_DETAILS_LIST, }, From b969e75bcc6f71738250c192d32232e056859680 Mon Sep 17 00:00:00 2001 From: Alberto <alberto@expensify.com> Date: Wed, 3 Apr 2024 18:13:59 +0200 Subject: [PATCH 031/206] typescript --- src/pages/iou/steps/MoneyRequestAmountForm.tsx | 7 ++++--- src/types/onyx/Transaction.ts | 3 +++ 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/src/pages/iou/steps/MoneyRequestAmountForm.tsx b/src/pages/iou/steps/MoneyRequestAmountForm.tsx index 6986cc418519..0ef9d6c75e3f 100644 --- a/src/pages/iou/steps/MoneyRequestAmountForm.tsx +++ b/src/pages/iou/steps/MoneyRequestAmountForm.tsx @@ -2,6 +2,7 @@ import React, {useCallback, useEffect, useRef, useState} from 'react'; import type {ForwardedRef} from 'react'; import {View} from 'react-native'; import type {NativeSyntheticEvent, TextInputSelectionChangeEventData} from 'react-native'; +import type {ValueOf} from 'type-fest'; import BigNumberPad from '@components/BigNumberPad'; import Button from '@components/Button'; import FormHelpMessage from '@components/FormHelpMessage'; @@ -22,7 +23,7 @@ import type {BaseTextInputRef} from '@src/components/TextInput/BaseTextInput/typ import CONST from '@src/CONST'; import ROUTES, {AllRoutes} from '@src/ROUTES'; import type {SelectedTabRequest} from '@src/types/onyx'; -import paymentMethod from '@src/types/onyx/PaymentMethod'; +import {PaymentMethodType} from "@src/types/onyx/OriginalMessage"; type MoneyRequestAmountFormProps = { /** IOU amount saved in Onyx */ @@ -56,7 +57,7 @@ type MoneyRequestAmountFormProps = { onCurrencyButtonPress?: () => void; /** Fired when submit button pressed, saves the given amount and navigates to the next page */ - onSubmitButtonPress: ({amount, currency, paymentMethod}: {amount: string; currency: string; paymentMethod: string}) => void; + onSubmitButtonPress: ({amount, currency, paymentMethod}: {amount: string; currency?: string; paymentMethod: PaymentMethodType}) => void; /** The current tab we have navigated to in the request modal. String that corresponds to the request type. */ selectedTab?: SelectedTabRequest; @@ -248,7 +249,7 @@ function MoneyRequestAmountForm( * Submit amount and navigate to a proper page */ const submitAndNavigateToNextPage = useCallback( - (iouPaymentType) => { + (iouPaymentType: PaymentMethodType) => { if (isAmountInvalid(currentAmount)) { setFormError('iou.error.invalidAmount'); return; diff --git a/src/types/onyx/Transaction.ts b/src/types/onyx/Transaction.ts index 1750fa61e514..208c897ae5cb 100644 --- a/src/types/onyx/Transaction.ts +++ b/src/types/onyx/Transaction.ts @@ -214,6 +214,9 @@ type Transaction = OnyxCommon.OnyxValueWithOfflineFeedback< /** Indicates transaction loading */ isLoading?: boolean; + + /** If set, skip confirmation when creating the transaction */ + skipConfirmation?: boolean; }, keyof Comment >; From dc2216c082404adda0520e29ffac5f555ea4fb7c Mon Sep 17 00:00:00 2001 From: Alberto <alberto@expensify.com> Date: Wed, 3 Apr 2024 18:25:40 +0200 Subject: [PATCH 032/206] more typescript --- src/pages/iou/steps/MoneyRequestAmountForm.tsx | 5 +++-- src/types/onyx/Transaction.ts | 12 ++++++------ 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/src/pages/iou/steps/MoneyRequestAmountForm.tsx b/src/pages/iou/steps/MoneyRequestAmountForm.tsx index 0ef9d6c75e3f..4cb92b487157 100644 --- a/src/pages/iou/steps/MoneyRequestAmountForm.tsx +++ b/src/pages/iou/steps/MoneyRequestAmountForm.tsx @@ -25,6 +25,7 @@ import ROUTES, {AllRoutes} from '@src/ROUTES'; import type {SelectedTabRequest} from '@src/types/onyx'; import {PaymentMethodType} from "@src/types/onyx/OriginalMessage"; +type IouType = ValueOf<typeof CONST.IOU.TYPE>; type MoneyRequestAmountFormProps = { /** IOU amount saved in Onyx */ amount?: number; @@ -42,7 +43,7 @@ type MoneyRequestAmountFormProps = { skipConfirmation?: boolean; /** Type of the IOU */ - iouType?: ValueOf<typeof CONST.IOU.TYPE>; + iouType?: IouType; /** The policyID of the request */ policyID?: string; @@ -249,7 +250,7 @@ function MoneyRequestAmountForm( * Submit amount and navigate to a proper page */ const submitAndNavigateToNextPage = useCallback( - (iouPaymentType: PaymentMethodType) => { + (iouPaymentType: IouType | PaymentMethodType | undefined) => { if (isAmountInvalid(currentAmount)) { setFormError('iou.error.invalidAmount'); return; diff --git a/src/types/onyx/Transaction.ts b/src/types/onyx/Transaction.ts index 208c897ae5cb..3c95b3a5f736 100644 --- a/src/types/onyx/Transaction.ts +++ b/src/types/onyx/Transaction.ts @@ -100,7 +100,7 @@ type TaxRate = { type Transaction = OnyxCommon.OnyxValueWithOfflineFeedback< { /** The original transaction amount */ - amount: number; + amount?: number; /** The transaction tax amount */ taxAmount?: number; @@ -115,13 +115,13 @@ type Transaction = OnyxCommon.OnyxValueWithOfflineFeedback< category?: string; /** The comment object on the transaction */ - comment: Comment; + comment?: Comment; /** Date that the request was created */ - created: string; + created?: string; /** The original currency of the transaction */ - currency: string; + currency?: string; /** Any additional error message to show */ errors?: OnyxCommon.Errors | ReceiptErrors; @@ -136,7 +136,7 @@ type Transaction = OnyxCommon.OnyxValueWithOfflineFeedback< iouRequestType?: ValueOf<typeof CONST.IOU.REQUEST_TYPE>; /** The original merchant name */ - merchant: string; + merchant?: string; /** The edited transaction amount */ modifiedAmount?: number; @@ -166,7 +166,7 @@ type Transaction = OnyxCommon.OnyxValueWithOfflineFeedback< receipt?: Receipt; /** The iouReportID associated with the transaction */ - reportID: string; + reportID?: string; /** Existing routes */ routes?: Routes; From 98a4bad62b41dabf10d0bc649d118bd4889637c4 Mon Sep 17 00:00:00 2001 From: Alberto <alberto@expensify.com> Date: Wed, 3 Apr 2024 18:37:54 +0200 Subject: [PATCH 033/206] lint --- src/pages/iou/request/IOURequestStartPage.js | 2 +- src/pages/iou/request/step/IOURequestStepAmount.js | 1 - src/pages/iou/request/step/IOURequestStepConfirmation.js | 1 - src/pages/iou/request/step/IOURequestStepDistance.js | 2 +- src/pages/iou/request/step/IOURequestStepScan/index.js | 2 +- .../iou/request/step/IOURequestStepScan/index.native.js | 2 +- src/pages/iou/steps/MoneyRequestAmountForm.tsx | 5 +++-- src/pages/tasks/NewTaskTitlePage.tsx | 1 - 8 files changed, 7 insertions(+), 9 deletions(-) diff --git a/src/pages/iou/request/IOURequestStartPage.js b/src/pages/iou/request/IOURequestStartPage.js index 0add953b7b50..de57dca995d2 100644 --- a/src/pages/iou/request/IOURequestStartPage.js +++ b/src/pages/iou/request/IOURequestStartPage.js @@ -130,7 +130,7 @@ function IOURequestStartPage({ IOU.initMoneyRequest(reportID, policy, isFromGlobalCreate, newIouType, lodashGet(transaction, 'skipConfirmation', false)); transactionRequestType.current = newIouType; }, - [policy, previousIOURequestType, reportID, isFromGlobalCreate, iouType, navigation, transaction.isFromGlobalCreate], + [policy, previousIOURequestType, reportID, isFromGlobalCreate, iouType, navigation, transaction], ); if (!transaction.transactionID) { diff --git a/src/pages/iou/request/step/IOURequestStepAmount.js b/src/pages/iou/request/step/IOURequestStepAmount.js index a7eaf8b77f30..fbe930254474 100644 --- a/src/pages/iou/request/step/IOURequestStepAmount.js +++ b/src/pages/iou/request/step/IOURequestStepAmount.js @@ -1,7 +1,6 @@ import {useFocusEffect} from '@react-navigation/native'; import lodashGet from 'lodash/get'; import lodashIsEmpty from 'lodash/isEmpty'; -import PropTypes from 'prop-types'; import React, {useCallback, useEffect, useRef} from 'react'; import {withOnyx} from 'react-native-onyx'; import _ from 'underscore'; diff --git a/src/pages/iou/request/step/IOURequestStepConfirmation.js b/src/pages/iou/request/step/IOURequestStepConfirmation.js index 43bfb4c90989..0df9a7333e7a 100644 --- a/src/pages/iou/request/step/IOURequestStepConfirmation.js +++ b/src/pages/iou/request/step/IOURequestStepConfirmation.js @@ -428,7 +428,6 @@ function IOURequestStepConfirmation({ } if (requestType === CONST.IOU.REQUEST_TYPE.DISTANCE) { - console.log('here'); createDistanceRequest(selectedParticipants, trimmedComment); return; } diff --git a/src/pages/iou/request/step/IOURequestStepDistance.js b/src/pages/iou/request/step/IOURequestStepDistance.js index 3bd3597e24cc..2a27acaff15f 100644 --- a/src/pages/iou/request/step/IOURequestStepDistance.js +++ b/src/pages/iou/request/step/IOURequestStepDistance.js @@ -209,7 +209,7 @@ function IOURequestStepDistance({ // If there was no reportID, then that means the user started this flow from the global + menu // and an optimistic reportID was generated. In that case, the next step is to select the participants for this request. Navigation.navigate(ROUTES.MONEY_REQUEST_STEP_PARTICIPANTS.getRoute(iouType, transactionID, reportID)); - }, [report, iouType, reportID, transactionID, backTo, waypoints]); + }, [report, iouType, reportID, transactionID, backTo, waypoints, currentUserPersonalDetails, personalDetails, skipConfirmation, transaction, translate]); const getError = () => { // Get route error if available else show the invalid number of waypoints error. diff --git a/src/pages/iou/request/step/IOURequestStepScan/index.js b/src/pages/iou/request/step/IOURequestStepScan/index.js index 08cf5e8a6a3a..1b762717739a 100644 --- a/src/pages/iou/request/step/IOURequestStepScan/index.js +++ b/src/pages/iou/request/step/IOURequestStepScan/index.js @@ -274,7 +274,7 @@ function IOURequestStepScan({ } Navigation.navigate(ROUTES.MONEY_REQUEST_STEP_CONFIRMATION.getRoute(CONST.IOU.ACTION.CREATE, iouType, transactionID, reportID)); }, - [iouType, report, reportID, transactionID, isFromGlobalCreate, backTo], + [iouType, report, reportID, transactionID, isFromGlobalCreate, backTo, currentUserPersonalDetails, personalDetails, skipConfirmation, transaction], ); const updateScanAndNavigate = useCallback( diff --git a/src/pages/iou/request/step/IOURequestStepScan/index.native.js b/src/pages/iou/request/step/IOURequestStepScan/index.native.js index 2dc22273b7f0..cff3774fe69e 100644 --- a/src/pages/iou/request/step/IOURequestStepScan/index.native.js +++ b/src/pages/iou/request/step/IOURequestStepScan/index.native.js @@ -251,7 +251,7 @@ function IOURequestStepScan({ } Navigation.navigate(ROUTES.MONEY_REQUEST_STEP_CONFIRMATION.getRoute(CONST.IOU.ACTION.CREATE, iouType, transactionID, reportID)); }, - [iouType, report, reportID, transactionID, isFromGlobalCreate, backTo], + [iouType, report, reportID, transactionID, isFromGlobalCreate, backTo, currentUserPersonalDetails, personalDetails, skipConfirmation, transaction], ); const updateScanAndNavigate = useCallback( diff --git a/src/pages/iou/steps/MoneyRequestAmountForm.tsx b/src/pages/iou/steps/MoneyRequestAmountForm.tsx index 4cb92b487157..1cd8e9e1cb48 100644 --- a/src/pages/iou/steps/MoneyRequestAmountForm.tsx +++ b/src/pages/iou/steps/MoneyRequestAmountForm.tsx @@ -21,9 +21,10 @@ import * as MoneyRequestUtils from '@libs/MoneyRequestUtils'; import Navigation from '@libs/Navigation/Navigation'; import type {BaseTextInputRef} from '@src/components/TextInput/BaseTextInput/types'; import CONST from '@src/CONST'; -import ROUTES, {AllRoutes} from '@src/ROUTES'; +import type {AllRoutes} from '@src/ROUTES'; +import ROUTES from '@src/ROUTES'; import type {SelectedTabRequest} from '@src/types/onyx'; -import {PaymentMethodType} from "@src/types/onyx/OriginalMessage"; +import type {PaymentMethodType} from "@src/types/onyx/OriginalMessage"; type IouType = ValueOf<typeof CONST.IOU.TYPE>; type MoneyRequestAmountFormProps = { diff --git a/src/pages/tasks/NewTaskTitlePage.tsx b/src/pages/tasks/NewTaskTitlePage.tsx index f9c2d5d2e128..582d2a5c6500 100644 --- a/src/pages/tasks/NewTaskTitlePage.tsx +++ b/src/pages/tasks/NewTaskTitlePage.tsx @@ -15,7 +15,6 @@ import useThemeStyles from '@hooks/useThemeStyles'; import * as ErrorUtils from '@libs/ErrorUtils'; import Navigation from '@libs/Navigation/Navigation'; import type {NewTaskNavigatorParamList} from '@libs/Navigation/types'; -import * as ReportUtils from '@libs/ReportUtils'; import * as TaskActions from '@userActions/Task'; import CONST from '@src/CONST'; import ONYXKEYS from '@src/ONYXKEYS'; From 724c8332831c48f2641671c1bad531021a16cd2d Mon Sep 17 00:00:00 2001 From: Alberto <alberto@expensify.com> Date: Thu, 4 Apr 2024 13:23:46 +0200 Subject: [PATCH 034/206] more typescript --- src/types/onyx/Transaction.ts | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/types/onyx/Transaction.ts b/src/types/onyx/Transaction.ts index 76044a80dcfe..3508be8efb68 100644 --- a/src/types/onyx/Transaction.ts +++ b/src/types/onyx/Transaction.ts @@ -100,7 +100,7 @@ type TaxRate = { type Transaction = OnyxCommon.OnyxValueWithOfflineFeedback< { /** The original transaction amount */ - amount?: number; + amount: number; /** The transaction tax amount */ taxAmount?: number; @@ -118,13 +118,13 @@ type Transaction = OnyxCommon.OnyxValueWithOfflineFeedback< category?: string; /** The comment object on the transaction */ - comment?: Comment; + comment: Comment; /** Date that the request was created */ - created?: string; + created: string; /** The original currency of the transaction */ - currency?: string; + currency: string; /** Any additional error message to show */ errors?: OnyxCommon.Errors | ReceiptErrors; @@ -139,7 +139,7 @@ type Transaction = OnyxCommon.OnyxValueWithOfflineFeedback< iouRequestType?: ValueOf<typeof CONST.IOU.REQUEST_TYPE>; /** The original merchant name */ - merchant?: string; + merchant: string; /** The edited transaction amount */ modifiedAmount?: number; @@ -169,7 +169,7 @@ type Transaction = OnyxCommon.OnyxValueWithOfflineFeedback< receipt?: Receipt; /** The iouReportID associated with the transaction */ - reportID?: string; + reportID: string; /** Existing routes */ routes?: Routes; From 2575c8b0e97ca15211e2b3eaba41b093e53c9a8d Mon Sep 17 00:00:00 2001 From: Alberto <alberto@expensify.com> Date: Thu, 4 Apr 2024 13:55:30 +0200 Subject: [PATCH 035/206] still typescript --- src/pages/iou/steps/MoneyRequestAmountForm.tsx | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/pages/iou/steps/MoneyRequestAmountForm.tsx b/src/pages/iou/steps/MoneyRequestAmountForm.tsx index 5dd3931c7264..44d96cede3e7 100644 --- a/src/pages/iou/steps/MoneyRequestAmountForm.tsx +++ b/src/pages/iou/steps/MoneyRequestAmountForm.tsx @@ -62,7 +62,7 @@ type MoneyRequestAmountFormProps = { onCurrencyButtonPress?: () => void; /** Fired when submit button pressed, saves the given amount and navigates to the next page */ - onSubmitButtonPress: ({amount, currency, paymentMethod}: {amount: string; currency: string; paymentMethod: PaymentMethodType}) => void; + onSubmitButtonPress: ({amount, currency, paymentMethod}: {amount: string; currency: string; paymentMethod?: PaymentMethodType}) => void; /** The current tab we have navigated to in the request modal. String that corresponds to the request type. */ selectedTab?: SelectedTabRequest; @@ -253,7 +253,7 @@ function MoneyRequestAmountForm( * Submit amount and navigate to a proper page */ const submitAndNavigateToNextPage = useCallback( - (iouPaymentType: IouType | PaymentMethodType | undefined) => { + (iouPaymentType?: PaymentMethodType | undefined) => { if (isAmountInvalid(currentAmount)) { setFormError('iou.error.invalidAmount'); return; @@ -264,8 +264,8 @@ function MoneyRequestAmountForm( return; } - onSubmitButtonPress({amount: currentAmount, currency, paymentMethod: iouPaymentType}); - }, [currentAmount, taxAmount, isTaxAmountForm, onSubmitButtonPress, currency, formattedTaxAmount]); + onSubmitButtonPress({amount: currentAmount, currency, paymentMethod: iouPaymentType}); + }, [currentAmount, taxAmount, isTaxAmountForm, onSubmitButtonPress, currency, formattedTaxAmount]); /** * Input handler to check for a forward-delete key (or keyboard shortcut) press. @@ -380,7 +380,7 @@ function MoneyRequestAmountForm( medium={isExtraSmallScreenHeight} large={!isExtraSmallScreenHeight} style={[styles.w100, canUseTouchScreen ? styles.mt5 : styles.mt3]} - onPress={submitAndNavigateToNextPage} + onPress={() => submitAndNavigateToNextPage()} text={buttonText} /> )} From f884c75811bfbc4d320ae22bd09b6b90bf8bb38e Mon Sep 17 00:00:00 2001 From: Alberto <alberto@expensify.com> Date: Thu, 4 Apr 2024 18:23:18 +0200 Subject: [PATCH 036/206] more typescript --- src/types/onyx/Transaction.ts | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/types/onyx/Transaction.ts b/src/types/onyx/Transaction.ts index 3508be8efb68..d6864ba00727 100644 --- a/src/types/onyx/Transaction.ts +++ b/src/types/onyx/Transaction.ts @@ -97,7 +97,7 @@ type TaxRate = { data?: TaxRateData; }; -type Transaction = OnyxCommon.OnyxValueWithOfflineFeedback< +type FullTransaction = OnyxCommon.OnyxValueWithOfflineFeedback< { /** The original transaction amount */ amount: number; @@ -224,7 +224,7 @@ type Transaction = OnyxCommon.OnyxValueWithOfflineFeedback< keyof Comment >; -type TransactionPendingFieldsKey = KeysOfUnion<Transaction['pendingFields']>; +type TransactionPendingFieldsKey = KeysOfUnion<FullTransaction['pendingFields']>; type AdditionalTransactionChanges = { comment?: string; @@ -233,7 +233,13 @@ type AdditionalTransactionChanges = { oldCurrency?: string; }; -type TransactionChanges = Partial<Transaction> & AdditionalTransactionChanges; +type EmptyTransaction = { + skipConfirmation?: boolean; +}; + +type Transaction = FullTransaction | EmptyTransaction; + +type TransactionChanges = Partial<FullTransaction> & AdditionalTransactionChanges; type TransactionCollectionDataSet = CollectionDataSet<typeof ONYXKEYS.COLLECTION.TRANSACTION>; From 43d54724b2088cdeba98af29e847b5b1e9bcc4fb Mon Sep 17 00:00:00 2001 From: Alberto <alberto@expensify.com> Date: Thu, 4 Apr 2024 18:24:34 +0200 Subject: [PATCH 037/206] undo changes --- src/types/onyx/Transaction.ts | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/src/types/onyx/Transaction.ts b/src/types/onyx/Transaction.ts index d6864ba00727..900529f1a515 100644 --- a/src/types/onyx/Transaction.ts +++ b/src/types/onyx/Transaction.ts @@ -97,7 +97,7 @@ type TaxRate = { data?: TaxRateData; }; -type FullTransaction = OnyxCommon.OnyxValueWithOfflineFeedback< +type Transaction = OnyxCommon.OnyxValueWithOfflineFeedback< { /** The original transaction amount */ amount: number; @@ -224,7 +224,7 @@ type FullTransaction = OnyxCommon.OnyxValueWithOfflineFeedback< keyof Comment >; -type TransactionPendingFieldsKey = KeysOfUnion<FullTransaction['pendingFields']>; +type TransactionPendingFieldsKey = KeysOfUnion<Transaction['pendingFields']>; type AdditionalTransactionChanges = { comment?: string; @@ -233,13 +233,8 @@ type AdditionalTransactionChanges = { oldCurrency?: string; }; -type EmptyTransaction = { - skipConfirmation?: boolean; -}; - -type Transaction = FullTransaction | EmptyTransaction; -type TransactionChanges = Partial<FullTransaction> & AdditionalTransactionChanges; +type TransactionChanges = Partial<Transaction> & AdditionalTransactionChanges; type TransactionCollectionDataSet = CollectionDataSet<typeof ONYXKEYS.COLLECTION.TRANSACTION>; From 6eb6b5b97d33f6de8d5797b4bd9d6f7430b9b256 Mon Sep 17 00:00:00 2001 From: Alberto <alberto@expensify.com> Date: Thu, 4 Apr 2024 18:31:27 +0200 Subject: [PATCH 038/206] use new onyx key --- src/ONYXKEYS.ts | 1 + src/libs/actions/IOU.ts | 7 ++----- src/libs/actions/Policy.ts | 1 + .../iou/request/step/IOURequestStepAmount.js | 17 ++++++++++++++--- 4 files changed, 18 insertions(+), 8 deletions(-) diff --git a/src/ONYXKEYS.ts b/src/ONYXKEYS.ts index 46b2c5f8055c..8efeb350576f 100755 --- a/src/ONYXKEYS.ts +++ b/src/ONYXKEYS.ts @@ -337,6 +337,7 @@ const ONYXKEYS = { // Holds temporary transactions used during the creation and edit flow TRANSACTION_DRAFT: 'transactionsDraft_', + SKIP_CONFIRMATION: 'skipConfirmation_', SPLIT_TRANSACTION_DRAFT: 'splitTransactionDraft_', PRIVATE_NOTES_DRAFT: 'privateNotesDraft_', NEXT_STEP: 'reportNextStep_', diff --git a/src/libs/actions/IOU.ts b/src/libs/actions/IOU.ts index 8f00cea9a979..eefb2aa1f6c6 100644 --- a/src/libs/actions/IOU.ts +++ b/src/libs/actions/IOU.ts @@ -319,11 +319,8 @@ function initMoneyRequest( } function clearMoneyRequest(transactionID: string, skipConfirmation = false) { - if (skipConfirmation) { - Onyx.set(`${ONYXKEYS.COLLECTION.TRANSACTION_DRAFT}${transactionID}`, {skipConfirmation: true}); - } else { - Onyx.set(`${ONYXKEYS.COLLECTION.TRANSACTION_DRAFT}${transactionID}`, null); - } + Onyx.set(`${ONYXKEYS.COLLECTION.TRANSACTION_DRAFT}${transactionID}`, skipConfirmation); + Onyx.set(`${ONYXKEYS.COLLECTION.TRANSACTION_DRAFT}${transactionID}`, null); } /** diff --git a/src/libs/actions/Policy.ts b/src/libs/actions/Policy.ts index 08c493e0c0aa..9a6f31f4d64b 100644 --- a/src/libs/actions/Policy.ts +++ b/src/libs/actions/Policy.ts @@ -1359,6 +1359,7 @@ function addMembersToWorkspace(invitedEmailsToAccountIDs: InvitedEmailsToAccount welcomeNote: new ExpensiMark().replace(welcomeNote), policyID, }; + console.log(params); if (!isEmptyObject(membersChats.reportCreationData)) { params.reportCreationData = JSON.stringify(membersChats.reportCreationData); } diff --git a/src/pages/iou/request/step/IOURequestStepAmount.js b/src/pages/iou/request/step/IOURequestStepAmount.js index c3d2bad4e2e4..3358bc13b05a 100644 --- a/src/pages/iou/request/step/IOURequestStepAmount.js +++ b/src/pages/iou/request/step/IOURequestStepAmount.js @@ -45,6 +45,9 @@ const propTypes = { /** Whether the user input should be kept or not */ shouldKeepUserInput: PropTypes.bool, + /** Whether the confirmation step should be skipped */ + skipConfirmation: PropTypes.bool, + /** The draft transaction object being modified in Onyx */ draftTransaction: transactionPropTypes, @@ -63,6 +66,7 @@ const defaultProps = { splitDraftTransaction: {}, draftTransaction: {}, shouldKeepUserInput: false, + skipConfirmation: false, }; function IOURequestStepAmount({ @@ -77,6 +81,7 @@ function IOURequestStepAmount({ splitDraftTransaction, draftTransaction, shouldKeepUserInput, + skipConfirmation, }) { const {translate} = useLocalize(); const textInput = useRef(null); @@ -93,7 +98,7 @@ function IOURequestStepAmount({ // For quick button actions, we'll skip the confirmation page unless the report is archived or this is a workspace request, as // the user will have to add a merchant. - const skipConfirmation = draftTransaction.skipConfirmation && !ReportUtils.isArchivedRoom(report) && !ReportUtils.isPolicyExpenseChat(report); + const shouldSkipConfirmation = skipConfirmation && !ReportUtils.isArchivedRoom(report) && !ReportUtils.isPolicyExpenseChat(report); useFocusEffect( useCallback(() => { @@ -169,7 +174,7 @@ function IOURequestStepAmount({ }); const backendAmount = CurrencyUtils.convertToBackendAmount(Number.parseFloat(amount)); - if (skipConfirmation) { + if (shouldSkipConfirmation) { if (iouType === CONST.IOU.TYPE.SPLIT) { IOU.splitBillAndOpenReport(participants, currentUserPersonalDetails.login, currentUserPersonalDetails.accountID, backendAmount, '', currency, '', '', ''); return; @@ -245,7 +250,7 @@ function IOURequestStepAmount({ isEditing={Boolean(backTo || isEditing)} currency={currency} amount={Math.abs(transactionAmount)} - skipConfirmation={skipConfirmation} + skipConfirmation={shouldSkipConfirmation} iouType={iouType} policyID={policy.policyID} bankAccountRoute={ReportUtils.getBankAccountRoute(report)} @@ -286,5 +291,11 @@ export default compose( return `${ONYXKEYS.COLLECTION.TRANSACTION_DRAFT}${transactionID}`; }, }, + skipConfirmation: { + key: ({route}) => { + const transactionID = lodashGet(route, 'params.transactionID', 0); + return `${ONYXKEYS.COLLECTION.SKIP_CONFIRMATION}${transactionID}`; + }, + }, }), )(IOURequestStepAmount); From 4200aaa1272f6086d943f07c89c37f40b5aee60c Mon Sep 17 00:00:00 2001 From: Alberto <alberto@expensify.com> Date: Thu, 4 Apr 2024 18:34:17 +0200 Subject: [PATCH 039/206] apply change to distance --- src/libs/actions/IOU.ts | 2 +- .../request/step/IOURequestStepDistance.js | 20 +++++++++++++++---- 2 files changed, 17 insertions(+), 5 deletions(-) diff --git a/src/libs/actions/IOU.ts b/src/libs/actions/IOU.ts index eefb2aa1f6c6..230d55fd9d8e 100644 --- a/src/libs/actions/IOU.ts +++ b/src/libs/actions/IOU.ts @@ -319,7 +319,7 @@ function initMoneyRequest( } function clearMoneyRequest(transactionID: string, skipConfirmation = false) { - Onyx.set(`${ONYXKEYS.COLLECTION.TRANSACTION_DRAFT}${transactionID}`, skipConfirmation); + Onyx.set(`${ONYXKEYS.COLLECTION.SKIP_CONFIRMATION}${transactionID}`, skipConfirmation); Onyx.set(`${ONYXKEYS.COLLECTION.TRANSACTION_DRAFT}${transactionID}`, null); } diff --git a/src/pages/iou/request/step/IOURequestStepDistance.js b/src/pages/iou/request/step/IOURequestStepDistance.js index 6a4f076e6bfb..b951534bb8d8 100644 --- a/src/pages/iou/request/step/IOURequestStepDistance.js +++ b/src/pages/iou/request/step/IOURequestStepDistance.js @@ -34,6 +34,7 @@ import IOURequestStepRoutePropTypes from './IOURequestStepRoutePropTypes'; import StepScreenWrapper from './StepScreenWrapper'; import withFullTransactionOrNotFound from './withFullTransactionOrNotFound'; import withWritableReportOrNotFound from './withWritableReportOrNotFound'; +import PropTypes from "prop-types"; const propTypes = { /** Navigation route context info provided by react navigation */ @@ -52,6 +53,9 @@ const propTypes = { /** backup version of the original transaction */ transactionBackup: transactionPropTypes, + /** Whether the confirmation step should be skipped */ + skipConfirmation: PropTypes.bool, + /** Personal details of all users */ personalDetails: personalDetailsPropType, @@ -63,6 +67,7 @@ const defaultProps = { policy: null, transaction: {}, transactionBackup: {}, + skipConfirmation: false, personalDetails: {}, ...withCurrentUserPersonalDetailsDefaultProps, }; @@ -77,6 +82,7 @@ function IOURequestStepDistance({ transactionBackup, personalDetails, currentUserPersonalDetails, + skipConfirmation }) { const styles = useThemeStyles(); const {isOffline} = useNetwork(); @@ -107,12 +113,12 @@ function IOURequestStepDistance({ // For quick button actions, we'll skip the confirmation page unless the report is archived or this is a workspace // request and the workspace requires a category or a tag - const skipConfirmation = + const shouldSkipConfirmation = transaction.skipConfirmation && !ReportUtils.isArchivedRoom(report) && !(ReportUtils.isPolicyExpenseChat(reportID) && (lodashGet(policy, 'requiresCategory', false) || lodashGet(policy, 'requiresTag', false))); let buttonText = !isCreatingNewRequest ? translate('common.save') : translate('common.next'); - if (skipConfirmation) { + if (shouldSkipConfirmation) { buttonText = iouType === CONST.IOU.TYPE.SPLIT ? translate('iou.split') : translate('iou.request'); } @@ -169,7 +175,7 @@ function IOURequestStepDistance({ const participantAccountID = lodashGet(participant, 'accountID', 0); return participantAccountID ? OptionsListUtils.getParticipantsOption(participant, personalDetails) : OptionsListUtils.getReportOption(participant); }); - if (skipConfirmation) { + if (shouldSkipConfirmation) { if (iouType === CONST.IOU.TYPE.SPLIT) { IOU.splitBillAndOpenReport( participants, @@ -209,7 +215,7 @@ function IOURequestStepDistance({ // If there was no reportID, then that means the user started this flow from the global + menu // and an optimistic reportID was generated. In that case, the next step is to select the participants for this request. Navigation.navigate(ROUTES.MONEY_REQUEST_STEP_PARTICIPANTS.getRoute(iouType, transactionID, reportID)); - }, [report, iouType, reportID, transactionID, backTo, waypoints, currentUserPersonalDetails, personalDetails, skipConfirmation, transaction, translate]); + }, [report, iouType, reportID, transactionID, backTo, waypoints, currentUserPersonalDetails, personalDetails, shouldSkipConfirmation, transaction, translate]); const getError = () => { // Get route error if available else show the invalid number of waypoints error. @@ -368,5 +374,11 @@ export default compose( transactionBackup: { key: (props) => `${ONYXKEYS.COLLECTION.TRANSACTION_DRAFT}${props.transactionID}`, }, + skipConfirmation: { + key: ({route}) => { + const transactionID = lodashGet(route, 'params.transactionID', 0); + return `${ONYXKEYS.COLLECTION.SKIP_CONFIRMATION}${transactionID}`; + }, + }, }), )(IOURequestStepDistance); From 2b6391e2d2d68caa55071a9eb3598ab8a6b5aa8b Mon Sep 17 00:00:00 2001 From: Alberto <alberto@expensify.com> Date: Thu, 4 Apr 2024 18:37:40 +0200 Subject: [PATCH 040/206] apply changes to scan --- .../request/step/IOURequestStepDistance.js | 2 +- .../request/step/IOURequestStepScan/index.js | 20 +++++++++++++++---- .../step/IOURequestStepScan/index.native.js | 20 +++++++++++++++---- 3 files changed, 33 insertions(+), 9 deletions(-) diff --git a/src/pages/iou/request/step/IOURequestStepDistance.js b/src/pages/iou/request/step/IOURequestStepDistance.js index b951534bb8d8..1be7da701bd6 100644 --- a/src/pages/iou/request/step/IOURequestStepDistance.js +++ b/src/pages/iou/request/step/IOURequestStepDistance.js @@ -114,7 +114,7 @@ function IOURequestStepDistance({ // For quick button actions, we'll skip the confirmation page unless the report is archived or this is a workspace // request and the workspace requires a category or a tag const shouldSkipConfirmation = - transaction.skipConfirmation && + skipConfirmation && !ReportUtils.isArchivedRoom(report) && !(ReportUtils.isPolicyExpenseChat(reportID) && (lodashGet(policy, 'requiresCategory', false) || lodashGet(policy, 'requiresTag', false))); let buttonText = !isCreatingNewRequest ? translate('common.save') : translate('common.next'); diff --git a/src/pages/iou/request/step/IOURequestStepScan/index.js b/src/pages/iou/request/step/IOURequestStepScan/index.js index 1b762717739a..9c57a9b3c28f 100644 --- a/src/pages/iou/request/step/IOURequestStepScan/index.js +++ b/src/pages/iou/request/step/IOURequestStepScan/index.js @@ -41,6 +41,7 @@ import CONST from '@src/CONST'; import ONYXKEYS from '@src/ONYXKEYS'; import ROUTES from '@src/ROUTES'; import NavigationAwareCamera from './NavigationAwareCamera'; +import PropTypes from "prop-types"; const propTypes = { /** Navigation route context info provided by react navigation */ @@ -56,6 +57,9 @@ const propTypes = { /** The transaction (or draft transaction) being changed */ transaction: transactionPropTypes, + /** Whether the confirmation step should be skipped */ + skipConfirmation: PropTypes.bool, + /** Personal details of all users */ personalDetails: personalDetailsPropType, @@ -68,6 +72,7 @@ const defaultProps = { policy: null, transaction: {}, personalDetails: {}, + skipConfirmation: false, ...withCurrentUserPersonalDetailsDefaultProps, }; @@ -81,6 +86,7 @@ function IOURequestStepScan({ transaction: {isFromGlobalCreate}, personalDetails, currentUserPersonalDetails, + skipConfirmation, }) { const theme = useTheme(); const styles = useThemeStyles(); @@ -110,8 +116,8 @@ function IOURequestStepScan({ // For quick button actions, we'll skip the confirmation page unless the report is archived or this is a workspace // request and the workspace requires a category or a tag - const skipConfirmation = - transaction.skipConfirmation && + const shouldSkipConfirmation = + skipConfirmation && !ReportUtils.isArchivedRoom(report) && !(ReportUtils.isPolicyExpenseChat(reportID) && (lodashGet(policy, 'requiresCategory', false) || lodashGet(policy, 'requiresTag', false))); @@ -250,7 +256,7 @@ function IOURequestStepScan({ return participantAccountID ? OptionsListUtils.getParticipantsOption(participant, personalDetails) : OptionsListUtils.getReportOption(participant); }); - if (skipConfirmation) { + if (shouldSkipConfirmation) { const receipt = file; receipt.source = source; receipt.state = CONST.IOU.RECEIPT_STATE.SCANREADY; @@ -274,7 +280,7 @@ function IOURequestStepScan({ } Navigation.navigate(ROUTES.MONEY_REQUEST_STEP_CONFIRMATION.getRoute(CONST.IOU.ACTION.CREATE, iouType, transactionID, reportID)); }, - [iouType, report, reportID, transactionID, isFromGlobalCreate, backTo, currentUserPersonalDetails, personalDetails, skipConfirmation, transaction], + [iouType, report, reportID, transactionID, isFromGlobalCreate, backTo, currentUserPersonalDetails, personalDetails, shouldSkipConfirmation, transaction], ); const updateScanAndNavigate = useCallback( @@ -564,5 +570,11 @@ export default compose( personalDetails: { key: ONYXKEYS.PERSONAL_DETAILS_LIST, }, + skipConfirmation: { + key: ({route}) => { + const transactionID = lodashGet(route, 'params.transactionID', 0); + return `${ONYXKEYS.COLLECTION.SKIP_CONFIRMATION}${transactionID}`; + }, + }, }), )(IOURequestStepScan); diff --git a/src/pages/iou/request/step/IOURequestStepScan/index.native.js b/src/pages/iou/request/step/IOURequestStepScan/index.native.js index cff3774fe69e..ac8a788c2584 100644 --- a/src/pages/iou/request/step/IOURequestStepScan/index.native.js +++ b/src/pages/iou/request/step/IOURequestStepScan/index.native.js @@ -41,6 +41,7 @@ import ONYXKEYS from '@src/ONYXKEYS'; import ROUTES from '@src/ROUTES'; import * as CameraPermission from './CameraPermission'; import NavigationAwareCamera from './NavigationAwareCamera'; +import PropTypes from "prop-types"; const propTypes = { /** Navigation route context info provided by react navigation */ @@ -56,6 +57,9 @@ const propTypes = { /** The transaction (or draft transaction) being changed */ transaction: transactionPropTypes, + /** Whether the confirmation step should be skipped */ + skipConfirmation: PropTypes.bool, + /** Personal details of all users */ personalDetails: personalDetailsPropType, @@ -68,6 +72,7 @@ const defaultProps = { policy: null, transaction: {}, personalDetails: {}, + skipConfirmation: false, ...withCurrentUserPersonalDetailsDefaultProps, }; @@ -81,6 +86,7 @@ function IOURequestStepScan({ transaction: {isFromGlobalCreate}, personalDetails, currentUserPersonalDetails, + skipConfirmation }) { const theme = useTheme(); const styles = useThemeStyles(); @@ -96,8 +102,8 @@ function IOURequestStepScan({ // For quick button actions, we'll skip the confirmation page unless the report is archived or this is a workspace // request and the workspace requires a category or a tag - const skipConfirmation = - transaction.skipConfirmation && + const shouldSkipConfirmation = + skipConfirmation && !ReportUtils.isArchivedRoom(report) && !(ReportUtils.isPolicyExpenseChat(reportID) && (lodashGet(policy, 'requiresCategory', false) || lodashGet(policy, 'requiresTag', false))); @@ -227,7 +233,7 @@ function IOURequestStepScan({ return participantAccountID ? OptionsListUtils.getParticipantsOption(participant, personalDetails) : OptionsListUtils.getReportOption(participant); }); - if (skipConfirmation) { + if (shouldSkipConfirmation) { const receipt = file; receipt.source = source; receipt.state = CONST.IOU.RECEIPT_STATE.SCANREADY; @@ -251,7 +257,7 @@ function IOURequestStepScan({ } Navigation.navigate(ROUTES.MONEY_REQUEST_STEP_CONFIRMATION.getRoute(CONST.IOU.ACTION.CREATE, iouType, transactionID, reportID)); }, - [iouType, report, reportID, transactionID, isFromGlobalCreate, backTo, currentUserPersonalDetails, personalDetails, skipConfirmation, transaction], + [iouType, report, reportID, transactionID, isFromGlobalCreate, backTo, currentUserPersonalDetails, personalDetails, shouldSkipConfirmation, transaction], ); const updateScanAndNavigate = useCallback( @@ -461,5 +467,11 @@ export default compose( personalDetails: { key: ONYXKEYS.PERSONAL_DETAILS_LIST, }, + skipConfirmation: { + key: ({route}) => { + const transactionID = lodashGet(route, 'params.transactionID', 0); + return `${ONYXKEYS.COLLECTION.SKIP_CONFIRMATION}${transactionID}`; + }, + }, }), )(IOURequestStepScan); From d3496ee39b42fba185ef1d5b742b7f7a880c5f00 Mon Sep 17 00:00:00 2001 From: Alberto <alberto@expensify.com> Date: Thu, 4 Apr 2024 18:39:02 +0200 Subject: [PATCH 041/206] prettier --- src/pages/iou/request/step/IOURequestStepDistance.js | 4 ++-- src/pages/iou/request/step/IOURequestStepScan/index.js | 2 +- .../iou/request/step/IOURequestStepScan/index.native.js | 4 ++-- src/pages/iou/steps/MoneyRequestAmountForm.tsx | 6 ++++-- src/types/onyx/Transaction.ts | 1 - 5 files changed, 9 insertions(+), 8 deletions(-) diff --git a/src/pages/iou/request/step/IOURequestStepDistance.js b/src/pages/iou/request/step/IOURequestStepDistance.js index 1be7da701bd6..35d692575c9a 100644 --- a/src/pages/iou/request/step/IOURequestStepDistance.js +++ b/src/pages/iou/request/step/IOURequestStepDistance.js @@ -1,4 +1,5 @@ import lodashGet from 'lodash/get'; +import PropTypes from 'prop-types'; import React, {useCallback, useEffect, useMemo, useRef, useState} from 'react'; import {View} from 'react-native'; import {withOnyx} from 'react-native-onyx'; @@ -34,7 +35,6 @@ import IOURequestStepRoutePropTypes from './IOURequestStepRoutePropTypes'; import StepScreenWrapper from './StepScreenWrapper'; import withFullTransactionOrNotFound from './withFullTransactionOrNotFound'; import withWritableReportOrNotFound from './withWritableReportOrNotFound'; -import PropTypes from "prop-types"; const propTypes = { /** Navigation route context info provided by react navigation */ @@ -82,7 +82,7 @@ function IOURequestStepDistance({ transactionBackup, personalDetails, currentUserPersonalDetails, - skipConfirmation + skipConfirmation, }) { const styles = useThemeStyles(); const {isOffline} = useNetwork(); diff --git a/src/pages/iou/request/step/IOURequestStepScan/index.js b/src/pages/iou/request/step/IOURequestStepScan/index.js index 9c57a9b3c28f..9a366f1c35c3 100644 --- a/src/pages/iou/request/step/IOURequestStepScan/index.js +++ b/src/pages/iou/request/step/IOURequestStepScan/index.js @@ -1,4 +1,5 @@ import lodashGet from 'lodash/get'; +import PropTypes from 'prop-types'; import React, {useCallback, useContext, useEffect, useReducer, useRef, useState} from 'react'; import {ActivityIndicator, PanResponder, PixelRatio, View} from 'react-native'; import {withOnyx} from 'react-native-onyx'; @@ -41,7 +42,6 @@ import CONST from '@src/CONST'; import ONYXKEYS from '@src/ONYXKEYS'; import ROUTES from '@src/ROUTES'; import NavigationAwareCamera from './NavigationAwareCamera'; -import PropTypes from "prop-types"; const propTypes = { /** Navigation route context info provided by react navigation */ diff --git a/src/pages/iou/request/step/IOURequestStepScan/index.native.js b/src/pages/iou/request/step/IOURequestStepScan/index.native.js index ac8a788c2584..16ddf9890ab7 100644 --- a/src/pages/iou/request/step/IOURequestStepScan/index.native.js +++ b/src/pages/iou/request/step/IOURequestStepScan/index.native.js @@ -1,6 +1,7 @@ import {useFocusEffect} from '@react-navigation/core'; import _ from '@types/underscore'; import lodashGet from 'lodash/get'; +import PropTypes from 'prop-types'; import React, {useCallback, useRef, useState} from 'react'; import {ActivityIndicator, Alert, AppState, InteractionManager, View} from 'react-native'; import {Gesture, GestureDetector} from 'react-native-gesture-handler'; @@ -41,7 +42,6 @@ import ONYXKEYS from '@src/ONYXKEYS'; import ROUTES from '@src/ROUTES'; import * as CameraPermission from './CameraPermission'; import NavigationAwareCamera from './NavigationAwareCamera'; -import PropTypes from "prop-types"; const propTypes = { /** Navigation route context info provided by react navigation */ @@ -86,7 +86,7 @@ function IOURequestStepScan({ transaction: {isFromGlobalCreate}, personalDetails, currentUserPersonalDetails, - skipConfirmation + skipConfirmation, }) { const theme = useTheme(); const styles = useThemeStyles(); diff --git a/src/pages/iou/steps/MoneyRequestAmountForm.tsx b/src/pages/iou/steps/MoneyRequestAmountForm.tsx index 44d96cede3e7..9e28fa21c27b 100644 --- a/src/pages/iou/steps/MoneyRequestAmountForm.tsx +++ b/src/pages/iou/steps/MoneyRequestAmountForm.tsx @@ -24,7 +24,7 @@ import CONST from '@src/CONST'; import type {AllRoutes} from '@src/ROUTES'; import ROUTES from '@src/ROUTES'; import type {SelectedTabRequest} from '@src/types/onyx'; -import type {PaymentMethodType} from "@src/types/onyx/OriginalMessage"; +import type {PaymentMethodType} from '@src/types/onyx/OriginalMessage'; type IouType = ValueOf<typeof CONST.IOU.TYPE>; type MoneyRequestAmountFormProps = { @@ -265,7 +265,9 @@ function MoneyRequestAmountForm( } onSubmitButtonPress({amount: currentAmount, currency, paymentMethod: iouPaymentType}); - }, [currentAmount, taxAmount, isTaxAmountForm, onSubmitButtonPress, currency, formattedTaxAmount]); + }, + [currentAmount, taxAmount, isTaxAmountForm, onSubmitButtonPress, currency, formattedTaxAmount], + ); /** * Input handler to check for a forward-delete key (or keyboard shortcut) press. diff --git a/src/types/onyx/Transaction.ts b/src/types/onyx/Transaction.ts index 900529f1a515..3508be8efb68 100644 --- a/src/types/onyx/Transaction.ts +++ b/src/types/onyx/Transaction.ts @@ -233,7 +233,6 @@ type AdditionalTransactionChanges = { oldCurrency?: string; }; - type TransactionChanges = Partial<Transaction> & AdditionalTransactionChanges; type TransactionCollectionDataSet = CollectionDataSet<typeof ONYXKEYS.COLLECTION.TRANSACTION>; From 86fb2c386a1d9b58745214a9d67036dc531b9b9c Mon Sep 17 00:00:00 2001 From: Alberto <alberto@expensify.com> Date: Thu, 4 Apr 2024 18:40:20 +0200 Subject: [PATCH 042/206] typing fixes --- src/ONYXKEYS.ts | 1 + src/types/onyx/Transaction.ts | 3 --- 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/src/ONYXKEYS.ts b/src/ONYXKEYS.ts index 8efeb350576f..44dca5241a72 100755 --- a/src/ONYXKEYS.ts +++ b/src/ONYXKEYS.ts @@ -532,6 +532,7 @@ type OnyxCollectionValuesMapping = { [ONYXKEYS.COLLECTION.SECURITY_GROUP]: OnyxTypes.SecurityGroup; [ONYXKEYS.COLLECTION.TRANSACTION]: OnyxTypes.Transaction; [ONYXKEYS.COLLECTION.TRANSACTION_DRAFT]: OnyxTypes.Transaction; + [ONYXKEYS.COLLECTION.SKIP_CONFIRMATION]: boolean; [ONYXKEYS.COLLECTION.TRANSACTION_VIOLATIONS]: OnyxTypes.TransactionViolations; [ONYXKEYS.COLLECTION.SPLIT_TRANSACTION_DRAFT]: OnyxTypes.Transaction; [ONYXKEYS.COLLECTION.POLICY_RECENTLY_USED_TAGS]: OnyxTypes.RecentlyUsedTags; diff --git a/src/types/onyx/Transaction.ts b/src/types/onyx/Transaction.ts index 3508be8efb68..8d05a9af5bd7 100644 --- a/src/types/onyx/Transaction.ts +++ b/src/types/onyx/Transaction.ts @@ -217,9 +217,6 @@ type Transaction = OnyxCommon.OnyxValueWithOfflineFeedback< /** Indicates transaction loading */ isLoading?: boolean; - - /** If set, skip confirmation when creating the transaction */ - skipConfirmation?: boolean; }, keyof Comment >; From c34e016fef156c1504835161315d8f4364d69c1a Mon Sep 17 00:00:00 2001 From: Alberto <alberto@expensify.com> Date: Thu, 4 Apr 2024 18:59:52 +0200 Subject: [PATCH 043/206] lint --- src/libs/actions/Policy.ts | 1 - src/pages/iou/request/step/IOURequestStepAmount.js | 1 + 2 files changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libs/actions/Policy.ts b/src/libs/actions/Policy.ts index 83eb869a5fa4..977a5c4087d0 100644 --- a/src/libs/actions/Policy.ts +++ b/src/libs/actions/Policy.ts @@ -1359,7 +1359,6 @@ function addMembersToWorkspace(invitedEmailsToAccountIDs: InvitedEmailsToAccount welcomeNote: new ExpensiMark().replace(welcomeNote), policyID, }; - console.log(params); if (!isEmptyObject(membersChats.reportCreationData)) { params.reportCreationData = JSON.stringify(membersChats.reportCreationData); } diff --git a/src/pages/iou/request/step/IOURequestStepAmount.js b/src/pages/iou/request/step/IOURequestStepAmount.js index bab8fcb03ff7..80575eb5fc19 100644 --- a/src/pages/iou/request/step/IOURequestStepAmount.js +++ b/src/pages/iou/request/step/IOURequestStepAmount.js @@ -1,3 +1,4 @@ +import PropTypes from 'prop-types'; import {useFocusEffect} from '@react-navigation/native'; import lodashGet from 'lodash/get'; import lodashIsEmpty from 'lodash/isEmpty'; From 9fa58023855b8c119324acd18179835118580783 Mon Sep 17 00:00:00 2001 From: Alberto <alberto@expensify.com> Date: Thu, 4 Apr 2024 19:00:36 +0200 Subject: [PATCH 044/206] remove extra param --- src/libs/actions/IOU.ts | 2 -- src/pages/iou/request/IOURequestStartPage.js | 4 ++-- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/src/libs/actions/IOU.ts b/src/libs/actions/IOU.ts index 9fcd2ee0eca2..435460bc6319 100644 --- a/src/libs/actions/IOU.ts +++ b/src/libs/actions/IOU.ts @@ -280,7 +280,6 @@ function initMoneyRequest( policy: OnyxEntry<OnyxTypes.Policy>, isFromGlobalCreate: boolean, iouRequestType: IOURequestType = CONST.IOU.REQUEST_TYPE.MANUAL, - skipConfirmation = false, ) { // Generate a brand new transactionID const newTransactionID = CONST.IOU.OPTIMISTIC_TRANSACTION_ID; @@ -314,7 +313,6 @@ function initMoneyRequest( reportID, transactionID: newTransactionID, isFromGlobalCreate, - skipConfirmation, merchant: CONST.TRANSACTION.PARTIAL_TRANSACTION_MERCHANT, }); } diff --git a/src/pages/iou/request/IOURequestStartPage.js b/src/pages/iou/request/IOURequestStartPage.js index de57dca995d2..2ec6561c7975 100644 --- a/src/pages/iou/request/IOURequestStartPage.js +++ b/src/pages/iou/request/IOURequestStartPage.js @@ -105,7 +105,7 @@ function IOURequestStartPage({ if (transaction.reportID === reportID) { return; } - IOU.initMoneyRequest(reportID, policy, isFromGlobalCreate, transactionRequestType.current, lodashGet(transaction, 'skipConfirmation', false)); + IOU.initMoneyRequest(reportID, policy, isFromGlobalCreate, transactionRequestType.current); }, [transaction, policy, reportID, iouType, isFromGlobalCreate]); const isExpenseChat = ReportUtils.isPolicyExpenseChat(report); @@ -127,7 +127,7 @@ function IOURequestStartPage({ if (iouType === CONST.IOU.TYPE.SPLIT && transaction.isFromGlobalCreate) { IOU.updateMoneyRequestTypeParams(navigation.getState().routes, CONST.IOU.TYPE.REQUEST, newIouType); } - IOU.initMoneyRequest(reportID, policy, isFromGlobalCreate, newIouType, lodashGet(transaction, 'skipConfirmation', false)); + IOU.initMoneyRequest(reportID, policy, isFromGlobalCreate, newIouType); transactionRequestType.current = newIouType; }, [policy, previousIOURequestType, reportID, isFromGlobalCreate, iouType, navigation, transaction], From af5032909fe465c93be3bc85f1cafed42243b551 Mon Sep 17 00:00:00 2001 From: Alberto <alberto@expensify.com> Date: Thu, 4 Apr 2024 19:09:15 +0200 Subject: [PATCH 045/206] Assign tax button update --- src/pages/tasks/NewTaskDetailsPage.tsx | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/pages/tasks/NewTaskDetailsPage.tsx b/src/pages/tasks/NewTaskDetailsPage.tsx index 2c866ebf47bb..bec04de3b4ec 100644 --- a/src/pages/tasks/NewTaskDetailsPage.tsx +++ b/src/pages/tasks/NewTaskDetailsPage.tsx @@ -43,6 +43,7 @@ function NewTaskDetailsPage({task}: NewTaskDetailsPageProps) { const {inputCallbackRef} = useAutoFocusInput(); const skipConfirmation = task?.skipConfirmation && task?.assigneeAccountID && task?.parentReportID; + const buttonText = skipConfirmation ? translate('newTaskPage.assignTask') : translate('common.next'); useEffect(() => { setTaskTitle(task?.title ?? ''); @@ -100,7 +101,7 @@ function NewTaskDetailsPage({task}: NewTaskDetailsPageProps) { /> <FormProvider formID={ONYXKEYS.FORMS.NEW_TASK_FORM} - submitButtonText={translate('common.next')} + submitButtonText={buttonText} style={[styles.mh5, styles.flexGrow1]} validate={validate} onSubmit={onSubmit} From 0b5acd9b241c64291d62c55d28e809d02b5264f9 Mon Sep 17 00:00:00 2001 From: Alberto <alberto@expensify.com> Date: Thu, 4 Apr 2024 19:18:43 +0200 Subject: [PATCH 046/206] prettier --- src/libs/actions/IOU.ts | 7 +------ src/pages/iou/request/step/IOURequestStepAmount.js | 2 +- src/pages/iou/steps/MoneyRequestAmountForm.tsx | 14 ++++++++------ 3 files changed, 10 insertions(+), 13 deletions(-) diff --git a/src/libs/actions/IOU.ts b/src/libs/actions/IOU.ts index 435460bc6319..8f433a49d27c 100644 --- a/src/libs/actions/IOU.ts +++ b/src/libs/actions/IOU.ts @@ -275,12 +275,7 @@ function getPolicy(policyID: string | undefined): OnyxTypes.Policy | EmptyObject * @param iouRequestType one of manual/scan/distance * @param skipConfirmation if true, skip confirmation step */ -function initMoneyRequest( - reportID: string, - policy: OnyxEntry<OnyxTypes.Policy>, - isFromGlobalCreate: boolean, - iouRequestType: IOURequestType = CONST.IOU.REQUEST_TYPE.MANUAL, -) { +function initMoneyRequest(reportID: string, policy: OnyxEntry<OnyxTypes.Policy>, isFromGlobalCreate: boolean, iouRequestType: IOURequestType = CONST.IOU.REQUEST_TYPE.MANUAL) { // Generate a brand new transactionID const newTransactionID = CONST.IOU.OPTIMISTIC_TRANSACTION_ID; // Disabling this line since currentDate can be an empty string diff --git a/src/pages/iou/request/step/IOURequestStepAmount.js b/src/pages/iou/request/step/IOURequestStepAmount.js index 80575eb5fc19..87a15a5c1063 100644 --- a/src/pages/iou/request/step/IOURequestStepAmount.js +++ b/src/pages/iou/request/step/IOURequestStepAmount.js @@ -1,7 +1,7 @@ -import PropTypes from 'prop-types'; import {useFocusEffect} from '@react-navigation/native'; import lodashGet from 'lodash/get'; import lodashIsEmpty from 'lodash/isEmpty'; +import PropTypes from 'prop-types'; import React, {useCallback, useEffect, useRef} from 'react'; import {withOnyx} from 'react-native-onyx'; import _ from 'underscore'; diff --git a/src/pages/iou/steps/MoneyRequestAmountForm.tsx b/src/pages/iou/steps/MoneyRequestAmountForm.tsx index 278215932c91..99aaf50ac4eb 100644 --- a/src/pages/iou/steps/MoneyRequestAmountForm.tsx +++ b/src/pages/iou/steps/MoneyRequestAmountForm.tsx @@ -263,13 +263,15 @@ function MoneyRequestAmountForm( return; } - // Update display amount string post-edit to ensure consistency with backend amount - // Reference: https://github.com/Expensify/App/issues/30505 - const backendAmount = CurrencyUtils.convertToBackendAmount(Number.parseFloat(currentAmount)); - initializeAmount(backendAmount); + // Update display amount string post-edit to ensure consistency with backend amount + // Reference: https://github.com/Expensify/App/issues/30505 + const backendAmount = CurrencyUtils.convertToBackendAmount(Number.parseFloat(currentAmount)); + initializeAmount(backendAmount); - onSubmitButtonPress({amount: currentAmount, currency, paymentMethod: iouPaymentType}); - }, [currentAmount, taxAmount, isTaxAmountForm, onSubmitButtonPress, currency, formattedTaxAmount, initializeAmount]); + onSubmitButtonPress({amount: currentAmount, currency, paymentMethod: iouPaymentType}); + }, + [currentAmount, taxAmount, isTaxAmountForm, onSubmitButtonPress, currency, formattedTaxAmount, initializeAmount], + ); /** * Input handler to check for a forward-delete key (or keyboard shortcut) press. From 782f274ff7a5ec053b421c72ae3b5fa597517ba8 Mon Sep 17 00:00:00 2001 From: Alberto <alberto@expensify.com> Date: Thu, 4 Apr 2024 19:49:29 +0200 Subject: [PATCH 047/206] Display correct button if report is missing --- src/pages/iou/request/step/IOURequestStepAmount.js | 2 +- src/pages/iou/request/step/IOURequestStepDistance.js | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/src/pages/iou/request/step/IOURequestStepAmount.js b/src/pages/iou/request/step/IOURequestStepAmount.js index 87a15a5c1063..a155df8c85b6 100644 --- a/src/pages/iou/request/step/IOURequestStepAmount.js +++ b/src/pages/iou/request/step/IOURequestStepAmount.js @@ -93,7 +93,7 @@ function IOURequestStepAmount({ // For quick button actions, we'll skip the confirmation page unless the report is archived or this is a workspace request, as // the user will have to add a merchant. - const shouldSkipConfirmation = skipConfirmation && !ReportUtils.isArchivedRoom(report) && !ReportUtils.isPolicyExpenseChat(report); + const shouldSkipConfirmation = skipConfirmation && report.reportID && !ReportUtils.isArchivedRoom(report) && !ReportUtils.isPolicyExpenseChat(report); useFocusEffect( useCallback(() => { diff --git a/src/pages/iou/request/step/IOURequestStepDistance.js b/src/pages/iou/request/step/IOURequestStepDistance.js index 35d692575c9a..bd2fa1e5db3f 100644 --- a/src/pages/iou/request/step/IOURequestStepDistance.js +++ b/src/pages/iou/request/step/IOURequestStepDistance.js @@ -115,6 +115,7 @@ function IOURequestStepDistance({ // request and the workspace requires a category or a tag const shouldSkipConfirmation = skipConfirmation && + report.reportID && !ReportUtils.isArchivedRoom(report) && !(ReportUtils.isPolicyExpenseChat(reportID) && (lodashGet(policy, 'requiresCategory', false) || lodashGet(policy, 'requiresTag', false))); let buttonText = !isCreatingNewRequest ? translate('common.save') : translate('common.next'); From a6941175c2b321a40d89abbd90c074a13607e9b3 Mon Sep 17 00:00:00 2001 From: Alberto <alberto@expensify.com> Date: Thu, 4 Apr 2024 19:52:03 +0200 Subject: [PATCH 048/206] go to user serlection if report is missing or archived --- src/pages/iou/request/step/IOURequestStepAmount.js | 2 +- src/pages/iou/request/step/IOURequestStepDistance.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/pages/iou/request/step/IOURequestStepAmount.js b/src/pages/iou/request/step/IOURequestStepAmount.js index a155df8c85b6..d9a5d1bd4d53 100644 --- a/src/pages/iou/request/step/IOURequestStepAmount.js +++ b/src/pages/iou/request/step/IOURequestStepAmount.js @@ -161,7 +161,7 @@ function IOURequestStepAmount({ // If a reportID exists in the report object, it's because the user started this flow from using the + button in the composer // inside a report. In this case, the participants can be automatically assigned from the report and the user can skip the participants step and go straight // to the confirm step. - if (report.reportID) { + if (report.reportID && !ReportUtils.isArchivedRoom(report)) { const selectedParticipants = IOU.setMoneyRequestParticipantsFromReport(transactionID, report); const participants = _.map(selectedParticipants, (participant) => { const participantAccountID = lodashGet(participant, 'accountID', 0); diff --git a/src/pages/iou/request/step/IOURequestStepDistance.js b/src/pages/iou/request/step/IOURequestStepDistance.js index bd2fa1e5db3f..21d6d5e1dfc0 100644 --- a/src/pages/iou/request/step/IOURequestStepDistance.js +++ b/src/pages/iou/request/step/IOURequestStepDistance.js @@ -170,7 +170,7 @@ function IOURequestStepDistance({ // If a reportID exists in the report object, it's because the user started this flow from using the + button in the composer // inside a report. In this case, the participants can be automatically assigned from the report and the user can skip the participants step and go straight // to the confirm step. - if (report.reportID) { + if (report.reportID && !ReportUtils.isArchivedRoom(report)) { const selectedParticipants = IOU.setMoneyRequestParticipantsFromReport(transactionID, report); const participants = _.map(selectedParticipants, (participant) => { const participantAccountID = lodashGet(participant, 'accountID', 0); From c96e51630fffd927b067c26ddd58b5104d79a54b Mon Sep 17 00:00:00 2001 From: Adam Grzybowski <adam.grzybowski@swmansion.com> Date: Fri, 5 Apr 2024 06:26:34 +0200 Subject: [PATCH 049/206] migrate search page to find page v1 --- src/ROUTES.ts | 2 +- src/SCREENS.ts | 4 ++-- src/libs/E2E/tests/openSearchPageTest.e2e.ts | 2 +- src/libs/Navigation/AppNavigator/AuthScreens.tsx | 2 +- .../AppNavigator/ModalStackNavigators/index.tsx | 6 +++--- .../AppNavigator/Navigators/LeftModalNavigator.tsx | 2 +- .../createCustomBottomTabNavigator/TopBar.tsx | 2 +- src/libs/Navigation/linkingConfig/config.ts | 4 ++-- src/libs/Navigation/types.ts | 10 +++++----- src/pages/SearchPage/index.tsx | 2 +- 10 files changed, 18 insertions(+), 18 deletions(-) diff --git a/src/ROUTES.ts b/src/ROUTES.ts index 8130c271a2db..0224270aa878 100644 --- a/src/ROUTES.ts +++ b/src/ROUTES.ts @@ -26,7 +26,7 @@ const ROUTES = { route: 'flag/:reportID/:reportActionID', getRoute: (reportID: string, reportActionID: string) => `flag/${reportID}/${reportActionID}` as const, }, - SEARCH: 'search', + FIND: 'find', DETAILS: { route: 'details', getRoute: (login: string) => `details?login=${encodeURIComponent(login)}` as const, diff --git a/src/SCREENS.ts b/src/SCREENS.ts index cf864fd96b3e..0006e243ee1e 100644 --- a/src/SCREENS.ts +++ b/src/SCREENS.ts @@ -93,7 +93,7 @@ const SCREENS = { ROOT: 'SaveTheWorld_Root', }, LEFT_MODAL: { - SEARCH: 'Search', + FIND: 'Find', WORKSPACE_SWITCHER: 'WorkspaceSwitcher', }, WORKSPACE_SWITCHER: { @@ -292,7 +292,7 @@ const SCREENS = { REPORT_PARTICIPANTS_ROOT: 'ReportParticipants_Root', ROOM_MEMBERS_ROOT: 'RoomMembers_Root', ROOM_INVITE_ROOT: 'RoomInvite_Root', - SEARCH_ROOT: 'Search_Root', + FIND_ROOT: 'FIND_Root', FLAG_COMMENT_ROOT: 'FlagComment_Root', REIMBURSEMENT_ACCOUNT: 'ReimbursementAccount', GET_ASSISTANCE: 'GetAssistance', diff --git a/src/libs/E2E/tests/openSearchPageTest.e2e.ts b/src/libs/E2E/tests/openSearchPageTest.e2e.ts index 86da851396f6..201cdc556d04 100644 --- a/src/libs/E2E/tests/openSearchPageTest.e2e.ts +++ b/src/libs/E2E/tests/openSearchPageTest.e2e.ts @@ -24,7 +24,7 @@ const test = () => { Performance.subscribeToMeasurements((entry) => { if (entry.name === CONST.TIMING.SIDEBAR_LOADED) { console.debug(`[E2E] Sidebar loaded, navigating to search route…`); - Navigation.navigate(ROUTES.SEARCH); + Navigation.navigate(ROUTES.FIND); return; } diff --git a/src/libs/Navigation/AppNavigator/AuthScreens.tsx b/src/libs/Navigation/AppNavigator/AuthScreens.tsx index 463dcfcd9e99..c1d98d9e5e0e 100644 --- a/src/libs/Navigation/AppNavigator/AuthScreens.tsx +++ b/src/libs/Navigation/AppNavigator/AuthScreens.tsx @@ -232,7 +232,7 @@ function AuthScreens({session, lastOpenedPublicRoomID, initialLastUpdateIDApplie const unsubscribeSearchShortcut = KeyboardShortcut.subscribe( searchShortcutConfig.shortcutKey, () => { - Modal.close(Session.checkIfActionIsAllowed(() => Navigation.navigate(ROUTES.SEARCH))); + Modal.close(Session.checkIfActionIsAllowed(() => Navigation.navigate(ROUTES.FIND))); }, shortcutsOverviewShortcutConfig.descriptionKey, shortcutsOverviewShortcutConfig.modifiers, diff --git a/src/libs/Navigation/AppNavigator/ModalStackNavigators/index.tsx b/src/libs/Navigation/AppNavigator/ModalStackNavigators/index.tsx index 0d1b9b59a089..a2afd3f9efcb 100644 --- a/src/libs/Navigation/AppNavigator/ModalStackNavigators/index.tsx +++ b/src/libs/Navigation/AppNavigator/ModalStackNavigators/index.tsx @@ -7,6 +7,7 @@ import type { DetailsNavigatorParamList, EditRequestNavigatorParamList, EnablePaymentsNavigatorParamList, + FindNavigatorParamList, FlagCommentNavigatorParamList, MoneyRequestNavigatorParamList, NewChatNavigatorParamList, @@ -22,7 +23,6 @@ import type { ReportSettingsNavigatorParamList, RoomInviteNavigatorParamList, RoomMembersNavigatorParamList, - SearchNavigatorParamList, SettingsNavigatorParamList, SignInNavigatorParamList, SplitDetailsNavigatorParamList, @@ -145,8 +145,8 @@ const RoomInviteModalStackNavigator = createModalStackNavigator<RoomInviteNaviga [SCREENS.ROOM_INVITE_ROOT]: () => require('../../../../pages/RoomInvitePage').default as React.ComponentType, }); -const SearchModalStackNavigator = createModalStackNavigator<SearchNavigatorParamList>({ - [SCREENS.SEARCH_ROOT]: () => require('../../../../pages/SearchPage').default as React.ComponentType, +const SearchModalStackNavigator = createModalStackNavigator<FindNavigatorParamList>({ + [SCREENS.FIND_ROOT]: () => require('../../../../pages/SearchPage').default as React.ComponentType, }); const NewChatModalStackNavigator = createModalStackNavigator<NewChatNavigatorParamList>({ diff --git a/src/libs/Navigation/AppNavigator/Navigators/LeftModalNavigator.tsx b/src/libs/Navigation/AppNavigator/Navigators/LeftModalNavigator.tsx index 8f76d8fbdd7b..28b72d662258 100644 --- a/src/libs/Navigation/AppNavigator/Navigators/LeftModalNavigator.tsx +++ b/src/libs/Navigation/AppNavigator/Navigators/LeftModalNavigator.tsx @@ -32,7 +32,7 @@ function LeftModalNavigator({navigation}: LeftModalNavigatorProps) { <View style={styles.LHPNavigatorContainer(isSmallScreenWidth)}> <Stack.Navigator screenOptions={screenOptions}> <Stack.Screen - name={SCREENS.LEFT_MODAL.SEARCH} + name={SCREENS.LEFT_MODAL.FIND} component={ModalStackNavigators.SearchModalStackNavigator} /> <Stack.Screen diff --git a/src/libs/Navigation/AppNavigator/createCustomBottomTabNavigator/TopBar.tsx b/src/libs/Navigation/AppNavigator/createCustomBottomTabNavigator/TopBar.tsx index 38bfe4af9ab6..7d4445e7de1b 100644 --- a/src/libs/Navigation/AppNavigator/createCustomBottomTabNavigator/TopBar.tsx +++ b/src/libs/Navigation/AppNavigator/createCustomBottomTabNavigator/TopBar.tsx @@ -64,7 +64,7 @@ function TopBar({policy}: TopBarProps) { <PressableWithoutFeedback accessibilityLabel={translate('sidebarScreen.buttonSearch')} style={[styles.flexRow, styles.mr2]} - onPress={Session.checkIfActionIsAllowed(() => Navigation.navigate(ROUTES.SEARCH))} + onPress={Session.checkIfActionIsAllowed(() => Navigation.navigate(ROUTES.FIND))} > <Icon src={Expensicons.MagnifyingGlass} diff --git a/src/libs/Navigation/linkingConfig/config.ts b/src/libs/Navigation/linkingConfig/config.ts index 823b6514c42b..729aaa3e7c54 100644 --- a/src/libs/Navigation/linkingConfig/config.ts +++ b/src/libs/Navigation/linkingConfig/config.ts @@ -66,9 +66,9 @@ const config: LinkingOptions<RootStackParamList>['config'] = { [SCREENS.NOT_FOUND]: '*', [NAVIGATORS.LEFT_MODAL_NAVIGATOR]: { screens: { - [SCREENS.LEFT_MODAL.SEARCH]: { + [SCREENS.LEFT_MODAL.FIND]: { screens: { - [SCREENS.SEARCH_ROOT]: ROUTES.SEARCH, + [SCREENS.FIND_ROOT]: ROUTES.FIND, }, }, [SCREENS.LEFT_MODAL.WORKSPACE_SWITCHER]: { diff --git a/src/libs/Navigation/types.ts b/src/libs/Navigation/types.ts index b88c44b9aa70..87ac410e3c01 100644 --- a/src/libs/Navigation/types.ts +++ b/src/libs/Navigation/types.ts @@ -281,8 +281,8 @@ type NewChatNavigatorParamList = { [SCREENS.NEW_CHAT.ROOT]: undefined; }; -type SearchNavigatorParamList = { - [SCREENS.SEARCH_ROOT]: undefined; +type FindNavigatorParamList = { + [SCREENS.FIND_ROOT]: undefined; }; type DetailsNavigatorParamList = { @@ -542,7 +542,7 @@ type PrivateNotesNavigatorParamList = { }; type LeftModalNavigatorParamList = { - [SCREENS.LEFT_MODAL.SEARCH]: NavigatorScreenParams<SearchNavigatorParamList>; + [SCREENS.LEFT_MODAL.FIND]: NavigatorScreenParams<FindNavigatorParamList>; [SCREENS.LEFT_MODAL.WORKSPACE_SWITCHER]: NavigatorScreenParams<WorkspaceSwitcherNavigatorParamList>; }; @@ -700,7 +700,7 @@ type AuthScreensParamList = SharedScreensParamList & { }; }; -type RootStackParamList = PublicScreensParamList & AuthScreensParamList & SearchNavigatorParamList; +type RootStackParamList = PublicScreensParamList & AuthScreensParamList & FindNavigatorParamList; type BottomTabName = keyof BottomTabNavigatorParamList; @@ -742,7 +742,7 @@ export type { ParticipantsNavigatorParamList, RoomMembersNavigatorParamList, RoomInviteNavigatorParamList, - SearchNavigatorParamList, + FindNavigatorParamList, NewChatNavigatorParamList, NewTaskNavigatorParamList, TeachersUniteNavigatorParamList, diff --git a/src/pages/SearchPage/index.tsx b/src/pages/SearchPage/index.tsx index c072bfd56913..faad8200ac5e 100644 --- a/src/pages/SearchPage/index.tsx +++ b/src/pages/SearchPage/index.tsx @@ -34,7 +34,7 @@ type SearchPageOnyxProps = { isSearchingForReports: OnyxEntry<boolean>; }; -type SearchPageProps = SearchPageOnyxProps & StackScreenProps<RootStackParamList, typeof SCREENS.SEARCH_ROOT>; +type SearchPageProps = SearchPageOnyxProps & StackScreenProps<RootStackParamList, typeof SCREENS.FIND_ROOT>; type SearchPageSectionItem = { data: OptionData[]; From 1e5150b624e19148436f84acc34cd0a1b3b68e2d Mon Sep 17 00:00:00 2001 From: Adam Grzybowski <adam.grzybowski@swmansion.com> Date: Fri, 5 Apr 2024 14:01:29 +0200 Subject: [PATCH 050/206] add new search tab --- src/ROUTES.ts | 2 + src/SCREENS.ts | 2 + .../Navigators/BottomTabNavigator.tsx | 5 +++ .../BaseCentralPaneNavigator.tsx | 8 ++++ .../BottomTabBar.tsx | 27 ++++++++++++- .../createCustomStackNavigator/index.tsx | 40 +++++++++++++++---- src/libs/Navigation/linkTo.ts | 14 ++++++- .../TAB_TO_CENTRAL_PANE_MAPPING.ts | 1 + src/libs/Navigation/linkingConfig/config.ts | 1 + src/libs/Navigation/types.ts | 4 ++ src/pages/Search/SearchPage.tsx | 20 ++++++++++ src/pages/Search/SearchPageBottomTab.tsx | 15 +++++++ src/pages/SearchPage.tsx | 16 ++++++++ 13 files changed, 144 insertions(+), 11 deletions(-) create mode 100644 src/pages/Search/SearchPage.tsx create mode 100644 src/pages/Search/SearchPageBottomTab.tsx create mode 100644 src/pages/SearchPage.tsx diff --git a/src/ROUTES.ts b/src/ROUTES.ts index 0224270aa878..b6410c926f96 100644 --- a/src/ROUTES.ts +++ b/src/ROUTES.ts @@ -20,6 +20,8 @@ const ROUTES = { ALL_SETTINGS: 'all-settings', + SEARCH: 'search', + // This is a utility route used to go to the user's concierge chat, or the sign-in page if the user's not authenticated CONCIERGE: 'concierge', FLAG_COMMENT: { diff --git a/src/SCREENS.ts b/src/SCREENS.ts index 0006e243ee1e..55a067e02c97 100644 --- a/src/SCREENS.ts +++ b/src/SCREENS.ts @@ -13,6 +13,8 @@ const PROTECTED_SCREENS = { const SCREENS = { ...PROTECTED_SCREENS, ALL_SETTINGS: 'AllSettings', + SEARCH: 'Search', + SEARCH_BOTTOM_TAB: 'SearchBottomTab', REPORT: 'Report', PROFILE_AVATAR: 'ProfileAvatar', WORKSPACE_AVATAR: 'WorkspaceAvatar', diff --git a/src/libs/Navigation/AppNavigator/Navigators/BottomTabNavigator.tsx b/src/libs/Navigation/AppNavigator/Navigators/BottomTabNavigator.tsx index 87a441f16ddb..93457a65ff3f 100644 --- a/src/libs/Navigation/AppNavigator/Navigators/BottomTabNavigator.tsx +++ b/src/libs/Navigation/AppNavigator/Navigators/BottomTabNavigator.tsx @@ -5,6 +5,7 @@ import createCustomBottomTabNavigator from '@libs/Navigation/AppNavigator/create import getTopmostCentralPaneRoute from '@libs/Navigation/getTopmostCentralPaneRoute'; import type {BottomTabNavigatorParamList} from '@libs/Navigation/types'; import SidebarScreen from '@pages/home/sidebar/SidebarScreen'; +import SearchPageBottomTab from '@pages/Search/SearchPageBottomTab'; import SCREENS from '@src/SCREENS'; import ActiveRouteContext from './ActiveRouteContext'; @@ -27,6 +28,10 @@ function BottomTabNavigator() { name={SCREENS.HOME} component={SidebarScreen} /> + <Tab.Screen + name={SCREENS.SEARCH_BOTTOM_TAB} + component={SearchPageBottomTab} + /> <Tab.Screen name={SCREENS.SETTINGS.ROOT} getComponent={loadInitialSettingsPage} diff --git a/src/libs/Navigation/AppNavigator/Navigators/CentralPaneNavigator/BaseCentralPaneNavigator.tsx b/src/libs/Navigation/AppNavigator/Navigators/CentralPaneNavigator/BaseCentralPaneNavigator.tsx index 16f403342a58..fabf78eb086e 100644 --- a/src/libs/Navigation/AppNavigator/Navigators/CentralPaneNavigator/BaseCentralPaneNavigator.tsx +++ b/src/libs/Navigation/AppNavigator/Navigators/CentralPaneNavigator/BaseCentralPaneNavigator.tsx @@ -4,6 +4,7 @@ import useThemeStyles from '@hooks/useThemeStyles'; import ReportScreenWrapper from '@libs/Navigation/AppNavigator/ReportScreenWrapper'; import getCurrentUrl from '@libs/Navigation/currentUrl'; import type {CentralPaneNavigatorParamList} from '@navigation/types'; +import SearchPage from '@pages/Search/SearchPage'; import SCREENS from '@src/SCREENS'; const Stack = createStackNavigator<CentralPaneNavigatorParamList>(); @@ -39,6 +40,13 @@ function BaseCentralPaneNavigator() { initialParams={{openOnAdminRoom: openOnAdminRoom === 'true' || undefined}} component={ReportScreenWrapper} /> + <Stack.Screen + name={SCREENS.SEARCH} + // We do it this way to avoid adding the url params to url + component={SearchPage} + initialParams={{filter: 'all'}} + /> + {Object.entries(settingsScreens).map(([screenName, componentGetter]) => ( <Stack.Screen key={screenName} diff --git a/src/libs/Navigation/AppNavigator/createCustomBottomTabNavigator/BottomTabBar.tsx b/src/libs/Navigation/AppNavigator/createCustomBottomTabNavigator/BottomTabBar.tsx index 6d20361b75f5..143bb7936057 100644 --- a/src/libs/Navigation/AppNavigator/createCustomBottomTabNavigator/BottomTabBar.tsx +++ b/src/libs/Navigation/AppNavigator/createCustomBottomTabNavigator/BottomTabBar.tsx @@ -13,6 +13,7 @@ import useTheme from '@hooks/useTheme'; import useThemeStyles from '@hooks/useThemeStyles'; import * as Session from '@libs/actions/Session'; import getTopmostBottomTabRoute from '@libs/Navigation/getTopmostBottomTabRoute'; +import getTopmostCentralPaneRoute from '@libs/Navigation/getTopmostCentralPaneRoute'; import Navigation from '@libs/Navigation/Navigation'; import type {RootStackParamList, State} from '@libs/Navigation/types'; import {getChatTabBrickRoad} from '@libs/WorkspacesSettingsUtils'; @@ -53,6 +54,12 @@ function BottomTabBar({isLoadingApp = false}: PurposeForUsingExpensifyModalProps // Parent navigator of the bottom tab bar is the root navigator. const currentTabName = useNavigationState<RootStackParamList, string | undefined>((state) => { + const topmostCentralPaneRoute = getTopmostCentralPaneRoute(state); + + if (topmostCentralPaneRoute && topmostCentralPaneRoute.name === SCREENS.SEARCH) { + return SCREENS.SEARCH; + } + const topmostBottomTabRoute = getTopmostBottomTabRoute(state); return topmostBottomTabRoute?.name ?? SCREENS.HOME; }); @@ -83,10 +90,28 @@ function BottomTabBar({isLoadingApp = false}: PurposeForUsingExpensifyModalProps )} </View> </PressableWithFeedback> + <PressableWithFeedback + onPress={() => { + Navigation.navigate(ROUTES.SEARCH); + }} + role={CONST.ROLE.BUTTON} + accessibilityLabel={translate('common.search')} + wrapperStyle={styles.flex1} + style={styles.bottomTabBarItem} + > + <View> + <Icon + src={Expensicons.ReceiptSearch} + fill={currentTabName === SCREENS.SEARCH ? theme.iconMenu : theme.icon} + width={variables.iconBottomBar} + height={variables.iconBottomBar} + /> + </View> + </PressableWithFeedback> </Tooltip> - <BottomTabBarFloatingActionButton /> <BottomTabAvatar isSelected={currentTabName === SCREENS.SETTINGS.ROOT} /> + <BottomTabBarFloatingActionButton /> </View> ); } diff --git a/src/libs/Navigation/AppNavigator/createCustomStackNavigator/index.tsx b/src/libs/Navigation/AppNavigator/createCustomStackNavigator/index.tsx index 2a517c45eb0d..01e7743c1760 100644 --- a/src/libs/Navigation/AppNavigator/createCustomStackNavigator/index.tsx +++ b/src/libs/Navigation/AppNavigator/createCustomStackNavigator/index.tsx @@ -3,21 +3,25 @@ import {createNavigatorFactory, useNavigationBuilder} from '@react-navigation/na import type {StackNavigationEventMap, StackNavigationOptions} from '@react-navigation/stack'; import {StackView} from '@react-navigation/stack'; import React, {useEffect, useMemo} from 'react'; +import {View} from 'react-native'; import useWindowDimensions from '@hooks/useWindowDimensions'; +import getTopmostCentralPaneRoute from '@libs/Navigation/getTopmostCentralPaneRoute'; import navigationRef from '@libs/Navigation/navigationRef'; +import type {RootStackParamList, State} from '@libs/Navigation/types'; import NAVIGATORS from '@src/NAVIGATORS'; +import SCREENS from '@src/SCREENS'; import CustomRouter from './CustomRouter'; import type {ResponsiveStackNavigatorProps, ResponsiveStackNavigatorRouterOptions} from './types'; type Routes = StackNavigationState<ParamListBase>['routes']; -function reduceReportRoutes(routes: Routes): Routes { +function reduceCentralPaneRoutes(routes: Routes): Routes { const result: Routes = []; let count = 0; const reverseRoutes = [...routes].reverse(); reverseRoutes.forEach((route) => { if (route.name === NAVIGATORS.CENTRAL_PANE_NAVIGATOR) { - // Remove all report routes except the last 3. This will improve performance. + // Remove all central pane routes except the last 3. This will improve performance. if (count < 3) { result.push(route); count++; @@ -52,15 +56,34 @@ function ResponsiveStackNavigator(props: ResponsiveStackNavigatorProps) { navigationRef.resetRoot(navigationRef.getRootState()); }, [isSmallScreenWidth]); - const stateToRender = useMemo(() => { - const result = reduceReportRoutes(state.routes); + const {stateToRender, searchRoute} = useMemo(() => { + const routes = reduceCentralPaneRoutes(state.routes); + + const lastRoute = routes[routes.length - 1]; + const isLastRouteSearchRoute = getTopmostCentralPaneRoute({routes: [lastRoute]} as State<RootStackParamList>)?.name === SCREENS.SEARCH; + + const firstRoute = routes[0]; + + if (isSmallScreenWidth && isLastRouteSearchRoute) { + return { + stateToRender: { + ...state, + index: 0, + routes: [firstRoute], + }, + searchRoute: lastRoute, + }; + } return { - ...state, - index: result.length - 1, - routes: [...result], + stateToRender: { + ...state, + index: routes.length - 1, + routes: [...routes], + }, + searchRoute: undefined, }; - }, [state]); + }, [state, isSmallScreenWidth]); return ( <NavigationContent> @@ -71,6 +94,7 @@ function ResponsiveStackNavigator(props: ResponsiveStackNavigatorProps) { descriptors={descriptors} navigation={navigation} /> + {searchRoute && <View style={{display: 'none'}}>{descriptors[searchRoute.key].render()}</View>} </NavigationContent> ); } diff --git a/src/libs/Navigation/linkTo.ts b/src/libs/Navigation/linkTo.ts index afa8fb56069a..35b3460361c9 100644 --- a/src/libs/Navigation/linkTo.ts +++ b/src/libs/Navigation/linkTo.ts @@ -6,6 +6,7 @@ import {extractPolicyIDFromPath, getPathWithoutPolicyID} from '@libs/PolicyUtils import CONST from '@src/CONST'; import NAVIGATORS from '@src/NAVIGATORS'; import type {Route} from '@src/ROUTES'; +import SCREENS from '@src/SCREENS'; import getActionsFromPartialDiff from './AppNavigator/getActionsFromPartialDiff'; import getPartialStateDiff from './AppNavigator/getPartialStateDiff'; import dismissModal from './dismissModal'; @@ -152,6 +153,15 @@ export default function linkTo(navigation: NavigationContainerRef<RootStackParam const topRouteName = rootState?.routes?.at(-1)?.name; const isTargetNavigatorOnTop = topRouteName === action.payload.name; + const isTargetScreenDifferentThanCurrent = topmostCentralPaneRoute && topmostCentralPaneRoute.name !== action.payload.params?.screen; + const isTargetScreenReportWithDifferentReportID = action.payload.params?.screen === SCREENS.REPORT && getTopmostReportId(rootState) !== getTopmostReportId(stateFromPath); + const isTargetScreenSearchWithDifferentParams = + action.payload.params?.screen === SCREENS.SEARCH && + topmostCentralPaneRoute && + topmostCentralPaneRoute.params && + 'filter' in topmostCentralPaneRoute.params && + topmostCentralPaneRoute?.params?.filter !== action.payload.params?.params?.filter; + // In case if type is 'FORCED_UP' we replace current screen with the provided. This means the current screen no longer exists in the stack if (type === CONST.NAVIGATION.TYPE.FORCED_UP) { action.type = CONST.NAVIGATION.ACTION_TYPE.REPLACE; @@ -159,8 +169,8 @@ export default function linkTo(navigation: NavigationContainerRef<RootStackParam // If this action is navigating to the report screen and the top most navigator is different from the one we want to navigate - PUSH the new screen to the top of the stack } else if ( action.payload.name === NAVIGATORS.CENTRAL_PANE_NAVIGATOR && - topmostCentralPaneRoute && - (topmostCentralPaneRoute.name !== action.payload.params?.screen || getTopmostReportId(rootState) !== getTopmostReportId(stateFromPath)) + (!topmostCentralPaneRoute || + (topmostCentralPaneRoute && (isTargetScreenDifferentThanCurrent || isTargetScreenReportWithDifferentReportID || isTargetScreenSearchWithDifferentParams))) ) { // We need to push a tab if the tab doesn't match the central pane route that we are going to push. const topmostBottomTabRoute = getTopmostBottomTabRoute(rootState); diff --git a/src/libs/Navigation/linkingConfig/TAB_TO_CENTRAL_PANE_MAPPING.ts b/src/libs/Navigation/linkingConfig/TAB_TO_CENTRAL_PANE_MAPPING.ts index 78a644ab4aee..efda5da092a5 100755 --- a/src/libs/Navigation/linkingConfig/TAB_TO_CENTRAL_PANE_MAPPING.ts +++ b/src/libs/Navigation/linkingConfig/TAB_TO_CENTRAL_PANE_MAPPING.ts @@ -3,6 +3,7 @@ import SCREENS from '@src/SCREENS'; const TAB_TO_CENTRAL_PANE_MAPPING: Record<BottomTabName, CentralPaneName[]> = { [SCREENS.HOME]: [SCREENS.REPORT], + [SCREENS.SEARCH_BOTTOM_TAB]: [SCREENS.SEARCH], [SCREENS.SETTINGS.ROOT]: [ SCREENS.SETTINGS.PROFILE.ROOT, SCREENS.SETTINGS.PREFERENCES.ROOT, diff --git a/src/libs/Navigation/linkingConfig/config.ts b/src/libs/Navigation/linkingConfig/config.ts index 729aaa3e7c54..9ba599874ba1 100644 --- a/src/libs/Navigation/linkingConfig/config.ts +++ b/src/libs/Navigation/linkingConfig/config.ts @@ -61,6 +61,7 @@ const config: LinkingOptions<RootStackParamList>['config'] = { exact: true, }, [SCREENS.SETTINGS.WORKSPACES]: ROUTES.SETTINGS_WORKSPACES, + [SCREENS.SEARCH]: ROUTES.SEARCH, }, }, [SCREENS.NOT_FOUND]: '*', diff --git a/src/libs/Navigation/types.ts b/src/libs/Navigation/types.ts index 87ac410e3c01..a2e8bbef4c22 100644 --- a/src/libs/Navigation/types.ts +++ b/src/libs/Navigation/types.ts @@ -59,6 +59,9 @@ type CentralPaneNavigatorParamList = { [SCREENS.SETTINGS.WALLET.ROOT]: undefined; [SCREENS.SETTINGS.ABOUT]: undefined; [SCREENS.SETTINGS.WORKSPACES]: undefined; + [SCREENS.SEARCH]: { + filter: string; + }; }; type WorkspaceSwitcherNavigatorParamList = { @@ -636,6 +639,7 @@ type FullScreenNavigatorParamList = { type BottomTabNavigatorParamList = { [SCREENS.HOME]: undefined; + [SCREENS.SEARCH_BOTTOM_TAB]: undefined; [SCREENS.SETTINGS.ROOT]: undefined; }; diff --git a/src/pages/Search/SearchPage.tsx b/src/pages/Search/SearchPage.tsx new file mode 100644 index 000000000000..22725453ea9a --- /dev/null +++ b/src/pages/Search/SearchPage.tsx @@ -0,0 +1,20 @@ +import type {StackScreenProps} from '@react-navigation/stack'; +import React from 'react'; +import {Text} from 'react-native'; +import ScreenWrapper from '@components/ScreenWrapper'; +import type {CentralPaneNavigatorParamList} from '@libs/Navigation/types'; +import type SCREENS from '@src/SCREENS'; + +type SearchPageProps = StackScreenProps<CentralPaneNavigatorParamList, typeof SCREENS.SEARCH>; + +function SearchPage({route}: SearchPageProps) { + return ( + <ScreenWrapper testID="testPage"> + <Text style={{color: 'white', fontSize: 30}}>Search page |{route.params.filter}|</Text> + </ScreenWrapper> + ); +} + +SearchPage.displayName = 'SearchPage'; + +export default SearchPage; diff --git a/src/pages/Search/SearchPageBottomTab.tsx b/src/pages/Search/SearchPageBottomTab.tsx new file mode 100644 index 000000000000..65e13bf870c4 --- /dev/null +++ b/src/pages/Search/SearchPageBottomTab.tsx @@ -0,0 +1,15 @@ +import React from 'react'; +import {Text} from 'react-native'; +import ScreenWrapper from '@components/ScreenWrapper'; + +function SearchPage() { + return ( + <ScreenWrapper testID="testPage"> + <Text style={{color: 'white', fontSize: 30}}>Search page BOTTOM TAB </Text> + </ScreenWrapper> + ); +} + +SearchPage.displayName = 'SearchPage'; + +export default SearchPage; diff --git a/src/pages/SearchPage.tsx b/src/pages/SearchPage.tsx new file mode 100644 index 000000000000..76f81697d190 --- /dev/null +++ b/src/pages/SearchPage.tsx @@ -0,0 +1,16 @@ +import React from 'react'; +// eslint-disable-next-line no-restricted-imports +import {Text} from 'react-native'; +import ScreenWrapper from '@components/ScreenWrapper'; + +function TestPage() { + return ( + <ScreenWrapper testID="testPage"> + <Text style={{color: 'white', fontSize: 30}}>TEST PAGE</Text> + </ScreenWrapper> + ); +} + +TestPage.displayName = 'TestPage'; + +export default TestPage; From ae469550901b470d0f69a303345a147b6ea84883 Mon Sep 17 00:00:00 2001 From: Bernhard Owen Josephus <bernhard.josephus@gmail.com> Date: Sat, 6 Apr 2024 20:55:13 +0800 Subject: [PATCH 051/206] don't clear ba data on unmount and fix loader blinking issue --- .../ReimbursementAccountPage.js | 23 +++++++++++-------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/src/pages/ReimbursementAccount/ReimbursementAccountPage.js b/src/pages/ReimbursementAccount/ReimbursementAccountPage.js index 0f5d04919e29..d352e73ac05d 100644 --- a/src/pages/ReimbursementAccount/ReimbursementAccountPage.js +++ b/src/pages/ReimbursementAccount/ReimbursementAccountPage.js @@ -236,18 +236,16 @@ function ReimbursementAccountPage({reimbursementAccount, route, onfidoToken, pol } /** - When this page is first opened, `reimbursementAccount` prop might not yet be fully loaded from Onyx - or could be partially loaded such that `reimbursementAccount.achData.currentStep` is unavailable. + When this page is first opened, `reimbursementAccount` prop might not yet be fully loaded from Onyx. Calculating `shouldShowContinueSetupButton` immediately on initial render doesn't make sense as it relies on complete data. Thus, we should wait to calculate it until we have received the full `reimbursementAccount` data from the server. This logic is handled within the useEffect hook, which acts similarly to `componentDidUpdate` when the `reimbursementAccount` dependency changes. */ - const [hasACHDataBeenLoaded, setHasACHDataBeenLoaded] = useState( - reimbursementAccount !== ReimbursementAccountProps.reimbursementAccountDefaultProps && _.has(reimbursementAccount, 'achData.currentStep'), - ); + const [hasACHDataBeenLoaded, setHasACHDataBeenLoaded] = useState(reimbursementAccount !== ReimbursementAccountProps.reimbursementAccountDefaultProps); const [shouldShowContinueSetupButton, setShouldShowContinueSetupButton] = useState(hasACHDataBeenLoaded ? getShouldShowContinueSetupButtonInitialValue() : false); + const [isReimbursementAccountLoading, setIsReimbursementAccountLoading] = useState(true); const currentStep = achData.currentStep || CONST.BANK_ACCOUNT.STEP.BANK_ACCOUNT; const policyName = lodashGet(policy, 'name', ''); @@ -256,6 +254,7 @@ function ReimbursementAccountPage({reimbursementAccount, route, onfidoToken, pol const {translate} = useLocalize(); const {isOffline} = useNetwork(); const requestorStepRef = useRef(null); + const prevIsReimbursementAccountLoading = usePrevious(reimbursementAccount.isLoading); const prevReimbursementAccount = usePrevious(reimbursementAccount); const prevIsOffline = usePrevious(isOffline); @@ -278,14 +277,18 @@ function ReimbursementAccountPage({reimbursementAccount, route, onfidoToken, pol useEffect( () => { fetchData(); - return () => { - BankAccounts.clearReimbursementAccount(); - }; }, // eslint-disable-next-line react-hooks/exhaustive-deps [], ); // The empty dependency array ensures this runs only once after the component mounts. + useEffect(() => { + if (reimbursementAccount.isLoading === prevIsReimbursementAccountLoading) { + return; + } + setIsReimbursementAccountLoading(reimbursementAccount.isLoading); + }, [prevIsReimbursementAccountLoading, reimbursementAccount.isLoading]); + useEffect( () => { // Check for network change from offline to online @@ -294,7 +297,7 @@ function ReimbursementAccountPage({reimbursementAccount, route, onfidoToken, pol } if (!hasACHDataBeenLoaded) { - if (reimbursementAccount !== ReimbursementAccountProps.reimbursementAccountDefaultProps && reimbursementAccount.isLoading === false) { + if (reimbursementAccount !== ReimbursementAccountProps.reimbursementAccountDefaultProps && isReimbursementAccountLoading === false) { setShouldShowContinueSetupButton(getShouldShowContinueSetupButtonInitialValue()); setHasACHDataBeenLoaded(true); } @@ -415,7 +418,7 @@ function ReimbursementAccountPage({reimbursementAccount, route, onfidoToken, pol } }; - const isLoading = (isLoadingApp || account.isLoading || reimbursementAccount.isLoading) && (!plaidCurrentEvent || plaidCurrentEvent === CONST.BANK_ACCOUNT.PLAID.EVENTS_NAME.EXIT); + const isLoading = (isLoadingApp || account.isLoading || isReimbursementAccountLoading) && (!plaidCurrentEvent || plaidCurrentEvent === CONST.BANK_ACCOUNT.PLAID.EVENTS_NAME.EXIT); const shouldShowOfflineLoader = !( isOffline && _.contains( From eef26cc858497cac3f2d1412f73049a998c5febe Mon Sep 17 00:00:00 2001 From: Wojciech Boman <wojciechboman@gmail.com> Date: Mon, 8 Apr 2024 08:34:57 +0200 Subject: [PATCH 052/206] Add search page template components --- src/CONST.ts | 8 ++ src/ROUTES.ts | 5 + src/components/TabSelector/TabSelector.tsx | 10 ++ src/pages/Search/SearchPage.tsx | 4 +- src/pages/Search/SearchPageBottomTab.tsx | 111 +++++++++++++++++++-- src/pages/Search/SearchResults.tsx | 14 +++ 6 files changed, 144 insertions(+), 8 deletions(-) create mode 100644 src/pages/Search/SearchResults.tsx diff --git a/src/CONST.ts b/src/CONST.ts index e7358b382f14..c90d9b4c3c4b 100755 --- a/src/CONST.ts +++ b/src/CONST.ts @@ -3194,12 +3194,20 @@ const CONST = { NEW_ROOM: 'room', RECEIPT_TAB_ID: 'ReceiptTab', IOU_REQUEST_TYPE: 'iouRequestType', + SEARCH: 'search', }, TAB_REQUEST: { MANUAL: 'manual', SCAN: 'scan', DISTANCE: 'distance', }, + TAB_SEARCH: { + ALL: 'all', + SENT: 'sent', + DRAFTS: 'drafts', + WAITING_ON_YOU: 'waitingOnYou', + FINISHED: 'finished', + }, STATUS_TEXT_MAX_LENGTH: 100, DROPDOWN_BUTTON_SIZE: { diff --git a/src/ROUTES.ts b/src/ROUTES.ts index b6410c926f96..130485925328 100644 --- a/src/ROUTES.ts +++ b/src/ROUTES.ts @@ -22,6 +22,11 @@ const ROUTES = { SEARCH: 'search', + SEARCH_WITH_FILTER: { + route: 'search?', + getRoute: (tab: string) => `search?filter=${tab}` as const, + }, + // This is a utility route used to go to the user's concierge chat, or the sign-in page if the user's not authenticated CONCIERGE: 'concierge', FLAG_COMMENT: { diff --git a/src/components/TabSelector/TabSelector.tsx b/src/components/TabSelector/TabSelector.tsx index fc19e6a8062e..00ecd41beb08 100644 --- a/src/components/TabSelector/TabSelector.tsx +++ b/src/components/TabSelector/TabSelector.tsx @@ -33,6 +33,16 @@ function getIconAndTitle(route: string, translate: LocaleContextProps['translate return {icon: Expensicons.Hashtag, title: translate('tabSelector.room')}; case CONST.TAB_REQUEST.DISTANCE: return {icon: Expensicons.Car, title: translate('common.distance')}; + case CONST.TAB_SEARCH.ALL: + return {icon: Expensicons.ExpensifyLogoNew, title: 'All'}; + case CONST.TAB_SEARCH.SENT: + return {icon: Expensicons.ExpensifyLogoNew, title: 'Sent'}; + case CONST.TAB_SEARCH.DRAFTS: + return {icon: Expensicons.ExpensifyLogoNew, title: 'Drafts'}; + case CONST.TAB_SEARCH.WAITING_ON_YOU: + return {icon: Expensicons.ExpensifyLogoNew, title: 'Waiting on you'}; + case CONST.TAB_SEARCH.FINISHED: + return {icon: Expensicons.ExpensifyLogoNew, title: 'Finished'}; default: throw new Error(`Route ${route} has no icon nor title set.`); } diff --git a/src/pages/Search/SearchPage.tsx b/src/pages/Search/SearchPage.tsx index 22725453ea9a..2decf6f96fe8 100644 --- a/src/pages/Search/SearchPage.tsx +++ b/src/pages/Search/SearchPage.tsx @@ -1,16 +1,16 @@ import type {StackScreenProps} from '@react-navigation/stack'; import React from 'react'; -import {Text} from 'react-native'; import ScreenWrapper from '@components/ScreenWrapper'; import type {CentralPaneNavigatorParamList} from '@libs/Navigation/types'; import type SCREENS from '@src/SCREENS'; +import SearchResults from './SearchResults'; type SearchPageProps = StackScreenProps<CentralPaneNavigatorParamList, typeof SCREENS.SEARCH>; function SearchPage({route}: SearchPageProps) { return ( <ScreenWrapper testID="testPage"> - <Text style={{color: 'white', fontSize: 30}}>Search page |{route.params.filter}|</Text> + <SearchResults filter={route.params.filter} /> </ScreenWrapper> ); } diff --git a/src/pages/Search/SearchPageBottomTab.tsx b/src/pages/Search/SearchPageBottomTab.tsx index 65e13bf870c4..5267a4396ac0 100644 --- a/src/pages/Search/SearchPageBottomTab.tsx +++ b/src/pages/Search/SearchPageBottomTab.tsx @@ -1,15 +1,114 @@ -import React from 'react'; -import {Text} from 'react-native'; +import {useNavigationState} from '@react-navigation/native'; +import {StackScreenProps} from '@react-navigation/stack'; +import React, {useState} from 'react'; +import {Text, View} from 'react-native'; +import MenuItem from '@components/MenuItem'; import ScreenWrapper from '@components/ScreenWrapper'; +import TabSelector from '@components/TabSelector/TabSelector'; +import useSingleExecution from '@hooks/useSingleExecution'; +import useThemeStyles from '@hooks/useThemeStyles'; +import useWaitForNavigation from '@hooks/useWaitForNavigation'; +import useWindowDimensions from '@hooks/useWindowDimensions'; +import getTopmostCentralPaneRoute from '@libs/Navigation/getTopmostCentralPaneRoute'; +import Navigation from '@libs/Navigation/Navigation'; +import OnyxTabNavigator, {TopTab} from '@libs/Navigation/OnyxTabNavigator'; +import type {CentralPaneNavigatorParamList, RootStackParamList} from '@libs/Navigation/types'; +import * as Expensicons from '@src/components/Icon/Expensicons'; +import CONST from '@src/CONST'; +import ROUTES from '@src/ROUTES'; +import type SCREENS from '@src/SCREENS'; +import IconAsset from '@src/types/utils/IconAsset'; +import SearchPage from './SearchPage'; +import SearchResults from './SearchResults'; + +type SearchMenuItem = { + title: string; + icon: IconAsset; + action: () => void; +}; + +function SearchPageBottomTab() { + const styles = useThemeStyles(); + const {singleExecution} = useSingleExecution(); + const {isSmallScreenWidth} = useWindowDimensions(); + const waitForNavigate = useWaitForNavigation(); + + const [filter, setFilter] = useState('all'); + + const searchMenuItems: SearchMenuItem[] = [ + { + title: 'All', + icon: Expensicons.ExpensifyLogoNew, + action: singleExecution( + waitForNavigate(() => { + setFilter('all'); + Navigation.navigate(ROUTES.SEARCH_WITH_FILTER.getRoute('all')); + }), + ), + }, + { + title: 'Sent', + icon: Expensicons.ExpensifyLogoNew, + action: singleExecution( + waitForNavigate(() => { + setFilter('sent'); + Navigation.navigate(ROUTES.SEARCH_WITH_FILTER.getRoute('sent')); + }), + ), + }, + { + title: 'Drafts', + icon: Expensicons.ExpensifyLogoNew, + action: singleExecution( + waitForNavigate(() => { + setFilter('drafts'); + Navigation.navigate(ROUTES.SEARCH_WITH_FILTER.getRoute('drafts')); + }), + ), + }, + ]; -function SearchPage() { return ( <ScreenWrapper testID="testPage"> - <Text style={{color: 'white', fontSize: 30}}>Search page BOTTOM TAB </Text> + {isSmallScreenWidth ? ( + <OnyxTabNavigator + id={CONST.TAB.NEW_CHAT_TAB_ID} + tabBar={TabSelector} + onTabSelected={(tab: string) => { + setFilter(tab); + Navigation.navigate(ROUTES.SEARCH_WITH_FILTER.getRoute(tab)); + }} + > + <TopTab.Screen name={CONST.TAB_SEARCH.ALL}>{() => <SearchResults filter="all" />}</TopTab.Screen> + <TopTab.Screen name={CONST.TAB_SEARCH.SENT}>{() => <SearchResults filter="sent" />}</TopTab.Screen> + <TopTab.Screen name={CONST.TAB_SEARCH.DRAFTS}>{() => <SearchResults filter="drafts" />}</TopTab.Screen> + </OnyxTabNavigator> + ) : ( + <View style={[styles.pb4, styles.mh3, styles.mt3]}> + {/* + Ideally we should use MenuList component for MenuItems with singleExecution/Navigation actions. + In this case where user can click on workspace avatar or menu items, we need to have a check for `isExecuting`. So, we are directly mapping menuItems. + */} + {searchMenuItems.map((item) => ( + <MenuItem + key={item.title} + disabled={false} + interactive + title={item.title} + icon={item.icon} + onPress={item.action} + wrapperStyle={styles.sectionMenuItem} + focused={item.title.toLowerCase() === filter} + hoverAndPressStyle={styles.hoveredComponentBG} + isPaneMenu + /> + ))} + </View> + )} </ScreenWrapper> ); } -SearchPage.displayName = 'SearchPage'; +SearchPageBottomTab.displayName = 'SearchPage'; -export default SearchPage; +export default SearchPageBottomTab; diff --git a/src/pages/Search/SearchResults.tsx b/src/pages/Search/SearchResults.tsx new file mode 100644 index 000000000000..b0d4c3bede39 --- /dev/null +++ b/src/pages/Search/SearchResults.tsx @@ -0,0 +1,14 @@ +import React from 'react'; +import Text from '@components/Text'; + +type SearchResultsProps = { + filter: string; +}; + +function SearchResults({filter}: SearchResultsProps) { + return <Text style={{color: 'white', fontSize: 30}}>Search results for: |{filter}| filter</Text>; +} + +SearchResults.displayName = 'SearchResults'; + +export default SearchResults; From 3df8757c4284ed58b946e5da6bcffc2357c3a861 Mon Sep 17 00:00:00 2001 From: Alberto <alberto@expensify.com> Date: Mon, 8 Apr 2024 17:47:39 +0200 Subject: [PATCH 053/206] button style --- src/pages/iou/request/step/IOURequestStepScan/index.native.js | 2 +- src/pages/iou/steps/MoneyRequestAmountForm.tsx | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/src/pages/iou/request/step/IOURequestStepScan/index.native.js b/src/pages/iou/request/step/IOURequestStepScan/index.native.js index f4d3a13b61ff..8c10f7bff9ac 100644 --- a/src/pages/iou/request/step/IOURequestStepScan/index.native.js +++ b/src/pages/iou/request/step/IOURequestStepScan/index.native.js @@ -1,5 +1,5 @@ import {useFocusEffect} from '@react-navigation/core'; -import _ from '@types/underscore'; +import _ from 'underscore'; import lodashGet from 'lodash/get'; import PropTypes from 'prop-types'; import React, {useCallback, useRef, useState} from 'react'; diff --git a/src/pages/iou/steps/MoneyRequestAmountForm.tsx b/src/pages/iou/steps/MoneyRequestAmountForm.tsx index 8e6ac9f0ef66..7ad9fdbbec4c 100644 --- a/src/pages/iou/steps/MoneyRequestAmountForm.tsx +++ b/src/pages/iou/steps/MoneyRequestAmountForm.tsx @@ -366,6 +366,7 @@ function MoneyRequestAmountForm( addDebitCardRoute={ROUTES.IOU_SEND_ADD_DEBIT_CARD} currency={currency ?? CONST.CURRENCY.USD} policyID={policyID ?? ''} + style={[styles.w100, canUseTouchScreen ? styles.mt5 : styles.mt3]} buttonSize={CONST.DROPDOWN_BUTTON_SIZE.LARGE} kycWallAnchorAlignment={{ horizontal: CONST.MODAL.ANCHOR_ORIGIN_HORIZONTAL.LEFT, From 07d22e302c301e22752c55597614d1fc7b17e8a9 Mon Sep 17 00:00:00 2001 From: Alberto <alberto@expensify.com> Date: Mon, 8 Apr 2024 17:53:47 +0200 Subject: [PATCH 054/206] pass payment method --- src/pages/iou/request/IOURequestStartPage.js | 2 +- src/pages/iou/request/step/IOURequestStepAmount.js | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/pages/iou/request/IOURequestStartPage.js b/src/pages/iou/request/IOURequestStartPage.js index 2ec6561c7975..cb078fac133c 100644 --- a/src/pages/iou/request/IOURequestStartPage.js +++ b/src/pages/iou/request/IOURequestStartPage.js @@ -130,7 +130,7 @@ function IOURequestStartPage({ IOU.initMoneyRequest(reportID, policy, isFromGlobalCreate, newIouType); transactionRequestType.current = newIouType; }, - [policy, previousIOURequestType, reportID, isFromGlobalCreate, iouType, navigation, transaction], + [policy, previousIOURequestType, reportID, isFromGlobalCreate, iouType, navigation, transaction.isFromGlobalCreate], ); if (!transaction.transactionID) { diff --git a/src/pages/iou/request/step/IOURequestStepAmount.js b/src/pages/iou/request/step/IOURequestStepAmount.js index d9a5d1bd4d53..c6a5fc723154 100644 --- a/src/pages/iou/request/step/IOURequestStepAmount.js +++ b/src/pages/iou/request/step/IOURequestStepAmount.js @@ -209,9 +209,9 @@ function IOURequestStepAmount({ Navigation.navigate(ROUTES.MONEY_REQUEST_STEP_PARTICIPANTS.getRoute(iouType, transactionID, reportID)); }; - const saveAmountAndCurrency = ({amount}) => { + const saveAmountAndCurrency = ({amount, paymentMethod}) => { if (!isEditing) { - navigateToNextPage({amount}); + navigateToNextPage({amount, paymentMethod}); return; } From 356a8d5664d9c9dd2e168f5699bd27e9334a7bcd Mon Sep 17 00:00:00 2001 From: Alberto <alberto@expensify.com> Date: Mon, 8 Apr 2024 17:56:30 +0200 Subject: [PATCH 055/206] remove extra param --- src/pages/iou/request/step/IOURequestStepScan/index.js | 5 ++--- .../iou/request/step/IOURequestStepScan/index.native.js | 5 ++--- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/src/pages/iou/request/step/IOURequestStepScan/index.js b/src/pages/iou/request/step/IOURequestStepScan/index.js index 9a366f1c35c3..b0a49f1a54fe 100644 --- a/src/pages/iou/request/step/IOURequestStepScan/index.js +++ b/src/pages/iou/request/step/IOURequestStepScan/index.js @@ -83,7 +83,6 @@ function IOURequestStepScan({ params: {action, iouType, reportID, transactionID, backTo}, }, transaction, - transaction: {isFromGlobalCreate}, personalDetails, currentUserPersonalDetails, skipConfirmation, @@ -243,7 +242,7 @@ function IOURequestStepScan({ } // If the transaction was created from the global create, the person needs to select participants, so take them there. - if (isFromGlobalCreate && iouType !== CONST.IOU.TYPE.TRACK_EXPENSE && !report.reportID) { + if (transaction.isFromGlobalCreate && iouType !== CONST.IOU.TYPE.TRACK_EXPENSE && !report.reportID) { Navigation.navigate(ROUTES.MONEY_REQUEST_STEP_PARTICIPANTS.getRoute(iouType, transactionID, reportID)); return; } @@ -280,7 +279,7 @@ function IOURequestStepScan({ } Navigation.navigate(ROUTES.MONEY_REQUEST_STEP_CONFIRMATION.getRoute(CONST.IOU.ACTION.CREATE, iouType, transactionID, reportID)); }, - [iouType, report, reportID, transactionID, isFromGlobalCreate, backTo, currentUserPersonalDetails, personalDetails, shouldSkipConfirmation, transaction], + [iouType, report, reportID, transactionID, backTo, currentUserPersonalDetails, personalDetails, shouldSkipConfirmation, transaction], ); const updateScanAndNavigate = useCallback( diff --git a/src/pages/iou/request/step/IOURequestStepScan/index.native.js b/src/pages/iou/request/step/IOURequestStepScan/index.native.js index 8c10f7bff9ac..681074a25c65 100644 --- a/src/pages/iou/request/step/IOURequestStepScan/index.native.js +++ b/src/pages/iou/request/step/IOURequestStepScan/index.native.js @@ -91,7 +91,6 @@ function IOURequestStepScan({ params: {action, iouType, reportID, transactionID, backTo}, }, transaction, - transaction: {isFromGlobalCreate}, personalDetails, currentUserPersonalDetails, skipConfirmation, @@ -228,7 +227,7 @@ function IOURequestStepScan({ } // If the transaction was created from the global create, the person needs to select participants, so take them there. - if (isFromGlobalCreate && iouType !== CONST.IOU.TYPE.TRACK_EXPENSE && !report.reportID) { + if (transaction.isFromGlobalCreate && iouType !== CONST.IOU.TYPE.TRACK_EXPENSE && !report.reportID) { Navigation.navigate(ROUTES.MONEY_REQUEST_STEP_PARTICIPANTS.getRoute(iouType, transactionID, reportID)); return; } @@ -265,7 +264,7 @@ function IOURequestStepScan({ } Navigation.navigate(ROUTES.MONEY_REQUEST_STEP_CONFIRMATION.getRoute(CONST.IOU.ACTION.CREATE, iouType, transactionID, reportID)); }, - [iouType, report, reportID, transactionID, isFromGlobalCreate, backTo, currentUserPersonalDetails, personalDetails, shouldSkipConfirmation, transaction], + [iouType, report, reportID, transactionID, backTo, currentUserPersonalDetails, personalDetails, shouldSkipConfirmation, transaction], ); const updateScanAndNavigate = useCallback( From c24fafc2205ed30c6ee326d129e2c221e7161864 Mon Sep 17 00:00:00 2001 From: Alberto <alberto@expensify.com> Date: Mon, 8 Apr 2024 18:09:26 +0200 Subject: [PATCH 056/206] prettier --- src/pages/iou/request/step/IOURequestStepScan/index.native.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pages/iou/request/step/IOURequestStepScan/index.native.js b/src/pages/iou/request/step/IOURequestStepScan/index.native.js index 681074a25c65..62ec4491b555 100644 --- a/src/pages/iou/request/step/IOURequestStepScan/index.native.js +++ b/src/pages/iou/request/step/IOURequestStepScan/index.native.js @@ -1,5 +1,4 @@ import {useFocusEffect} from '@react-navigation/core'; -import _ from 'underscore'; import lodashGet from 'lodash/get'; import PropTypes from 'prop-types'; import React, {useCallback, useRef, useState} from 'react'; @@ -9,6 +8,7 @@ import {withOnyx} from 'react-native-onyx'; import {RESULTS} from 'react-native-permissions'; import Animated, {runOnJS, useAnimatedStyle, useSharedValue, withDelay, withSequence, withSpring, withTiming} from 'react-native-reanimated'; import {useCameraDevice} from 'react-native-vision-camera'; +import _ from 'underscore'; import Hand from '@assets/images/hand.svg'; import Shutter from '@assets/images/shutter.svg'; import AttachmentPicker from '@components/AttachmentPicker'; From 3c745077bf7c973f50d7a1957023bfec5bbf2d12 Mon Sep 17 00:00:00 2001 From: Wojciech Boman <wojciechboman@gmail.com> Date: Tue, 9 Apr 2024 18:14:04 +0200 Subject: [PATCH 057/206] Add new search pages --- src/ROUTES.ts | 11 ++++-- src/SCREENS.ts | 8 +++- .../ModalStackNavigators/index.tsx | 6 +++ .../Navigators/BottomTabNavigator.tsx | 2 +- .../BaseCentralPaneNavigator.tsx | 3 +- .../Navigators/RightModalNavigator.tsx | 4 ++ .../BottomTabBar.tsx | 8 ++-- .../index.native.tsx | 38 ++++++++++++++++++- .../createCustomStackNavigator/index.tsx | 2 +- .../CENTRAL_PANE_TO_RHP_MAPPING.ts | 1 + .../TAB_TO_CENTRAL_PANE_MAPPING.ts | 2 +- src/libs/Navigation/linkingConfig/config.ts | 7 +++- src/libs/Navigation/types.ts | 15 ++++++-- src/pages/Search/SearchPage.tsx | 2 +- src/pages/Search/SearchPageBottomTab.tsx | 8 ++-- src/pages/home/ReportScreen.tsx | 3 +- tests/perf-test/SearchPage.perf-test.tsx | 2 +- 17 files changed, 94 insertions(+), 28 deletions(-) diff --git a/src/ROUTES.ts b/src/ROUTES.ts index 130485925328..5d6175a275ea 100644 --- a/src/ROUTES.ts +++ b/src/ROUTES.ts @@ -20,11 +20,14 @@ const ROUTES = { ALL_SETTINGS: 'all-settings', - SEARCH: 'search', + SEARCH: { + route: '/search/:query', + getRoute: (query: string) => `search/${query}` as const, + }, - SEARCH_WITH_FILTER: { - route: 'search?', - getRoute: (tab: string) => `search?filter=${tab}` as const, + SEARCH_REPORT: { + route: '/search/:query/view/:reportID', + getRoute: (query: string, reportID: string) => `search/${query}/view/${reportID}` as const, }, // This is a utility route used to go to the user's concierge chat, or the sign-in page if the user's not authenticated diff --git a/src/SCREENS.ts b/src/SCREENS.ts index 55a067e02c97..035deb85f9e1 100644 --- a/src/SCREENS.ts +++ b/src/SCREENS.ts @@ -13,8 +13,6 @@ const PROTECTED_SCREENS = { const SCREENS = { ...PROTECTED_SCREENS, ALL_SETTINGS: 'AllSettings', - SEARCH: 'Search', - SEARCH_BOTTOM_TAB: 'SearchBottomTab', REPORT: 'Report', PROFILE_AVATAR: 'ProfileAvatar', WORKSPACE_AVATAR: 'WorkspaceAvatar', @@ -25,6 +23,11 @@ const SCREENS = { UNLINK_LOGIN: 'UnlinkLogin', SETTINGS_CENTRAL_PANE: 'SettingsCentralPane', WORKSPACES_CENTRAL_PANE: 'WorkspacesCentralPane', + SEARCH: { + CENTRAL_PANE: 'Search_Central_Pane', + REPORT: 'Search_Report', + BOTTOM_TAB: 'Search_Bottom_Tab', + }, SETTINGS: { ROOT: 'Settings_Root', SHARE_CODE: 'Settings_Share_Code', @@ -127,6 +130,7 @@ const SCREENS = { ROOM_INVITE: 'RoomInvite', REFERRAL: 'Referral', PROCESS_MONEY_REQUEST_HOLD: 'ProcessMoneyRequestHold', + SEARCH_REPORT: 'Search_Report', }, SIGN_IN_WITH_APPLE_DESKTOP: 'AppleSignInDesktop', SIGN_IN_WITH_GOOGLE_DESKTOP: 'GoogleSignInDesktop', diff --git a/src/libs/Navigation/AppNavigator/ModalStackNavigators/index.tsx b/src/libs/Navigation/AppNavigator/ModalStackNavigators/index.tsx index a2afd3f9efcb..628497a1936d 100644 --- a/src/libs/Navigation/AppNavigator/ModalStackNavigators/index.tsx +++ b/src/libs/Navigation/AppNavigator/ModalStackNavigators/index.tsx @@ -23,6 +23,7 @@ import type { ReportSettingsNavigatorParamList, RoomInviteNavigatorParamList, RoomMembersNavigatorParamList, + SearchReportParamList, SettingsNavigatorParamList, SignInNavigatorParamList, SplitDetailsNavigatorParamList, @@ -149,6 +150,10 @@ const SearchModalStackNavigator = createModalStackNavigator<FindNavigatorParamLi [SCREENS.FIND_ROOT]: () => require('../../../../pages/SearchPage').default as React.ComponentType, }); +const SearchReportModalStackNavigator = createModalStackNavigator<SearchReportParamList>({ + [SCREENS.SEARCH.REPORT]: () => require('../../../../pages/home/ReportScreen').default as React.ComponentType, +}); + const NewChatModalStackNavigator = createModalStackNavigator<NewChatNavigatorParamList>({ [SCREENS.NEW_CHAT.ROOT]: () => require('../../../../pages/NewChatSelectorPage').default as React.ComponentType, [SCREENS.NEW_CHAT.NEW_CHAT_CONFIRM]: () => require('../../../../pages/NewChatConfirmPage').default as React.ComponentType, @@ -342,4 +347,5 @@ export { WalletStatementStackNavigator, ProcessMoneyRequestHoldStackNavigator, WorkspaceSettingsModalStackNavigator, + SearchReportModalStackNavigator, }; diff --git a/src/libs/Navigation/AppNavigator/Navigators/BottomTabNavigator.tsx b/src/libs/Navigation/AppNavigator/Navigators/BottomTabNavigator.tsx index 93457a65ff3f..7f18b54c4ac5 100644 --- a/src/libs/Navigation/AppNavigator/Navigators/BottomTabNavigator.tsx +++ b/src/libs/Navigation/AppNavigator/Navigators/BottomTabNavigator.tsx @@ -29,7 +29,7 @@ function BottomTabNavigator() { component={SidebarScreen} /> <Tab.Screen - name={SCREENS.SEARCH_BOTTOM_TAB} + name={SCREENS.SEARCH.BOTTOM_TAB} component={SearchPageBottomTab} /> <Tab.Screen diff --git a/src/libs/Navigation/AppNavigator/Navigators/CentralPaneNavigator/BaseCentralPaneNavigator.tsx b/src/libs/Navigation/AppNavigator/Navigators/CentralPaneNavigator/BaseCentralPaneNavigator.tsx index fabf78eb086e..260f51901687 100644 --- a/src/libs/Navigation/AppNavigator/Navigators/CentralPaneNavigator/BaseCentralPaneNavigator.tsx +++ b/src/libs/Navigation/AppNavigator/Navigators/CentralPaneNavigator/BaseCentralPaneNavigator.tsx @@ -41,10 +41,9 @@ function BaseCentralPaneNavigator() { component={ReportScreenWrapper} /> <Stack.Screen - name={SCREENS.SEARCH} + name={SCREENS.SEARCH.CENTRAL_PANE} // We do it this way to avoid adding the url params to url component={SearchPage} - initialParams={{filter: 'all'}} /> {Object.entries(settingsScreens).map(([screenName, componentGetter]) => ( diff --git a/src/libs/Navigation/AppNavigator/Navigators/RightModalNavigator.tsx b/src/libs/Navigation/AppNavigator/Navigators/RightModalNavigator.tsx index c421bdc82028..3d3fb569f69f 100644 --- a/src/libs/Navigation/AppNavigator/Navigators/RightModalNavigator.tsx +++ b/src/libs/Navigation/AppNavigator/Navigators/RightModalNavigator.tsx @@ -137,6 +137,10 @@ function RightModalNavigator({navigation}: RightModalNavigatorProps) { name="ProcessMoneyRequestHold" component={ModalStackNavigators.ProcessMoneyRequestHoldStackNavigator} /> + <Stack.Screen + name={SCREENS.RIGHT_MODAL.SEARCH_REPORT} + component={ModalStackNavigators.SearchReportModalStackNavigator} + /> </Stack.Navigator> </View> </NoDropZone> diff --git a/src/libs/Navigation/AppNavigator/createCustomBottomTabNavigator/BottomTabBar.tsx b/src/libs/Navigation/AppNavigator/createCustomBottomTabNavigator/BottomTabBar.tsx index 143bb7936057..84138929b05d 100644 --- a/src/libs/Navigation/AppNavigator/createCustomBottomTabNavigator/BottomTabBar.tsx +++ b/src/libs/Navigation/AppNavigator/createCustomBottomTabNavigator/BottomTabBar.tsx @@ -56,8 +56,8 @@ function BottomTabBar({isLoadingApp = false}: PurposeForUsingExpensifyModalProps const currentTabName = useNavigationState<RootStackParamList, string | undefined>((state) => { const topmostCentralPaneRoute = getTopmostCentralPaneRoute(state); - if (topmostCentralPaneRoute && topmostCentralPaneRoute.name === SCREENS.SEARCH) { - return SCREENS.SEARCH; + if (topmostCentralPaneRoute && topmostCentralPaneRoute.name === SCREENS.SEARCH.CENTRAL_PANE) { + return SCREENS.SEARCH.CENTRAL_PANE; } const topmostBottomTabRoute = getTopmostBottomTabRoute(state); @@ -92,7 +92,7 @@ function BottomTabBar({isLoadingApp = false}: PurposeForUsingExpensifyModalProps </PressableWithFeedback> <PressableWithFeedback onPress={() => { - Navigation.navigate(ROUTES.SEARCH); + Navigation.navigate(ROUTES.SEARCH.getRoute('all')); }} role={CONST.ROLE.BUTTON} accessibilityLabel={translate('common.search')} @@ -102,7 +102,7 @@ function BottomTabBar({isLoadingApp = false}: PurposeForUsingExpensifyModalProps <View> <Icon src={Expensicons.ReceiptSearch} - fill={currentTabName === SCREENS.SEARCH ? theme.iconMenu : theme.icon} + fill={currentTabName === SCREENS.SEARCH.CENTRAL_PANE ? theme.iconMenu : theme.icon} width={variables.iconBottomBar} height={variables.iconBottomBar} /> diff --git a/src/libs/Navigation/AppNavigator/createCustomStackNavigator/index.native.tsx b/src/libs/Navigation/AppNavigator/createCustomStackNavigator/index.native.tsx index 151dd0a0f893..52d63e9bda26 100644 --- a/src/libs/Navigation/AppNavigator/createCustomStackNavigator/index.native.tsx +++ b/src/libs/Navigation/AppNavigator/createCustomStackNavigator/index.native.tsx @@ -2,8 +2,12 @@ import type {ParamListBase, StackActionHelpers, StackNavigationState} from '@rea import {createNavigatorFactory, useNavigationBuilder} from '@react-navigation/native'; import type {StackNavigationEventMap, StackNavigationOptions} from '@react-navigation/stack'; import {StackView} from '@react-navigation/stack'; -import React, {useRef} from 'react'; +import React, {useMemo, useRef} from 'react'; +import {View} from 'react-native'; import useWindowDimensions from '@hooks/useWindowDimensions'; +import getTopmostCentralPaneRoute from '@libs/Navigation/getTopmostCentralPaneRoute'; +import type {RootStackParamList, State} from '@libs/Navigation/types'; +import SCREENS from '@src/SCREENS'; import CustomRouter from './CustomRouter'; import type {ResponsiveStackNavigatorProps, ResponsiveStackNavigatorRouterOptions} from './types'; @@ -26,15 +30,45 @@ function ResponsiveStackNavigator(props: ResponsiveStackNavigatorProps) { initialRouteName: props.initialRouteName, }); + const {stateToRender, searchRoute} = useMemo(() => { + const routes = state.routes; + + const lastRoute = routes[routes.length - 1]; + const isLastRouteSearchRoute = getTopmostCentralPaneRoute({routes: [lastRoute]} as State<RootStackParamList>)?.name === SCREENS.SEARCH.CENTRAL_PANE; + + const firstRoute = routes[0]; + + if (isLastRouteSearchRoute) { + return { + stateToRender: { + ...state, + index: 0, + routes: [firstRoute], + }, + searchRoute: lastRoute, + }; + } + + return { + stateToRender: { + ...state, + index: routes.length - 1, + routes: [...routes], + }, + searchRoute: undefined, + }; + }, [state]); + return ( <NavigationContent> <StackView // eslint-disable-next-line react/jsx-props-no-spreading {...props} - state={state} + state={stateToRender} descriptors={descriptors} navigation={navigation} /> + {searchRoute && <View style={{display: 'none'}}>{descriptors[searchRoute.key].render()}</View>} </NavigationContent> ); } diff --git a/src/libs/Navigation/AppNavigator/createCustomStackNavigator/index.tsx b/src/libs/Navigation/AppNavigator/createCustomStackNavigator/index.tsx index 01e7743c1760..767190bb1967 100644 --- a/src/libs/Navigation/AppNavigator/createCustomStackNavigator/index.tsx +++ b/src/libs/Navigation/AppNavigator/createCustomStackNavigator/index.tsx @@ -60,7 +60,7 @@ function ResponsiveStackNavigator(props: ResponsiveStackNavigatorProps) { const routes = reduceCentralPaneRoutes(state.routes); const lastRoute = routes[routes.length - 1]; - const isLastRouteSearchRoute = getTopmostCentralPaneRoute({routes: [lastRoute]} as State<RootStackParamList>)?.name === SCREENS.SEARCH; + const isLastRouteSearchRoute = getTopmostCentralPaneRoute({routes: [lastRoute]} as State<RootStackParamList>)?.name === SCREENS.SEARCH.CENTRAL_PANE; const firstRoute = routes[0]; diff --git a/src/libs/Navigation/linkingConfig/CENTRAL_PANE_TO_RHP_MAPPING.ts b/src/libs/Navigation/linkingConfig/CENTRAL_PANE_TO_RHP_MAPPING.ts index 95233bfed079..5d2c3ab9d1d1 100755 --- a/src/libs/Navigation/linkingConfig/CENTRAL_PANE_TO_RHP_MAPPING.ts +++ b/src/libs/Navigation/linkingConfig/CENTRAL_PANE_TO_RHP_MAPPING.ts @@ -36,6 +36,7 @@ const CENTRAL_PANE_TO_RHP_MAPPING: Partial<Record<CentralPaneName, string[]>> = ], [SCREENS.SETTINGS.SECURITY]: [SCREENS.SETTINGS.TWO_FACTOR_AUTH, SCREENS.SETTINGS.CLOSE], [SCREENS.SETTINGS.ABOUT]: [SCREENS.SETTINGS.APP_DOWNLOAD_LINKS, SCREENS.SETTINGS.TROUBLESHOOT], + [SCREENS.SEARCH.CENTRAL_PANE]: [SCREENS.SEARCH.REPORT], }; export default CENTRAL_PANE_TO_RHP_MAPPING; diff --git a/src/libs/Navigation/linkingConfig/TAB_TO_CENTRAL_PANE_MAPPING.ts b/src/libs/Navigation/linkingConfig/TAB_TO_CENTRAL_PANE_MAPPING.ts index efda5da092a5..efd0a1ae756d 100755 --- a/src/libs/Navigation/linkingConfig/TAB_TO_CENTRAL_PANE_MAPPING.ts +++ b/src/libs/Navigation/linkingConfig/TAB_TO_CENTRAL_PANE_MAPPING.ts @@ -3,7 +3,7 @@ import SCREENS from '@src/SCREENS'; const TAB_TO_CENTRAL_PANE_MAPPING: Record<BottomTabName, CentralPaneName[]> = { [SCREENS.HOME]: [SCREENS.REPORT], - [SCREENS.SEARCH_BOTTOM_TAB]: [SCREENS.SEARCH], + [SCREENS.SEARCH.BOTTOM_TAB]: [SCREENS.SEARCH.CENTRAL_PANE], [SCREENS.SETTINGS.ROOT]: [ SCREENS.SETTINGS.PROFILE.ROOT, SCREENS.SETTINGS.PREFERENCES.ROOT, diff --git a/src/libs/Navigation/linkingConfig/config.ts b/src/libs/Navigation/linkingConfig/config.ts index 9ba599874ba1..8f1e50ce9a2b 100644 --- a/src/libs/Navigation/linkingConfig/config.ts +++ b/src/libs/Navigation/linkingConfig/config.ts @@ -61,7 +61,7 @@ const config: LinkingOptions<RootStackParamList>['config'] = { exact: true, }, [SCREENS.SETTINGS.WORKSPACES]: ROUTES.SETTINGS_WORKSPACES, - [SCREENS.SEARCH]: ROUTES.SEARCH, + [SCREENS.SEARCH.CENTRAL_PANE]: ROUTES.SEARCH.route, }, }, [SCREENS.NOT_FOUND]: '*', @@ -593,6 +593,11 @@ const config: LinkingOptions<RootStackParamList>['config'] = { [SCREENS.PROCESS_MONEY_REQUEST_HOLD_ROOT]: ROUTES.PROCESS_MONEY_REQUEST_HOLD, }, }, + [SCREENS.RIGHT_MODAL.SEARCH_REPORT]: { + screens: { + [SCREENS.SEARCH.REPORT]: ROUTES.SEARCH_REPORT.route, + }, + }, }, }, diff --git a/src/libs/Navigation/types.ts b/src/libs/Navigation/types.ts index a2e8bbef4c22..bed1a4b555ad 100644 --- a/src/libs/Navigation/types.ts +++ b/src/libs/Navigation/types.ts @@ -59,8 +59,8 @@ type CentralPaneNavigatorParamList = { [SCREENS.SETTINGS.WALLET.ROOT]: undefined; [SCREENS.SETTINGS.ABOUT]: undefined; [SCREENS.SETTINGS.WORKSPACES]: undefined; - [SCREENS.SEARCH]: { - filter: string; + [SCREENS.SEARCH.CENTRAL_PANE]: { + query: string; }; }; @@ -549,6 +549,13 @@ type LeftModalNavigatorParamList = { [SCREENS.LEFT_MODAL.WORKSPACE_SWITCHER]: NavigatorScreenParams<WorkspaceSwitcherNavigatorParamList>; }; +type SearchReportParamList = { + [SCREENS.SEARCH.REPORT]: { + query: string; + reportID: string; + }; +}; + type RightModalNavigatorParamList = { [SCREENS.RIGHT_MODAL.SETTINGS]: NavigatorScreenParams<SettingsNavigatorParamList>; [SCREENS.RIGHT_MODAL.NEW_CHAT]: NavigatorScreenParams<NewChatNavigatorParamList>; @@ -576,6 +583,7 @@ type RightModalNavigatorParamList = { [SCREENS.RIGHT_MODAL.PROCESS_MONEY_REQUEST_HOLD]: NavigatorScreenParams<ProcessMoneyRequestHoldNavigatorParamList>; [SCREENS.RIGHT_MODAL.REFERRAL]: NavigatorScreenParams<ReferralDetailsNavigatorParamList>; [SCREENS.RIGHT_MODAL.PRIVATE_NOTES]: NavigatorScreenParams<PrivateNotesNavigatorParamList>; + [SCREENS.RIGHT_MODAL.SEARCH_REPORT]: NavigatorScreenParams<SearchReportParamList>; }; type WorkspacesCentralPaneNavigatorParamList = { @@ -639,7 +647,7 @@ type FullScreenNavigatorParamList = { type BottomTabNavigatorParamList = { [SCREENS.HOME]: undefined; - [SCREENS.SEARCH_BOTTOM_TAB]: undefined; + [SCREENS.SEARCH.BOTTOM_TAB]: undefined; [SCREENS.SETTINGS.ROOT]: undefined; }; @@ -767,4 +775,5 @@ export type { FullScreenNavigatorParamList, WorkspacesCentralPaneNavigatorParamList, BackToParams, + SearchReportParamList, }; diff --git a/src/pages/Search/SearchPage.tsx b/src/pages/Search/SearchPage.tsx index 2decf6f96fe8..488ce1dbb28a 100644 --- a/src/pages/Search/SearchPage.tsx +++ b/src/pages/Search/SearchPage.tsx @@ -10,7 +10,7 @@ type SearchPageProps = StackScreenProps<CentralPaneNavigatorParamList, typeof SC function SearchPage({route}: SearchPageProps) { return ( <ScreenWrapper testID="testPage"> - <SearchResults filter={route.params.filter} /> + <SearchResults filter={route.params.query} /> </ScreenWrapper> ); } diff --git a/src/pages/Search/SearchPageBottomTab.tsx b/src/pages/Search/SearchPageBottomTab.tsx index 5267a4396ac0..cc108010cb55 100644 --- a/src/pages/Search/SearchPageBottomTab.tsx +++ b/src/pages/Search/SearchPageBottomTab.tsx @@ -42,7 +42,7 @@ function SearchPageBottomTab() { action: singleExecution( waitForNavigate(() => { setFilter('all'); - Navigation.navigate(ROUTES.SEARCH_WITH_FILTER.getRoute('all')); + Navigation.navigate(ROUTES.SEARCH.getRoute('all')); }), ), }, @@ -52,7 +52,7 @@ function SearchPageBottomTab() { action: singleExecution( waitForNavigate(() => { setFilter('sent'); - Navigation.navigate(ROUTES.SEARCH_WITH_FILTER.getRoute('sent')); + Navigation.navigate(ROUTES.SEARCH.getRoute('sent')); }), ), }, @@ -62,7 +62,7 @@ function SearchPageBottomTab() { action: singleExecution( waitForNavigate(() => { setFilter('drafts'); - Navigation.navigate(ROUTES.SEARCH_WITH_FILTER.getRoute('drafts')); + Navigation.navigate(ROUTES.SEARCH.getRoute('drafts')); }), ), }, @@ -76,7 +76,7 @@ function SearchPageBottomTab() { tabBar={TabSelector} onTabSelected={(tab: string) => { setFilter(tab); - Navigation.navigate(ROUTES.SEARCH_WITH_FILTER.getRoute(tab)); + Navigation.navigate(ROUTES.SEARCH.getRoute(tab)); }} > <TopTab.Screen name={CONST.TAB_SEARCH.ALL}>{() => <SearchResults filter="all" />}</TopTab.Screen> diff --git a/src/pages/home/ReportScreen.tsx b/src/pages/home/ReportScreen.tsx index ef277984b4e9..d2833a4a77f9 100644 --- a/src/pages/home/ReportScreen.tsx +++ b/src/pages/home/ReportScreen.tsx @@ -356,7 +356,8 @@ function ReportScreen({ return reportIDFromRoute !== '' && !!report.reportID && !isTransitioning; }, [report, reportIDFromRoute]); - const isLoading = !ReportUtils.isValidReportIDFromPath(reportIDFromRoute) || !isSidebarLoaded || PersonalDetailsUtils.isPersonalDetailsEmpty(); + // @TODO: isSidebarLoaded has been removed from isLoading variable to prevent from infinite loading on SCREENS.SEARCH.REPORT. Remember to undo this change and handle this case + const isLoading = !ReportUtils.isValidReportIDFromPath(reportIDFromRoute) || PersonalDetailsUtils.isPersonalDetailsEmpty(); const shouldShowSkeleton = !isLinkedMessageAvailable && (isLinkingToMessage || diff --git a/tests/perf-test/SearchPage.perf-test.tsx b/tests/perf-test/SearchPage.perf-test.tsx index 95f5630e3fe9..bb2d31987f8e 100644 --- a/tests/perf-test/SearchPage.perf-test.tsx +++ b/tests/perf-test/SearchPage.perf-test.tsx @@ -119,7 +119,7 @@ afterEach(() => { PusherHelper.teardown(); }); -type SearchPageProps = StackScreenProps<RootStackParamList, typeof SCREENS.SEARCH_ROOT> & { +type SearchPageProps = StackScreenProps<RootStackParamList, typeof SCREENS.FIND_ROOT> & { betas: OnyxEntry<Beta[]>; reports: OnyxCollection<Report>; isSearchingForReports: OnyxEntry<boolean>; From d573e25cccf835d097ddef39230a172dd16fd374 Mon Sep 17 00:00:00 2001 From: Alberto <alberto@expensify.com> Date: Wed, 10 Apr 2024 00:03:18 +0200 Subject: [PATCH 058/206] typescript --- src/libs/actions/Task.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libs/actions/Task.ts b/src/libs/actions/Task.ts index 5d4e06bbf7e5..b12a7ef0d796 100644 --- a/src/libs/actions/Task.ts +++ b/src/libs/actions/Task.ts @@ -729,7 +729,7 @@ function setParentReportID(parentReportID: string) { /** * Clears out the task info from the store and navigates to the NewTaskDetails page */ -function clearOutTaskInfoAndNavigate(reportID: string, chatReport: OnyxEntry<OnyxTypes.Report>, accountID = 0, skipConfirmation = false) { +function clearOutTaskInfoAndNavigate(reportID?: string, chatReport?: OnyxEntry<OnyxTypes.Report>, accountID = 0, skipConfirmation = false) { clearOutTaskInfo(skipConfirmation); if (reportID && reportID !== '0') { setParentReportID(reportID); From fab20c210060f7a109b68f4771649f54ca3ddf4b Mon Sep 17 00:00:00 2001 From: Alberto <alberto@expensify.com> Date: Wed, 10 Apr 2024 00:04:15 +0200 Subject: [PATCH 059/206] lint --- .../sidebar/SidebarScreen/FloatingActionButtonAndPopover.tsx | 1 - 1 file changed, 1 deletion(-) diff --git a/src/pages/home/sidebar/SidebarScreen/FloatingActionButtonAndPopover.tsx b/src/pages/home/sidebar/SidebarScreen/FloatingActionButtonAndPopover.tsx index 7395ccdf9774..554aee761c4a 100644 --- a/src/pages/home/sidebar/SidebarScreen/FloatingActionButtonAndPopover.tsx +++ b/src/pages/home/sidebar/SidebarScreen/FloatingActionButtonAndPopover.tsx @@ -180,7 +180,6 @@ function FloatingActionButtonAndPopover( return; case CONST.QUICK_ACTIONS.ASSIGN_TASK: Task.clearOutTaskInfoAndNavigate(quickAction?.chatReportID ?? '', quickActionReport, quickAction.targetAccountID ?? 0, true); - return; default: } }; From 2a7b093a47195af5c6742f6028fecf5b77fca16a Mon Sep 17 00:00:00 2001 From: Alberto <alberto@expensify.com> Date: Wed, 10 Apr 2024 00:25:43 +0200 Subject: [PATCH 060/206] lint --- .../sidebar/SidebarScreen/FloatingActionButtonAndPopover.tsx | 1 + 1 file changed, 1 insertion(+) diff --git a/src/pages/home/sidebar/SidebarScreen/FloatingActionButtonAndPopover.tsx b/src/pages/home/sidebar/SidebarScreen/FloatingActionButtonAndPopover.tsx index 554aee761c4a..cdba77e9182f 100644 --- a/src/pages/home/sidebar/SidebarScreen/FloatingActionButtonAndPopover.tsx +++ b/src/pages/home/sidebar/SidebarScreen/FloatingActionButtonAndPopover.tsx @@ -180,6 +180,7 @@ function FloatingActionButtonAndPopover( return; case CONST.QUICK_ACTIONS.ASSIGN_TASK: Task.clearOutTaskInfoAndNavigate(quickAction?.chatReportID ?? '', quickActionReport, quickAction.targetAccountID ?? 0, true); + break; default: } }; From a707c28b009c773b7d1b16903beb69472d5f783d Mon Sep 17 00:00:00 2001 From: Adam Grzybowski <adam.grzybowski@swmansion.com> Date: Wed, 10 Apr 2024 11:40:41 +0200 Subject: [PATCH 061/206] remove native.tsx for createCustomStackNavigator --- .../index.native.tsx | 44 ------------------- 1 file changed, 44 deletions(-) delete mode 100644 src/libs/Navigation/AppNavigator/createCustomStackNavigator/index.native.tsx diff --git a/src/libs/Navigation/AppNavigator/createCustomStackNavigator/index.native.tsx b/src/libs/Navigation/AppNavigator/createCustomStackNavigator/index.native.tsx deleted file mode 100644 index 151dd0a0f893..000000000000 --- a/src/libs/Navigation/AppNavigator/createCustomStackNavigator/index.native.tsx +++ /dev/null @@ -1,44 +0,0 @@ -import type {ParamListBase, StackActionHelpers, StackNavigationState} from '@react-navigation/native'; -import {createNavigatorFactory, useNavigationBuilder} from '@react-navigation/native'; -import type {StackNavigationEventMap, StackNavigationOptions} from '@react-navigation/stack'; -import {StackView} from '@react-navigation/stack'; -import React, {useRef} from 'react'; -import useWindowDimensions from '@hooks/useWindowDimensions'; -import CustomRouter from './CustomRouter'; -import type {ResponsiveStackNavigatorProps, ResponsiveStackNavigatorRouterOptions} from './types'; - -function ResponsiveStackNavigator(props: ResponsiveStackNavigatorProps) { - const {isSmallScreenWidth} = useWindowDimensions(); - - const isSmallScreenWidthRef = useRef(isSmallScreenWidth); - - isSmallScreenWidthRef.current = isSmallScreenWidth; - - const {navigation, state, descriptors, NavigationContent} = useNavigationBuilder< - StackNavigationState<ParamListBase>, - ResponsiveStackNavigatorRouterOptions, - StackActionHelpers<ParamListBase>, - StackNavigationOptions, - StackNavigationEventMap - >(CustomRouter, { - children: props.children, - screenOptions: props.screenOptions, - initialRouteName: props.initialRouteName, - }); - - return ( - <NavigationContent> - <StackView - // eslint-disable-next-line react/jsx-props-no-spreading - {...props} - state={state} - descriptors={descriptors} - navigation={navigation} - /> - </NavigationContent> - ); -} - -ResponsiveStackNavigator.displayName = 'ResponsiveStackNavigator'; - -export default createNavigatorFactory<StackNavigationState<ParamListBase>, StackNavigationOptions, StackNavigationEventMap, typeof ResponsiveStackNavigator>(ResponsiveStackNavigator); From 3afd0b9251871e4ca87bec16ced4b126e117ddbe Mon Sep 17 00:00:00 2001 From: Adam Grzybowski <adam.grzybowski@swmansion.com> Date: Wed, 10 Apr 2024 11:41:10 +0200 Subject: [PATCH 062/206] add check for search page in getAdaptedStateFromPath --- src/libs/Navigation/linkingConfig/getAdaptedStateFromPath.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/libs/Navigation/linkingConfig/getAdaptedStateFromPath.ts b/src/libs/Navigation/linkingConfig/getAdaptedStateFromPath.ts index 3cdcfba59466..5f5e023639b0 100644 --- a/src/libs/Navigation/linkingConfig/getAdaptedStateFromPath.ts +++ b/src/libs/Navigation/linkingConfig/getAdaptedStateFromPath.ts @@ -302,7 +302,9 @@ function getAdaptedState(state: PartialState<NavigationState<RootStackParamList> // Routes // - found bottom tab // - matching central pane on desktop layout - if (isNarrowLayout) { + + // We want to make sure that the bottom tab search page is always pushed with matching central pane page. Even on the narrow layout. + if (isNarrowLayout && bottomTabNavigator.state?.routes[0].name !== SCREENS.SEARCH_BOTTOM_TAB) { return { adaptedState: state, metainfo, From 2206c1d61b5bb091869517d8a84898472fd3d363 Mon Sep 17 00:00:00 2001 From: Wojciech Boman <wojciechboman@gmail.com> Date: Wed, 10 Apr 2024 11:55:35 +0200 Subject: [PATCH 063/206] Handle passing params to useActiveRoute --- src/hooks/useActiveRoute.ts | 3 +- .../Navigators/ActiveRouteContext.ts | 3 +- .../Navigators/BottomTabNavigator.tsx | 2 +- src/pages/Search/SearchPageBottomTab.tsx | 43 +++++-------------- src/pages/settings/InitialSettingsPage.tsx | 4 +- 5 files changed, 18 insertions(+), 37 deletions(-) diff --git a/src/hooks/useActiveRoute.ts b/src/hooks/useActiveRoute.ts index 651d00a0c37c..afccc28f8243 100644 --- a/src/hooks/useActiveRoute.ts +++ b/src/hooks/useActiveRoute.ts @@ -1,7 +1,8 @@ import {useContext} from 'react'; import ActiveRouteContext from '@libs/Navigation/AppNavigator/Navigators/ActiveRouteContext'; +import type {CentralPaneNavigatorParamList, NavigationPartialRoute} from '@libs/Navigation/types'; -function useActiveRoute(): string { +function useActiveRoute(): NavigationPartialRoute<keyof CentralPaneNavigatorParamList> | undefined { return useContext(ActiveRouteContext); } diff --git a/src/libs/Navigation/AppNavigator/Navigators/ActiveRouteContext.ts b/src/libs/Navigation/AppNavigator/Navigators/ActiveRouteContext.ts index d1d14d43af1a..6d0de3211e7c 100644 --- a/src/libs/Navigation/AppNavigator/Navigators/ActiveRouteContext.ts +++ b/src/libs/Navigation/AppNavigator/Navigators/ActiveRouteContext.ts @@ -1,5 +1,6 @@ import React from 'react'; +import type {CentralPaneNavigatorParamList, NavigationPartialRoute} from '@libs/Navigation/types'; -const ActiveRouteContext = React.createContext(''); +const ActiveRouteContext = React.createContext<NavigationPartialRoute<keyof CentralPaneNavigatorParamList> | undefined>(undefined); export default ActiveRouteContext; diff --git a/src/libs/Navigation/AppNavigator/Navigators/BottomTabNavigator.tsx b/src/libs/Navigation/AppNavigator/Navigators/BottomTabNavigator.tsx index 7f18b54c4ac5..6680ea302441 100644 --- a/src/libs/Navigation/AppNavigator/Navigators/BottomTabNavigator.tsx +++ b/src/libs/Navigation/AppNavigator/Navigators/BottomTabNavigator.tsx @@ -22,7 +22,7 @@ function BottomTabNavigator() { const activeRoute = useNavigationState(getTopmostCentralPaneRoute); return ( - <ActiveRouteContext.Provider value={activeRoute?.name ?? ''}> + <ActiveRouteContext.Provider value={activeRoute}> <Tab.Navigator screenOptions={screenOptions}> <Tab.Screen name={SCREENS.HOME} diff --git a/src/pages/Search/SearchPageBottomTab.tsx b/src/pages/Search/SearchPageBottomTab.tsx index cc108010cb55..a1400f740abd 100644 --- a/src/pages/Search/SearchPageBottomTab.tsx +++ b/src/pages/Search/SearchPageBottomTab.tsx @@ -1,24 +1,19 @@ -import {useNavigationState} from '@react-navigation/native'; -import {StackScreenProps} from '@react-navigation/stack'; import React, {useState} from 'react'; -import {Text, View} from 'react-native'; +import {View} from 'react-native'; import MenuItem from '@components/MenuItem'; import ScreenWrapper from '@components/ScreenWrapper'; import TabSelector from '@components/TabSelector/TabSelector'; +import useActiveRoute from '@hooks/useActiveRoute'; import useSingleExecution from '@hooks/useSingleExecution'; import useThemeStyles from '@hooks/useThemeStyles'; import useWaitForNavigation from '@hooks/useWaitForNavigation'; import useWindowDimensions from '@hooks/useWindowDimensions'; -import getTopmostCentralPaneRoute from '@libs/Navigation/getTopmostCentralPaneRoute'; import Navigation from '@libs/Navigation/Navigation'; import OnyxTabNavigator, {TopTab} from '@libs/Navigation/OnyxTabNavigator'; -import type {CentralPaneNavigatorParamList, RootStackParamList} from '@libs/Navigation/types'; import * as Expensicons from '@src/components/Icon/Expensicons'; import CONST from '@src/CONST'; import ROUTES from '@src/ROUTES'; -import type SCREENS from '@src/SCREENS'; -import IconAsset from '@src/types/utils/IconAsset'; -import SearchPage from './SearchPage'; +import type IconAsset from '@src/types/utils/IconAsset'; import SearchResults from './SearchResults'; type SearchMenuItem = { @@ -32,39 +27,24 @@ function SearchPageBottomTab() { const {singleExecution} = useSingleExecution(); const {isSmallScreenWidth} = useWindowDimensions(); const waitForNavigate = useWaitForNavigation(); - - const [filter, setFilter] = useState('all'); + const activeRoute = useActiveRoute(); + const currentQuery = activeRoute?.params?.query; const searchMenuItems: SearchMenuItem[] = [ { title: 'All', icon: Expensicons.ExpensifyLogoNew, - action: singleExecution( - waitForNavigate(() => { - setFilter('all'); - Navigation.navigate(ROUTES.SEARCH.getRoute('all')); - }), - ), + action: singleExecution(waitForNavigate(() => Navigation.navigate(ROUTES.SEARCH.getRoute('all')))), }, { title: 'Sent', icon: Expensicons.ExpensifyLogoNew, - action: singleExecution( - waitForNavigate(() => { - setFilter('sent'); - Navigation.navigate(ROUTES.SEARCH.getRoute('sent')); - }), - ), + action: singleExecution(waitForNavigate(() => Navigation.navigate(ROUTES.SEARCH.getRoute('sent')))), }, { title: 'Drafts', icon: Expensicons.ExpensifyLogoNew, - action: singleExecution( - waitForNavigate(() => { - setFilter('drafts'); - Navigation.navigate(ROUTES.SEARCH.getRoute('drafts')); - }), - ), + action: singleExecution(waitForNavigate(() => Navigation.navigate(ROUTES.SEARCH.getRoute('drafts')))), }, ]; @@ -74,10 +54,7 @@ function SearchPageBottomTab() { <OnyxTabNavigator id={CONST.TAB.NEW_CHAT_TAB_ID} tabBar={TabSelector} - onTabSelected={(tab: string) => { - setFilter(tab); - Navigation.navigate(ROUTES.SEARCH.getRoute(tab)); - }} + onTabSelected={(tab: string) => Navigation.navigate(ROUTES.SEARCH.getRoute(tab))} > <TopTab.Screen name={CONST.TAB_SEARCH.ALL}>{() => <SearchResults filter="all" />}</TopTab.Screen> <TopTab.Screen name={CONST.TAB_SEARCH.SENT}>{() => <SearchResults filter="sent" />}</TopTab.Screen> @@ -98,7 +75,7 @@ function SearchPageBottomTab() { icon={item.icon} onPress={item.action} wrapperStyle={styles.sectionMenuItem} - focused={item.title.toLowerCase() === filter} + focused={item.title.toLowerCase() === currentQuery} hoverAndPressStyle={styles.hoveredComponentBG} isPaneMenu /> diff --git a/src/pages/settings/InitialSettingsPage.tsx b/src/pages/settings/InitialSettingsPage.tsx index 73bd031b5978..7397020448e5 100755 --- a/src/pages/settings/InitialSettingsPage.tsx +++ b/src/pages/settings/InitialSettingsPage.tsx @@ -319,7 +319,9 @@ function InitialSettingsPage({session, userWallet, bankAccountList, fundList, wa hoverAndPressStyle={styles.hoveredComponentBG} shouldBlockSelection={Boolean(item.link)} onSecondaryInteraction={item.link ? (event) => openPopover(item.link, event) : undefined} - focused={!!activeRoute && !!item.routeName && !!(activeRoute.toLowerCase().replaceAll('_', '') === item.routeName.toLowerCase().replaceAll('/', ''))} + focused={ + !!activeRoute?.name && !!item.routeName && !!(activeRoute?.name.toLowerCase().replaceAll('_', '') === item.routeName.toLowerCase().replaceAll('/', '')) + } isPaneMenu iconRight={item.iconRight} shouldShowRightIcon={item.shouldShowRightIcon} From 34f0411cb1b10b68b37a10219eedab51bb639836 Mon Sep 17 00:00:00 2001 From: tienifr <christianwen18@gmail.com> Date: Wed, 10 Apr 2024 17:15:07 +0700 Subject: [PATCH 064/206] use waitForNavigate where neccesary --- src/components/MenuItem.tsx | 10 +++------- src/components/TaskHeaderActionButton.tsx | 6 +++--- src/pages/settings/Profile/ProfilePage.tsx | 7 ++++--- 3 files changed, 10 insertions(+), 13 deletions(-) diff --git a/src/components/MenuItem.tsx b/src/components/MenuItem.tsx index 12ddf04658f4..6a260c524c76 100644 --- a/src/components/MenuItem.tsx +++ b/src/components/MenuItem.tsx @@ -329,7 +329,7 @@ function MenuItem( const StyleUtils = useStyleUtils(); const combinedStyle = [style, styles.popoverMenuItem]; const {isSmallScreenWidth} = useWindowDimensions(); - const {isExecuting, singleExecution, waitForNavigate} = useContext(MenuItemGroupContext) ?? {}; + const {isExecuting, singleExecution} = useContext(MenuItemGroupContext) ?? {}; const isDeleted = style && Array.isArray(style) ? style.includes(styles.offlineFeedback.deleted) : false; const descriptionVerticalMargin = shouldShowDescriptionOnTop ? styles.mb1 : styles.mt1; @@ -404,15 +404,11 @@ function MenuItem( } if (onPress && event) { - if (!singleExecution || !waitForNavigate) { + if (!singleExecution) { onPress(event); return; } - singleExecution( - waitForNavigate(() => { - onPress(event); - }), - )(); + singleExecution(onPress)(event); } }; diff --git a/src/components/TaskHeaderActionButton.tsx b/src/components/TaskHeaderActionButton.tsx index 1a614faf6df5..44f87fd7981f 100644 --- a/src/components/TaskHeaderActionButton.tsx +++ b/src/components/TaskHeaderActionButton.tsx @@ -25,15 +25,15 @@ type TaskHeaderActionButtonProps = TaskHeaderActionButtonOnyxProps & { function TaskHeaderActionButton({report, session}: TaskHeaderActionButtonProps) { const {translate} = useLocalize(); const styles = useThemeStyles(); - const {isExecuting, singleExecution, waitForNavigate} = useContext(MenuItemGroupContext) ?? {}; + const {isExecuting, singleExecution} = useContext(MenuItemGroupContext) ?? {}; const onPressAction = () => { const onPress = () => (ReportUtils.isCompletedTaskReport(report) ? Task.reopenTask(report) : Task.completeTask(report)); - if (!singleExecution || !waitForNavigate) { + if (!singleExecution) { onPress(); return; } - singleExecution(waitForNavigate(onPress))(); + singleExecution(onPress)(); }; return ( diff --git a/src/pages/settings/Profile/ProfilePage.tsx b/src/pages/settings/Profile/ProfilePage.tsx index 4c5ed88e6898..f33a86ed2d46 100755 --- a/src/pages/settings/Profile/ProfilePage.tsx +++ b/src/pages/settings/Profile/ProfilePage.tsx @@ -1,11 +1,11 @@ -import React, {useEffect} from 'react'; +import React, {useContext, useEffect} from 'react'; import {View} from 'react-native'; import type {OnyxEntry} from 'react-native-onyx'; import {withOnyx} from 'react-native-onyx'; import FullScreenLoadingIndicator from '@components/FullscreenLoadingIndicator'; import HeaderWithBackButton from '@components/HeaderWithBackButton'; import * as Illustrations from '@components/Icon/Illustrations'; -import MenuItemGroup from '@components/MenuItemGroup'; +import MenuItemGroup, {MenuItemGroupContext} from '@components/MenuItemGroup'; import MenuItemWithTopDescription from '@components/MenuItemWithTopDescription'; import ScreenWrapper from '@components/ScreenWrapper'; import ScrollView from '@components/ScrollView'; @@ -61,6 +61,7 @@ function ProfilePage({ const StyleUtils = useStyleUtils(); const {translate} = useLocalize(); const {isSmallScreenWidth} = useWindowDimensions(); + const {waitForNavigate} = useContext(MenuItemGroupContext) ?? {}; const getPronouns = (): string => { const pronounsKey = currentUserPersonalDetails?.pronouns?.replace(CONST.PRONOUNS.PREFIX, '') ?? ''; @@ -179,7 +180,7 @@ function ProfilePage({ title={detail.title} description={detail.description} wrapperStyle={styles.sectionMenuItemTopDescription} - onPress={() => Navigation.navigate(detail.pageRoute)} + onPress={waitForNavigate ? waitForNavigate(() => Navigation.navigate(detail.pageRoute)) : () => Navigation.navigate(detail.pageRoute)} /> ))} </> From a1b228a1ee762d6303f60de945a6aa22e1f5ac9e Mon Sep 17 00:00:00 2001 From: Wojciech Boman <wojciechboman@gmail.com> Date: Wed, 10 Apr 2024 12:41:13 +0200 Subject: [PATCH 065/206] Adjust getAdaptedStateFromPath to new search routes --- src/libs/Navigation/linkingConfig/getAdaptedStateFromPath.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libs/Navigation/linkingConfig/getAdaptedStateFromPath.ts b/src/libs/Navigation/linkingConfig/getAdaptedStateFromPath.ts index 5f5e023639b0..8df528efa792 100644 --- a/src/libs/Navigation/linkingConfig/getAdaptedStateFromPath.ts +++ b/src/libs/Navigation/linkingConfig/getAdaptedStateFromPath.ts @@ -304,7 +304,7 @@ function getAdaptedState(state: PartialState<NavigationState<RootStackParamList> // - matching central pane on desktop layout // We want to make sure that the bottom tab search page is always pushed with matching central pane page. Even on the narrow layout. - if (isNarrowLayout && bottomTabNavigator.state?.routes[0].name !== SCREENS.SEARCH_BOTTOM_TAB) { + if (isNarrowLayout && bottomTabNavigator.state?.routes[0].name !== SCREENS.SEARCH.BOTTOM_TAB) { return { adaptedState: state, metainfo, From a72d2217e7a0bf7f4a9b9e6515a18fce49f60cd5 Mon Sep 17 00:00:00 2001 From: Adam Grzybowski <adam.grzybowski@swmansion.com> Date: Wed, 10 Apr 2024 17:10:29 +0200 Subject: [PATCH 066/206] fix linnkTo --- src/libs/Navigation/linkTo.ts | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/src/libs/Navigation/linkTo.ts b/src/libs/Navigation/linkTo.ts index 35b3460361c9..630a44fe1d3b 100644 --- a/src/libs/Navigation/linkTo.ts +++ b/src/libs/Navigation/linkTo.ts @@ -6,7 +6,6 @@ import {extractPolicyIDFromPath, getPathWithoutPolicyID} from '@libs/PolicyUtils import CONST from '@src/CONST'; import NAVIGATORS from '@src/NAVIGATORS'; import type {Route} from '@src/ROUTES'; -import SCREENS from '@src/SCREENS'; import getActionsFromPartialDiff from './AppNavigator/getActionsFromPartialDiff'; import getPartialStateDiff from './AppNavigator/getPartialStateDiff'; import dismissModal from './dismissModal'; @@ -14,7 +13,6 @@ import getPolicyIDFromState from './getPolicyIDFromState'; import getStateFromPath from './getStateFromPath'; import getTopmostBottomTabRoute from './getTopmostBottomTabRoute'; import getTopmostCentralPaneRoute from './getTopmostCentralPaneRoute'; -import getTopmostReportId from './getTopmostReportId'; import linkingConfig from './linkingConfig'; import getAdaptedStateFromPath from './linkingConfig/getAdaptedStateFromPath'; import getMatchingBottomTabRouteForState from './linkingConfig/getMatchingBottomTabRouteForState'; @@ -32,6 +30,18 @@ type ActionPayload = { params?: ActionPayloadParams; }; +// eslint-disable-next-line @typescript-eslint/ban-types +const shallowCompare = (obj1?: object, obj2?: object) => { + if (!obj1 && !obj2) { + return true; + } + if (obj1 && obj2) { + // @ts-expect-error we know that obj1 and obj2 are params of a route. + return Object.keys(obj1).length === Object.keys(obj2).length && Object.keys(obj1).every((key) => obj1[key] === obj2[key]); + } + return false; +}; + /** * Motivation for this function is described in NAVIGATION.md * @@ -153,25 +163,15 @@ export default function linkTo(navigation: NavigationContainerRef<RootStackParam const topRouteName = rootState?.routes?.at(-1)?.name; const isTargetNavigatorOnTop = topRouteName === action.payload.name; - const isTargetScreenDifferentThanCurrent = topmostCentralPaneRoute && topmostCentralPaneRoute.name !== action.payload.params?.screen; - const isTargetScreenReportWithDifferentReportID = action.payload.params?.screen === SCREENS.REPORT && getTopmostReportId(rootState) !== getTopmostReportId(stateFromPath); - const isTargetScreenSearchWithDifferentParams = - action.payload.params?.screen === SCREENS.SEARCH && - topmostCentralPaneRoute && - topmostCentralPaneRoute.params && - 'filter' in topmostCentralPaneRoute.params && - topmostCentralPaneRoute?.params?.filter !== action.payload.params?.params?.filter; + const isTargetScreenDifferentThanCurrent = Boolean(topmostCentralPaneRoute && topmostCentralPaneRoute.name !== action.payload.params?.screen); + const areParamsDifferent = !shallowCompare(topmostCentralPaneRoute?.params, action.payload.params?.params); // In case if type is 'FORCED_UP' we replace current screen with the provided. This means the current screen no longer exists in the stack if (type === CONST.NAVIGATION.TYPE.FORCED_UP) { action.type = CONST.NAVIGATION.ACTION_TYPE.REPLACE; // If this action is navigating to the report screen and the top most navigator is different from the one we want to navigate - PUSH the new screen to the top of the stack - } else if ( - action.payload.name === NAVIGATORS.CENTRAL_PANE_NAVIGATOR && - (!topmostCentralPaneRoute || - (topmostCentralPaneRoute && (isTargetScreenDifferentThanCurrent || isTargetScreenReportWithDifferentReportID || isTargetScreenSearchWithDifferentParams))) - ) { + } else if (action.payload.name === NAVIGATORS.CENTRAL_PANE_NAVIGATOR && (isTargetScreenDifferentThanCurrent || areParamsDifferent)) { // We need to push a tab if the tab doesn't match the central pane route that we are going to push. const topmostBottomTabRoute = getTopmostBottomTabRoute(rootState); const matchingBottomTabRoute = getMatchingBottomTabRouteForState(stateFromPath, policyID); From 633d881e2a06f0cd0ae57648709ad54b6c7e2b23 Mon Sep 17 00:00:00 2001 From: Adam Grzybowski <adam.grzybowski@swmansion.com> Date: Wed, 10 Apr 2024 18:28:54 +0200 Subject: [PATCH 067/206] remove waitForNavigation and OnyxTabNavigator from SearchPageBottomTab --- src/pages/Search/SearchPageBottomTab.tsx | 54 +++++++++--------------- 1 file changed, 19 insertions(+), 35 deletions(-) diff --git a/src/pages/Search/SearchPageBottomTab.tsx b/src/pages/Search/SearchPageBottomTab.tsx index a1400f740abd..68c6598088cb 100644 --- a/src/pages/Search/SearchPageBottomTab.tsx +++ b/src/pages/Search/SearchPageBottomTab.tsx @@ -34,54 +34,38 @@ function SearchPageBottomTab() { { title: 'All', icon: Expensicons.ExpensifyLogoNew, - action: singleExecution(waitForNavigate(() => Navigation.navigate(ROUTES.SEARCH.getRoute('all')))), + action: singleExecution(() => Navigation.navigate(ROUTES.SEARCH.getRoute('all'))), }, { title: 'Sent', icon: Expensicons.ExpensifyLogoNew, - action: singleExecution(waitForNavigate(() => Navigation.navigate(ROUTES.SEARCH.getRoute('sent')))), + action: singleExecution(() => Navigation.navigate(ROUTES.SEARCH.getRoute('sent'))), }, { title: 'Drafts', icon: Expensicons.ExpensifyLogoNew, - action: singleExecution(waitForNavigate(() => Navigation.navigate(ROUTES.SEARCH.getRoute('drafts')))), + action: singleExecution(() => Navigation.navigate(ROUTES.SEARCH.getRoute('drafts'))), }, ]; return ( <ScreenWrapper testID="testPage"> - {isSmallScreenWidth ? ( - <OnyxTabNavigator - id={CONST.TAB.NEW_CHAT_TAB_ID} - tabBar={TabSelector} - onTabSelected={(tab: string) => Navigation.navigate(ROUTES.SEARCH.getRoute(tab))} - > - <TopTab.Screen name={CONST.TAB_SEARCH.ALL}>{() => <SearchResults filter="all" />}</TopTab.Screen> - <TopTab.Screen name={CONST.TAB_SEARCH.SENT}>{() => <SearchResults filter="sent" />}</TopTab.Screen> - <TopTab.Screen name={CONST.TAB_SEARCH.DRAFTS}>{() => <SearchResults filter="drafts" />}</TopTab.Screen> - </OnyxTabNavigator> - ) : ( - <View style={[styles.pb4, styles.mh3, styles.mt3]}> - {/* - Ideally we should use MenuList component for MenuItems with singleExecution/Navigation actions. - In this case where user can click on workspace avatar or menu items, we need to have a check for `isExecuting`. So, we are directly mapping menuItems. - */} - {searchMenuItems.map((item) => ( - <MenuItem - key={item.title} - disabled={false} - interactive - title={item.title} - icon={item.icon} - onPress={item.action} - wrapperStyle={styles.sectionMenuItem} - focused={item.title.toLowerCase() === currentQuery} - hoverAndPressStyle={styles.hoveredComponentBG} - isPaneMenu - /> - ))} - </View> - )} + <View style={[styles.pb4, styles.mh3, styles.mt3]}> + {searchMenuItems.map((item) => ( + <MenuItem + key={item.title} + disabled={false} + interactive + title={item.title} + icon={item.icon} + onPress={item.action} + wrapperStyle={styles.sectionMenuItem} + focused={item.title.toLowerCase() === currentQuery} + hoverAndPressStyle={styles.hoveredComponentBG} + isPaneMenu + /> + ))} + </View> </ScreenWrapper> ); } From 2d78c11a8c6fe55f4fe6d8e8cfe1015adc259bd7 Mon Sep 17 00:00:00 2001 From: Adam Grzybowski <adam.grzybowski@swmansion.com> Date: Wed, 10 Apr 2024 18:29:34 +0200 Subject: [PATCH 068/206] remove waitForNavigation and OnyxTabNavigator from SearchPageBottomTab v2 --- src/pages/Search/SearchPageBottomTab.tsx | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/src/pages/Search/SearchPageBottomTab.tsx b/src/pages/Search/SearchPageBottomTab.tsx index 68c6598088cb..32ba8beac1ef 100644 --- a/src/pages/Search/SearchPageBottomTab.tsx +++ b/src/pages/Search/SearchPageBottomTab.tsx @@ -1,20 +1,16 @@ -import React, {useState} from 'react'; +import React from 'react'; import {View} from 'react-native'; import MenuItem from '@components/MenuItem'; import ScreenWrapper from '@components/ScreenWrapper'; -import TabSelector from '@components/TabSelector/TabSelector'; import useActiveRoute from '@hooks/useActiveRoute'; import useSingleExecution from '@hooks/useSingleExecution'; import useThemeStyles from '@hooks/useThemeStyles'; import useWaitForNavigation from '@hooks/useWaitForNavigation'; import useWindowDimensions from '@hooks/useWindowDimensions'; import Navigation from '@libs/Navigation/Navigation'; -import OnyxTabNavigator, {TopTab} from '@libs/Navigation/OnyxTabNavigator'; import * as Expensicons from '@src/components/Icon/Expensicons'; -import CONST from '@src/CONST'; import ROUTES from '@src/ROUTES'; import type IconAsset from '@src/types/utils/IconAsset'; -import SearchResults from './SearchResults'; type SearchMenuItem = { title: string; @@ -25,8 +21,6 @@ type SearchMenuItem = { function SearchPageBottomTab() { const styles = useThemeStyles(); const {singleExecution} = useSingleExecution(); - const {isSmallScreenWidth} = useWindowDimensions(); - const waitForNavigate = useWaitForNavigation(); const activeRoute = useActiveRoute(); const currentQuery = activeRoute?.params?.query; From b57d45603adfc9c0fef8acebd0bd609ff0f1c906 Mon Sep 17 00:00:00 2001 From: Adam Grzybowski <adam.grzybowski@swmansion.com> Date: Wed, 10 Apr 2024 18:36:12 +0200 Subject: [PATCH 069/206] add customBackHandler --- src/pages/Search/SearchPage.tsx | 5 ++- .../useCustomBackHandler/index.android.ts | 32 +++++++++++++++++++ .../Search/useCustomBackHandler/index.ts | 3 ++ 3 files changed, 39 insertions(+), 1 deletion(-) create mode 100644 src/pages/Search/useCustomBackHandler/index.android.ts create mode 100644 src/pages/Search/useCustomBackHandler/index.ts diff --git a/src/pages/Search/SearchPage.tsx b/src/pages/Search/SearchPage.tsx index 488ce1dbb28a..135ab66276a2 100644 --- a/src/pages/Search/SearchPage.tsx +++ b/src/pages/Search/SearchPage.tsx @@ -4,10 +4,13 @@ import ScreenWrapper from '@components/ScreenWrapper'; import type {CentralPaneNavigatorParamList} from '@libs/Navigation/types'; import type SCREENS from '@src/SCREENS'; import SearchResults from './SearchResults'; +import useCustomBackHandler from './useCustomBackHandler'; -type SearchPageProps = StackScreenProps<CentralPaneNavigatorParamList, typeof SCREENS.SEARCH>; +type SearchPageProps = StackScreenProps<CentralPaneNavigatorParamList, typeof SCREENS.SEARCH.CENTRAL_PANE>; function SearchPage({route}: SearchPageProps) { + useCustomBackHandler(); + return ( <ScreenWrapper testID="testPage"> <SearchResults filter={route.params.query} /> diff --git a/src/pages/Search/useCustomBackHandler/index.android.ts b/src/pages/Search/useCustomBackHandler/index.android.ts new file mode 100644 index 000000000000..cc9d5d3ca198 --- /dev/null +++ b/src/pages/Search/useCustomBackHandler/index.android.ts @@ -0,0 +1,32 @@ +import {StackActions, useFocusEffect} from '@react-navigation/native'; +import {useCallback} from 'react'; +import {BackHandler} from 'react-native'; +import getTopmostCentralPaneRoute from '@libs/Navigation/getTopmostCentralPaneRoute'; +import navigationRef from '@libs/Navigation/navigationRef'; +import type {RootStackParamList, State} from '@libs/Navigation/types'; +import NAVIGATORS from '@src/NAVIGATORS'; +import SCREENS from '@src/SCREENS'; + +function useCustomBackHandler() { + useFocusEffect( + useCallback(() => { + const onBackPress = () => { + const rootState = navigationRef.getRootState(); + + const bottomTabRoute = rootState.routes.find((route) => route.name === NAVIGATORS.BOTTOM_TAB_NAVIGATOR); + const centralPaneRouteAfterPop = getTopmostCentralPaneRoute({routes: [rootState.routes.at(-2)]} as State<RootStackParamList>); + + if (bottomTabRoute && bottomTabRoute.state && (!centralPaneRouteAfterPop || centralPaneRouteAfterPop.name !== SCREENS.SEARCH.CENTRAL_PANE)) { + navigationRef.dispatch({...StackActions.pop(), target: bottomTabRoute.state.key}); + } + return false; + }; + + const subscription = BackHandler.addEventListener('hardwareBackPress', onBackPress); + + return () => subscription.remove(); + }, []), + ); +} + +export default useCustomBackHandler; diff --git a/src/pages/Search/useCustomBackHandler/index.ts b/src/pages/Search/useCustomBackHandler/index.ts new file mode 100644 index 000000000000..be753de818a6 --- /dev/null +++ b/src/pages/Search/useCustomBackHandler/index.ts @@ -0,0 +1,3 @@ +function useCustomBackHandler() {} + +export default useCustomBackHandler; From 2fcae18f57c3dfb6f9e566bd29eac514d30e543b Mon Sep 17 00:00:00 2001 From: Adam Grzybowski <adam.grzybowski@swmansion.com> Date: Wed, 10 Apr 2024 18:38:41 +0200 Subject: [PATCH 070/206] remove unused imports --- src/pages/Search/SearchPageBottomTab.tsx | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/pages/Search/SearchPageBottomTab.tsx b/src/pages/Search/SearchPageBottomTab.tsx index 32ba8beac1ef..96b6aaf191fd 100644 --- a/src/pages/Search/SearchPageBottomTab.tsx +++ b/src/pages/Search/SearchPageBottomTab.tsx @@ -5,8 +5,6 @@ import ScreenWrapper from '@components/ScreenWrapper'; import useActiveRoute from '@hooks/useActiveRoute'; import useSingleExecution from '@hooks/useSingleExecution'; import useThemeStyles from '@hooks/useThemeStyles'; -import useWaitForNavigation from '@hooks/useWaitForNavigation'; -import useWindowDimensions from '@hooks/useWindowDimensions'; import Navigation from '@libs/Navigation/Navigation'; import * as Expensicons from '@src/components/Icon/Expensicons'; import ROUTES from '@src/ROUTES'; From b12e867e76e9b64b36afb990431a970f693b413e Mon Sep 17 00:00:00 2001 From: Alberto <alberto@expensify.com> Date: Thu, 11 Apr 2024 17:06:04 +0200 Subject: [PATCH 071/206] better props --- .../step/IOURequestStepScan/index.native.tsx | 24 ++++++++++++++++- .../request/step/IOURequestStepScan/index.tsx | 27 ++++++++++++------- 2 files changed, 41 insertions(+), 10 deletions(-) diff --git a/src/pages/iou/request/step/IOURequestStepScan/index.native.tsx b/src/pages/iou/request/step/IOURequestStepScan/index.native.tsx index f55e32f04aa0..1a665ea9e820 100644 --- a/src/pages/iou/request/step/IOURequestStepScan/index.native.tsx +++ b/src/pages/iou/request/step/IOURequestStepScan/index.native.tsx @@ -42,8 +42,30 @@ import type * as OnyxTypes from '@src/types/onyx'; import CameraPermission from './CameraPermission'; import NavigationAwareCamera from './NavigationAwareCamera'; import type IOURequestStepOnyxProps from './types'; +import transactionPropTypes from "@components/transactionPropTypes"; +import PropTypes from "prop-types"; -type IOURequestStepScanProps = IOURequestStepOnyxProps & +type IOURequestStepScanOnyxProps = { + /** The user */ + user: OnyxEntry<OnyxTypes.User>; + + /** The policy of the report */ + ...policyPropTypes; + + /** The transaction (or draft transaction) being changed */ + transaction: transactionPropTypes; + + /** Whether the confirmation step should be skipped */ + skipConfirmation: PropTypes.bool; + + /** Personal details of all users */ + personalDetails: personalDetailsPropType; + + /** The personal details of the current user */ + ...withCurrentUserPersonalDetailsPropTypes; +}; + +type IOURequestStepScanProps = IOURequestStepScanOnyxProps & WithWritableReportOrNotFoundProps<typeof SCREENS.MONEY_REQUEST.STEP_SCAN> & { /** Holds data related to Money Request view state, rather than the underlying Money Request data. */ transaction: OnyxEntry<OnyxTypes.Transaction>; diff --git a/src/pages/iou/request/step/IOURequestStepScan/index.tsx b/src/pages/iou/request/step/IOURequestStepScan/index.tsx index c0e1032bed3d..0148118872e5 100644 --- a/src/pages/iou/request/step/IOURequestStepScan/index.tsx +++ b/src/pages/iou/request/step/IOURequestStepScan/index.tsx @@ -49,18 +49,27 @@ import {isEmptyObject} from '@src/types/utils/EmptyObject'; import NavigationAwareCamera from './NavigationAwareCamera'; import type IOURequestStepOnyxProps from './types'; -type IOURequestStepScanProps = IOURequestStepOnyxProps & +type IOURequestStepScanOnyxProps = { + /** The policy of the report */ + ...policyPropTypes; + + /** The transaction (or draft transaction) being changed */ + transaction: transactionPropTypes; + + /** Whether the confirmation step should be skipped */ + skipConfirmation: PropTypes.bool; + + /** Personal details of all users */ + personalDetails: personalDetailsPropType; + + /** The personal details of the current user */ + ...withCurrentUserPersonalDetailsPropTypes; +}; + +type IOURequestStepScanProps = IOURequestStepScanOnyxProps & WithWritableReportOrNotFoundProps<typeof SCREENS.MONEY_REQUEST.STEP_SCAN> & { /** Holds data related to Money Request view state, rather than the underlying Money Request data. */ transaction: OnyxEntry<OnyxTypes.Transaction>; - /** Whether the confirmation step should be skipped */ - skipConfirmation: PropTypes.bool, - - /** Personal details of all users */ - personalDetails: personalDetailsPropType, - - /** The personal details of the current user */ - ...withCurrentUserPersonalDetailsPropTypes, }; function IOURequestStepScan({ From eca86e59a190626403382326a796ec3ed9007723 Mon Sep 17 00:00:00 2001 From: Alberto <alberto@expensify.com> Date: Thu, 11 Apr 2024 17:18:35 +0200 Subject: [PATCH 072/206] more props fixes --- .../step/IOURequestStepScan/index.native.tsx | 19 ++++++---------- .../request/step/IOURequestStepScan/index.tsx | 22 ++++++------------- 2 files changed, 14 insertions(+), 27 deletions(-) diff --git a/src/pages/iou/request/step/IOURequestStepScan/index.native.tsx b/src/pages/iou/request/step/IOURequestStepScan/index.native.tsx index 1a665ea9e820..d7086970c92a 100644 --- a/src/pages/iou/request/step/IOURequestStepScan/index.native.tsx +++ b/src/pages/iou/request/step/IOURequestStepScan/index.native.tsx @@ -19,7 +19,9 @@ import * as Expensicons from '@components/Icon/Expensicons'; import ImageSVG from '@components/ImageSVG'; import PressableWithFeedback from '@components/Pressable/PressableWithFeedback'; import Text from '@components/Text'; -import withCurrentUserPersonalDetails, {withCurrentUserPersonalDetailsDefaultProps, withCurrentUserPersonalDetailsPropTypes} from '@components/withCurrentUserPersonalDetails'; +import withCurrentUserPersonalDetails, { + WithCurrentUserPersonalDetailsProps, +} from '@components/withCurrentUserPersonalDetails'; import useLocalize from '@hooks/useLocalize'; import useTheme from '@hooks/useTheme'; import useThemeStyles from '@hooks/useThemeStyles'; @@ -42,30 +44,23 @@ import type * as OnyxTypes from '@src/types/onyx'; import CameraPermission from './CameraPermission'; import NavigationAwareCamera from './NavigationAwareCamera'; import type IOURequestStepOnyxProps from './types'; -import transactionPropTypes from "@components/transactionPropTypes"; import PropTypes from "prop-types"; +import {WithPolicyProps} from "@pages/workspace/withPolicy"; +import {PersonalDetailsList} from "@src/types/onyx"; type IOURequestStepScanOnyxProps = { /** The user */ user: OnyxEntry<OnyxTypes.User>; - /** The policy of the report */ - ...policyPropTypes; - - /** The transaction (or draft transaction) being changed */ - transaction: transactionPropTypes; - /** Whether the confirmation step should be skipped */ skipConfirmation: PropTypes.bool; /** Personal details of all users */ - personalDetails: personalDetailsPropType; + personalDetails: OnyxEntry<PersonalDetailsList>; - /** The personal details of the current user */ - ...withCurrentUserPersonalDetailsPropTypes; }; -type IOURequestStepScanProps = IOURequestStepScanOnyxProps & +type IOURequestStepScanProps = IOURequestStepScanOnyxProps & WithCurrentUserPersonalDetailsProps & WithPolicyProps & WithWritableReportOrNotFoundProps<typeof SCREENS.MONEY_REQUEST.STEP_SCAN> & { /** Holds data related to Money Request view state, rather than the underlying Money Request data. */ transaction: OnyxEntry<OnyxTypes.Transaction>; diff --git a/src/pages/iou/request/step/IOURequestStepScan/index.tsx b/src/pages/iou/request/step/IOURequestStepScan/index.tsx index 0148118872e5..18e448e976fd 100644 --- a/src/pages/iou/request/step/IOURequestStepScan/index.tsx +++ b/src/pages/iou/request/step/IOURequestStepScan/index.tsx @@ -18,8 +18,9 @@ import Icon from '@components/Icon'; import * as Expensicons from '@components/Icon/Expensicons'; import PressableWithFeedback from '@components/Pressable/PressableWithFeedback'; import Text from '@components/Text'; -import transactionPropTypes from '@components/transactionPropTypes'; -import withCurrentUserPersonalDetails, {withCurrentUserPersonalDetailsDefaultProps, withCurrentUserPersonalDetailsPropTypes} from '@components/withCurrentUserPersonalDetails'; +import withCurrentUserPersonalDetails, { + WithCurrentUserPersonalDetailsProps, +} from '@components/withCurrentUserPersonalDetails'; import useLocalize from '@hooks/useLocalize'; import useTabNavigatorFocus from '@hooks/useTabNavigatorFocus'; import useTheme from '@hooks/useTheme'; @@ -35,9 +36,7 @@ import StepScreenDragAndDropWrapper from '@pages/iou/request/step/StepScreenDrag import withFullTransactionOrNotFound from '@pages/iou/request/step/withFullTransactionOrNotFound'; import type {WithWritableReportOrNotFoundProps} from '@pages/iou/request/step/withWritableReportOrNotFound'; import withWritableReportOrNotFound from '@pages/iou/request/step/withWritableReportOrNotFound'; -import personalDetailsPropType from '@pages/personalDetailsPropType'; -import reportPropTypes from '@pages/reportPropTypes'; -import {policyPropTypes} from '@pages/workspace/withPolicy'; +import type {WithPolicyProps} from '@pages/workspace/withPolicy'; import * as IOU from '@userActions/IOU'; import CONST from '@src/CONST'; import ONYXKEYS from '@src/ONYXKEYS'; @@ -48,25 +47,18 @@ import type * as OnyxTypes from '@src/types/onyx'; import {isEmptyObject} from '@src/types/utils/EmptyObject'; import NavigationAwareCamera from './NavigationAwareCamera'; import type IOURequestStepOnyxProps from './types'; +import {PersonalDetailsList} from "@src/types/onyx"; type IOURequestStepScanOnyxProps = { - /** The policy of the report */ - ...policyPropTypes; - - /** The transaction (or draft transaction) being changed */ - transaction: transactionPropTypes; /** Whether the confirmation step should be skipped */ skipConfirmation: PropTypes.bool; /** Personal details of all users */ - personalDetails: personalDetailsPropType; - - /** The personal details of the current user */ - ...withCurrentUserPersonalDetailsPropTypes; + personalDetails: OnyxEntry<PersonalDetailsList>; }; -type IOURequestStepScanProps = IOURequestStepScanOnyxProps & +type IOURequestStepScanProps = IOURequestStepScanOnyxProps & WithCurrentUserPersonalDetailsProps & WithPolicyProps & WithWritableReportOrNotFoundProps<typeof SCREENS.MONEY_REQUEST.STEP_SCAN> & { /** Holds data related to Money Request view state, rather than the underlying Money Request data. */ transaction: OnyxEntry<OnyxTypes.Transaction>; From 5e7ee15a6b6d1decef58c27beb8ca57ae6e040c1 Mon Sep 17 00:00:00 2001 From: Alberto <alberto@expensify.com> Date: Thu, 11 Apr 2024 17:29:52 +0200 Subject: [PATCH 073/206] typescript --- .../iou/request/step/IOURequestStepScan/index.native.tsx | 9 --------- 1 file changed, 9 deletions(-) diff --git a/src/pages/iou/request/step/IOURequestStepScan/index.native.tsx b/src/pages/iou/request/step/IOURequestStepScan/index.native.tsx index d7086970c92a..5d2865bb1e64 100644 --- a/src/pages/iou/request/step/IOURequestStepScan/index.native.tsx +++ b/src/pages/iou/request/step/IOURequestStepScan/index.native.tsx @@ -64,15 +64,6 @@ type IOURequestStepScanProps = IOURequestStepScanOnyxProps & WithCurrentUserPers WithWritableReportOrNotFoundProps<typeof SCREENS.MONEY_REQUEST.STEP_SCAN> & { /** Holds data related to Money Request view state, rather than the underlying Money Request data. */ transaction: OnyxEntry<OnyxTypes.Transaction>; - - /** Whether the confirmation step should be skipped */ - skipConfirmation: PropTypes.bool, - - /** Personal details of all users */ - personalDetails: personalDetailsPropType, - - /** The personal details of the current user */ - ...withCurrentUserPersonalDetailsPropTypes, }; function IOURequestStepScan({ From 4d090e74b865dbb1abfebe2dbf445cd09d3db2bb Mon Sep 17 00:00:00 2001 From: Alberto <alberto@expensify.com> Date: Thu, 11 Apr 2024 17:30:29 +0200 Subject: [PATCH 074/206] prettier --- .../step/IOURequestStepScan/index.native.tsx | 17 ++++++++--------- .../request/step/IOURequestStepScan/index.tsx | 19 +++++++++---------- 2 files changed, 17 insertions(+), 19 deletions(-) diff --git a/src/pages/iou/request/step/IOURequestStepScan/index.native.tsx b/src/pages/iou/request/step/IOURequestStepScan/index.native.tsx index 5d2865bb1e64..0dcd071e606f 100644 --- a/src/pages/iou/request/step/IOURequestStepScan/index.native.tsx +++ b/src/pages/iou/request/step/IOURequestStepScan/index.native.tsx @@ -1,4 +1,5 @@ import {useFocusEffect} from '@react-navigation/core'; +import PropTypes from 'prop-types'; import React, {useCallback, useRef, useState} from 'react'; import {ActivityIndicator, Alert, AppState, InteractionManager, View} from 'react-native'; import {Gesture, GestureDetector} from 'react-native-gesture-handler'; @@ -19,9 +20,7 @@ import * as Expensicons from '@components/Icon/Expensicons'; import ImageSVG from '@components/ImageSVG'; import PressableWithFeedback from '@components/Pressable/PressableWithFeedback'; import Text from '@components/Text'; -import withCurrentUserPersonalDetails, { - WithCurrentUserPersonalDetailsProps, -} from '@components/withCurrentUserPersonalDetails'; +import withCurrentUserPersonalDetails, {WithCurrentUserPersonalDetailsProps} from '@components/withCurrentUserPersonalDetails'; import useLocalize from '@hooks/useLocalize'; import useTheme from '@hooks/useTheme'; import useThemeStyles from '@hooks/useThemeStyles'; @@ -35,18 +34,17 @@ import withFullTransactionOrNotFound from '@pages/iou/request/step/withFullTrans import type {WithWritableReportOrNotFoundProps} from '@pages/iou/request/step/withWritableReportOrNotFound'; import withWritableReportOrNotFound from '@pages/iou/request/step/withWritableReportOrNotFound'; import personalDetailsPropType from '@pages/personalDetailsPropType'; +import {WithPolicyProps} from '@pages/workspace/withPolicy'; import * as IOU from '@userActions/IOU'; import CONST from '@src/CONST'; import ONYXKEYS from '@src/ONYXKEYS'; import ROUTES from '@src/ROUTES'; import type SCREENS from '@src/SCREENS'; import type * as OnyxTypes from '@src/types/onyx'; +import {PersonalDetailsList} from '@src/types/onyx'; import CameraPermission from './CameraPermission'; import NavigationAwareCamera from './NavigationAwareCamera'; import type IOURequestStepOnyxProps from './types'; -import PropTypes from "prop-types"; -import {WithPolicyProps} from "@pages/workspace/withPolicy"; -import {PersonalDetailsList} from "@src/types/onyx"; type IOURequestStepScanOnyxProps = { /** The user */ @@ -57,10 +55,11 @@ type IOURequestStepScanOnyxProps = { /** Personal details of all users */ personalDetails: OnyxEntry<PersonalDetailsList>; - }; -type IOURequestStepScanProps = IOURequestStepScanOnyxProps & WithCurrentUserPersonalDetailsProps & WithPolicyProps & +type IOURequestStepScanProps = IOURequestStepScanOnyxProps & + WithCurrentUserPersonalDetailsProps & + WithPolicyProps & WithWritableReportOrNotFoundProps<typeof SCREENS.MONEY_REQUEST.STEP_SCAN> & { /** Holds data related to Money Request view state, rather than the underlying Money Request data. */ transaction: OnyxEntry<OnyxTypes.Transaction>; @@ -465,7 +464,7 @@ const IOURequestStepScanOnyxProps = withOnyx<IOURequestStepScanProps, IOURequest })(IOURequestStepScan); // eslint-disable-next-line rulesdir/no-negated-variables -const IOURequestStepScanWithCurrentUserPersonalDetails = withCurrentUserPersonalDetails(IOURequestStepScanOnyxProps) +const IOURequestStepScanWithCurrentUserPersonalDetails = withCurrentUserPersonalDetails(IOURequestStepScanOnyxProps); // eslint-disable-next-line rulesdir/no-negated-variables const IOURequestStepScanWithWritableReportOrNotFound = withWritableReportOrNotFound(IOURequestStepScanWithCurrentUserPersonalDetails); // eslint-disable-next-line rulesdir/no-negated-variables diff --git a/src/pages/iou/request/step/IOURequestStepScan/index.tsx b/src/pages/iou/request/step/IOURequestStepScan/index.tsx index 18e448e976fd..4cbd0a25eb23 100644 --- a/src/pages/iou/request/step/IOURequestStepScan/index.tsx +++ b/src/pages/iou/request/step/IOURequestStepScan/index.tsx @@ -2,9 +2,9 @@ import lodashGet from 'lodash/get'; import PropTypes from 'prop-types'; import React, {useCallback, useContext, useEffect, useReducer, useRef, useState} from 'react'; import {ActivityIndicator, PanResponder, PixelRatio, View} from 'react-native'; -import {withOnyx, OnyxEntry} from 'react-native-onyx'; -import _ from 'underscore'; +import {OnyxEntry, withOnyx} from 'react-native-onyx'; import type Webcam from 'react-webcam'; +import _ from 'underscore'; import Hand from '@assets/images/hand.svg'; import ReceiptUpload from '@assets/images/receipt-upload.svg'; import Shutter from '@assets/images/shutter.svg'; @@ -18,9 +18,7 @@ import Icon from '@components/Icon'; import * as Expensicons from '@components/Icon/Expensicons'; import PressableWithFeedback from '@components/Pressable/PressableWithFeedback'; import Text from '@components/Text'; -import withCurrentUserPersonalDetails, { - WithCurrentUserPersonalDetailsProps, -} from '@components/withCurrentUserPersonalDetails'; +import withCurrentUserPersonalDetails, {WithCurrentUserPersonalDetailsProps} from '@components/withCurrentUserPersonalDetails'; import useLocalize from '@hooks/useLocalize'; import useTabNavigatorFocus from '@hooks/useTabNavigatorFocus'; import useTheme from '@hooks/useTheme'; @@ -39,18 +37,17 @@ import withWritableReportOrNotFound from '@pages/iou/request/step/withWritableRe import type {WithPolicyProps} from '@pages/workspace/withPolicy'; import * as IOU from '@userActions/IOU'; import CONST from '@src/CONST'; -import ONYXKEYS from '@src/ONYXKEYS'; import type {TranslationPaths} from '@src/languages/types'; +import ONYXKEYS from '@src/ONYXKEYS'; import ROUTES from '@src/ROUTES'; import type SCREENS from '@src/SCREENS'; import type * as OnyxTypes from '@src/types/onyx'; +import {PersonalDetailsList} from '@src/types/onyx'; import {isEmptyObject} from '@src/types/utils/EmptyObject'; import NavigationAwareCamera from './NavigationAwareCamera'; import type IOURequestStepOnyxProps from './types'; -import {PersonalDetailsList} from "@src/types/onyx"; type IOURequestStepScanOnyxProps = { - /** Whether the confirmation step should be skipped */ skipConfirmation: PropTypes.bool; @@ -58,7 +55,9 @@ type IOURequestStepScanOnyxProps = { personalDetails: OnyxEntry<PersonalDetailsList>; }; -type IOURequestStepScanProps = IOURequestStepScanOnyxProps & WithCurrentUserPersonalDetailsProps & WithPolicyProps & +type IOURequestStepScanProps = IOURequestStepScanOnyxProps & + WithCurrentUserPersonalDetailsProps & + WithPolicyProps & WithWritableReportOrNotFoundProps<typeof SCREENS.MONEY_REQUEST.STEP_SCAN> & { /** Holds data related to Money Request view state, rather than the underlying Money Request data. */ transaction: OnyxEntry<OnyxTypes.Transaction>; @@ -579,7 +578,7 @@ const IOURequestStepScanOnyxProps = withOnyx<IOURequestStepScanProps, IOURequest })(IOURequestStepScan); // eslint-disable-next-line rulesdir/no-negated-variables -const IOURequestStepScanWithCurrentUserPersonalDetails = withCurrentUserPersonalDetails(IOURequestStepScanOnyxProps) +const IOURequestStepScanWithCurrentUserPersonalDetails = withCurrentUserPersonalDetails(IOURequestStepScanOnyxProps); // eslint-disable-next-line rulesdir/no-negated-variables const IOURequestStepScanWithWritableReportOrNotFound = withWritableReportOrNotFound(IOURequestStepScanWithCurrentUserPersonalDetails); // eslint-disable-next-line rulesdir/no-negated-variables From af7c219ccdcb8010fd5dbf44ddcb3e7353ab3bdd Mon Sep 17 00:00:00 2001 From: Alberto <alberto@expensify.com> Date: Thu, 11 Apr 2024 17:39:04 +0200 Subject: [PATCH 075/206] more typescript --- .../iou/request/step/IOURequestStepScan/index.native.tsx | 6 +++--- src/pages/iou/request/step/IOURequestStepScan/index.tsx | 7 +++---- 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/src/pages/iou/request/step/IOURequestStepScan/index.native.tsx b/src/pages/iou/request/step/IOURequestStepScan/index.native.tsx index 0dcd071e606f..0b10dafaf34b 100644 --- a/src/pages/iou/request/step/IOURequestStepScan/index.native.tsx +++ b/src/pages/iou/request/step/IOURequestStepScan/index.native.tsx @@ -94,7 +94,7 @@ function IOURequestStepScan({ const shouldSkipConfirmation = skipConfirmation && !ReportUtils.isArchivedRoom(report) && - !(ReportUtils.isPolicyExpenseChat(reportID) && (lodashGet(policy, 'requiresCategory', false) || lodashGet(policy, 'requiresTag', false))); + !(ReportUtils.isPolicyExpenseChat(reportID) && (policy?.requiresCategory ?? false || policy?.requiresTag ?? false)); const {translate} = useLocalize(); @@ -220,7 +220,7 @@ function IOURequestStepScan({ // be added to the transaction (taken from the chat report participants) and then the person is taken to the confirmation step. const selectedParticipants = IOU.setMoneyRequestParticipantsFromReport(transactionID, report); const participants = _.map(selectedParticipants, (participant) => { - const participantAccountID = lodashGet(participant, 'accountID', 0); + const participantAccountID = participant?.accountID ?? 0; return participantAccountID ? OptionsListUtils.getParticipantsOption(participant, personalDetails) : OptionsListUtils.getReportOption(participant); }); @@ -454,7 +454,7 @@ const IOURequestStepScanOnyxProps = withOnyx<IOURequestStepScanProps, IOURequest }, skipConfirmation: { key: ({route}) => { - const transactionID = lodashGet(route, 'params.transactionID', 0); + const transactionID = route.params.transactionID ?? 0; return `${ONYXKEYS.COLLECTION.SKIP_CONFIRMATION}${transactionID}`; }, }, diff --git a/src/pages/iou/request/step/IOURequestStepScan/index.tsx b/src/pages/iou/request/step/IOURequestStepScan/index.tsx index 4cbd0a25eb23..1b29cc3146ca 100644 --- a/src/pages/iou/request/step/IOURequestStepScan/index.tsx +++ b/src/pages/iou/request/step/IOURequestStepScan/index.tsx @@ -1,4 +1,3 @@ -import lodashGet from 'lodash/get'; import PropTypes from 'prop-types'; import React, {useCallback, useContext, useEffect, useReducer, useRef, useState} from 'react'; import {ActivityIndicator, PanResponder, PixelRatio, View} from 'react-native'; @@ -105,7 +104,7 @@ function IOURequestStepScan({ const shouldSkipConfirmation = skipConfirmation && !ReportUtils.isArchivedRoom(report) && - !(ReportUtils.isPolicyExpenseChat(reportID) && (lodashGet(policy, 'requiresCategory', false) || lodashGet(policy, 'requiresTag', false))); + !(ReportUtils.isPolicyExpenseChat(reportID) && (policy?.requiresCategory ?? false || policy?.requiresTag ?? false)); /** * On phones that have ultra-wide lens, react-webcam uses ultra-wide by default. @@ -247,7 +246,7 @@ function IOURequestStepScan({ // be added to the transaction (taken from the chat report participants) and then the person is taken to the confirmation step. const selectedParticipants = IOU.setMoneyRequestParticipantsFromReport(transactionID, report); const participants = _.map(selectedParticipants, (participant) => { - const participantAccountID = lodashGet(participant, 'accountID', 0); + const participantAccountID = participant?.accountID ?? 0; return participantAccountID ? OptionsListUtils.getParticipantsOption(participant, personalDetails) : OptionsListUtils.getReportOption(participant); }); @@ -571,7 +570,7 @@ const IOURequestStepScanOnyxProps = withOnyx<IOURequestStepScanProps, IOURequest }, skipConfirmation: { key: ({route}) => { - const transactionID = lodashGet(route, 'params.transactionID', 0); + const transactionID = route.params.transactionID ?? 0; return `${ONYXKEYS.COLLECTION.SKIP_CONFIRMATION}${transactionID}`; }, }, From 0d451ccad168fc8d31a4996eb31a97124725111c Mon Sep 17 00:00:00 2001 From: Alberto <alberto@expensify.com> Date: Thu, 11 Apr 2024 17:45:21 +0200 Subject: [PATCH 076/206] types and bools --- .../iou/request/step/IOURequestStepScan/index.native.tsx | 7 +++---- src/pages/iou/request/step/IOURequestStepScan/index.tsx | 6 +++--- 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/src/pages/iou/request/step/IOURequestStepScan/index.native.tsx b/src/pages/iou/request/step/IOURequestStepScan/index.native.tsx index 0b10dafaf34b..c75068d41da9 100644 --- a/src/pages/iou/request/step/IOURequestStepScan/index.native.tsx +++ b/src/pages/iou/request/step/IOURequestStepScan/index.native.tsx @@ -33,7 +33,6 @@ import StepScreenWrapper from '@pages/iou/request/step/StepScreenWrapper'; import withFullTransactionOrNotFound from '@pages/iou/request/step/withFullTransactionOrNotFound'; import type {WithWritableReportOrNotFoundProps} from '@pages/iou/request/step/withWritableReportOrNotFound'; import withWritableReportOrNotFound from '@pages/iou/request/step/withWritableReportOrNotFound'; -import personalDetailsPropType from '@pages/personalDetailsPropType'; import {WithPolicyProps} from '@pages/workspace/withPolicy'; import * as IOU from '@userActions/IOU'; import CONST from '@src/CONST'; @@ -51,7 +50,7 @@ type IOURequestStepScanOnyxProps = { user: OnyxEntry<OnyxTypes.User>; /** Whether the confirmation step should be skipped */ - skipConfirmation: PropTypes.bool; + skipConfirmation: boolean; /** Personal details of all users */ personalDetails: OnyxEntry<PersonalDetailsList>; @@ -94,7 +93,7 @@ function IOURequestStepScan({ const shouldSkipConfirmation = skipConfirmation && !ReportUtils.isArchivedRoom(report) && - !(ReportUtils.isPolicyExpenseChat(reportID) && (policy?.requiresCategory ?? false || policy?.requiresTag ?? false)); + !(ReportUtils.isPolicyExpenseChat(reportID) && ((policy?.requiresCategory ?? false) || (policy?.requiresTag ?? false))); const {translate} = useLocalize(); @@ -204,7 +203,7 @@ function IOURequestStepScan({ }; const navigateToConfirmationStep = useCallback( - (file, source) => { + (file: FileObject, source: string) => { if (backTo) { Navigation.goBack(backTo); return; diff --git a/src/pages/iou/request/step/IOURequestStepScan/index.tsx b/src/pages/iou/request/step/IOURequestStepScan/index.tsx index 1b29cc3146ca..1c329fb153d1 100644 --- a/src/pages/iou/request/step/IOURequestStepScan/index.tsx +++ b/src/pages/iou/request/step/IOURequestStepScan/index.tsx @@ -48,7 +48,7 @@ import type IOURequestStepOnyxProps from './types'; type IOURequestStepScanOnyxProps = { /** Whether the confirmation step should be skipped */ - skipConfirmation: PropTypes.bool; + skipConfirmation: boolean; /** Personal details of all users */ personalDetails: OnyxEntry<PersonalDetailsList>; @@ -104,7 +104,7 @@ function IOURequestStepScan({ const shouldSkipConfirmation = skipConfirmation && !ReportUtils.isArchivedRoom(report) && - !(ReportUtils.isPolicyExpenseChat(reportID) && (policy?.requiresCategory ?? false || policy?.requiresTag ?? false)); + !(ReportUtils.isPolicyExpenseChat(reportID) && ((policy?.requiresCategory ?? false) || (policy?.requiresTag ?? false))); /** * On phones that have ultra-wide lens, react-webcam uses ultra-wide by default. @@ -230,7 +230,7 @@ function IOURequestStepScan({ }; const navigateToConfirmationStep = useCallback( - (file, source) => { + (file: FileObject, source: string) => { if (backTo) { Navigation.goBack(backTo); return; From 0c55b21abc9ed3fd6b9fe6dd62681f22fb138c15 Mon Sep 17 00:00:00 2001 From: Alberto <alberto@expensify.com> Date: Thu, 11 Apr 2024 17:55:06 +0200 Subject: [PATCH 077/206] still fighting Typescript --- .../step/IOURequestStepScan/index.native.tsx | 13 ++++++------- .../iou/request/step/IOURequestStepScan/index.tsx | 12 ++++++------ 2 files changed, 12 insertions(+), 13 deletions(-) diff --git a/src/pages/iou/request/step/IOURequestStepScan/index.native.tsx b/src/pages/iou/request/step/IOURequestStepScan/index.native.tsx index c75068d41da9..23ded0b178e2 100644 --- a/src/pages/iou/request/step/IOURequestStepScan/index.native.tsx +++ b/src/pages/iou/request/step/IOURequestStepScan/index.native.tsx @@ -1,5 +1,4 @@ import {useFocusEffect} from '@react-navigation/core'; -import PropTypes from 'prop-types'; import React, {useCallback, useRef, useState} from 'react'; import {ActivityIndicator, Alert, AppState, InteractionManager, View} from 'react-native'; import {Gesture, GestureDetector} from 'react-native-gesture-handler'; @@ -40,7 +39,7 @@ import ONYXKEYS from '@src/ONYXKEYS'; import ROUTES from '@src/ROUTES'; import type SCREENS from '@src/SCREENS'; import type * as OnyxTypes from '@src/types/onyx'; -import {PersonalDetailsList} from '@src/types/onyx'; +import {PersonalDetailsList, Report} from '@src/types/onyx'; import CameraPermission from './CameraPermission'; import NavigationAwareCamera from './NavigationAwareCamera'; import type IOURequestStepOnyxProps from './types'; @@ -49,9 +48,6 @@ type IOURequestStepScanOnyxProps = { /** The user */ user: OnyxEntry<OnyxTypes.User>; - /** Whether the confirmation step should be skipped */ - skipConfirmation: boolean; - /** Personal details of all users */ personalDetails: OnyxEntry<PersonalDetailsList>; }; @@ -62,6 +58,9 @@ type IOURequestStepScanProps = IOURequestStepScanOnyxProps & WithWritableReportOrNotFoundProps<typeof SCREENS.MONEY_REQUEST.STEP_SCAN> & { /** Holds data related to Money Request view state, rather than the underlying Money Request data. */ transaction: OnyxEntry<OnyxTypes.Transaction>; + + /** Whether the confirmation step should be skipped */ + skipConfirmation: boolean; }; function IOURequestStepScan({ @@ -234,8 +233,8 @@ function IOURequestStepScan({ IOU.requestMoney( report, 0, - transaction.currency, - transaction.created, + transaction?.currency ?? 'USD', + transaction?.created ?? '', '', currentUserPersonalDetails.login, currentUserPersonalDetails.accountID, diff --git a/src/pages/iou/request/step/IOURequestStepScan/index.tsx b/src/pages/iou/request/step/IOURequestStepScan/index.tsx index 1c329fb153d1..48b943750a58 100644 --- a/src/pages/iou/request/step/IOURequestStepScan/index.tsx +++ b/src/pages/iou/request/step/IOURequestStepScan/index.tsx @@ -41,15 +41,12 @@ import ONYXKEYS from '@src/ONYXKEYS'; import ROUTES from '@src/ROUTES'; import type SCREENS from '@src/SCREENS'; import type * as OnyxTypes from '@src/types/onyx'; -import {PersonalDetailsList} from '@src/types/onyx'; +import {PersonalDetailsList, Report} from '@src/types/onyx'; import {isEmptyObject} from '@src/types/utils/EmptyObject'; import NavigationAwareCamera from './NavigationAwareCamera'; import type IOURequestStepOnyxProps from './types'; type IOURequestStepScanOnyxProps = { - /** Whether the confirmation step should be skipped */ - skipConfirmation: boolean; - /** Personal details of all users */ personalDetails: OnyxEntry<PersonalDetailsList>; }; @@ -60,6 +57,9 @@ type IOURequestStepScanProps = IOURequestStepScanOnyxProps & WithWritableReportOrNotFoundProps<typeof SCREENS.MONEY_REQUEST.STEP_SCAN> & { /** Holds data related to Money Request view state, rather than the underlying Money Request data. */ transaction: OnyxEntry<OnyxTypes.Transaction>; + + /** Whether the confirmation step should be skipped */ + skipConfirmation: boolean; }; function IOURequestStepScan({ @@ -261,8 +261,8 @@ function IOURequestStepScan({ IOU.requestMoney( report, 0, - transaction.currency, - transaction.created, + transaction?.currency ?? 'USD', + transaction?.created ?? '', '', currentUserPersonalDetails.login, currentUserPersonalDetails.accountID, From 0cb3f1ff4c29b4b8fceeb81c6337323b60089daa Mon Sep 17 00:00:00 2001 From: Alberto <alberto@expensify.com> Date: Thu, 11 Apr 2024 18:00:20 +0200 Subject: [PATCH 078/206] add receipt type --- .../iou/request/step/IOURequestStepScan/index.native.tsx | 5 +++-- src/pages/iou/request/step/IOURequestStepScan/index.tsx | 3 ++- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/pages/iou/request/step/IOURequestStepScan/index.native.tsx b/src/pages/iou/request/step/IOURequestStepScan/index.native.tsx index 23ded0b178e2..bdcf768c146d 100644 --- a/src/pages/iou/request/step/IOURequestStepScan/index.native.tsx +++ b/src/pages/iou/request/step/IOURequestStepScan/index.native.tsx @@ -43,6 +43,7 @@ import {PersonalDetailsList, Report} from '@src/types/onyx'; import CameraPermission from './CameraPermission'; import NavigationAwareCamera from './NavigationAwareCamera'; import type IOURequestStepOnyxProps from './types'; +import {Receipt} from "@src/types/onyx/Transaction"; type IOURequestStepScanOnyxProps = { /** The user */ @@ -223,7 +224,7 @@ function IOURequestStepScan({ }); if (shouldSkipConfirmation) { - const receipt = file; + const receipt: Receipt = file; receipt.source = source; receipt.state = CONST.IOU.RECEIPT_STATE.SCANREADY; if (iouType === CONST.IOU.TYPE.SPLIT) { @@ -275,7 +276,7 @@ function IOURequestStepScan({ return; } - navigateToConfirmationStep(file, file.uri); + navigateToConfirmationStep(file, file.uri ?? ''); }; const capturePhoto = useCallback(() => { diff --git a/src/pages/iou/request/step/IOURequestStepScan/index.tsx b/src/pages/iou/request/step/IOURequestStepScan/index.tsx index 48b943750a58..49bd3c2ce691 100644 --- a/src/pages/iou/request/step/IOURequestStepScan/index.tsx +++ b/src/pages/iou/request/step/IOURequestStepScan/index.tsx @@ -45,6 +45,7 @@ import {PersonalDetailsList, Report} from '@src/types/onyx'; import {isEmptyObject} from '@src/types/utils/EmptyObject'; import NavigationAwareCamera from './NavigationAwareCamera'; import type IOURequestStepOnyxProps from './types'; +import {Receipt} from "@src/types/onyx/Transaction"; type IOURequestStepScanOnyxProps = { /** Personal details of all users */ @@ -251,7 +252,7 @@ function IOURequestStepScan({ }); if (shouldSkipConfirmation) { - const receipt = file; + const receipt: Receipt = file; receipt.source = source; receipt.state = CONST.IOU.RECEIPT_STATE.SCANREADY; if (iouType === CONST.IOU.TYPE.SPLIT) { From 699e93b302e45c8e55da87874aa44d9d10def040 Mon Sep 17 00:00:00 2001 From: Alberto <alberto@expensify.com> Date: Thu, 11 Apr 2024 18:08:43 +0200 Subject: [PATCH 079/206] fix split flow --- .../step/IOURequestStepScan/index.native.tsx | 13 ++++++++++++- .../iou/request/step/IOURequestStepScan/index.tsx | 13 ++++++++++++- 2 files changed, 24 insertions(+), 2 deletions(-) diff --git a/src/pages/iou/request/step/IOURequestStepScan/index.native.tsx b/src/pages/iou/request/step/IOURequestStepScan/index.native.tsx index bdcf768c146d..291c66f0f93c 100644 --- a/src/pages/iou/request/step/IOURequestStepScan/index.native.tsx +++ b/src/pages/iou/request/step/IOURequestStepScan/index.native.tsx @@ -228,7 +228,18 @@ function IOURequestStepScan({ receipt.source = source; receipt.state = CONST.IOU.RECEIPT_STATE.SCANREADY; if (iouType === CONST.IOU.TYPE.SPLIT) { - IOU.startSplitBill(participants, currentUserPersonalDetails.login, currentUserPersonalDetails.accountID, '', '', '', receipt, reportID); + IOU.startSplitBill({ + participants: participants, + currentUserLogin: currentUserPersonalDetails?.login ? '', + currentUserAccountID: currentUserPersonalDetails?.accountID ? '', + comment: '', + receipt: receipt, + existingSplitChatReportID: reportID ?? 0, + billable: false, + category: '', + tag: '', + currency: transaction?.currency ?? 'USD', + }); return; } IOU.requestMoney( diff --git a/src/pages/iou/request/step/IOURequestStepScan/index.tsx b/src/pages/iou/request/step/IOURequestStepScan/index.tsx index 49bd3c2ce691..71591e61e835 100644 --- a/src/pages/iou/request/step/IOURequestStepScan/index.tsx +++ b/src/pages/iou/request/step/IOURequestStepScan/index.tsx @@ -256,7 +256,18 @@ function IOURequestStepScan({ receipt.source = source; receipt.state = CONST.IOU.RECEIPT_STATE.SCANREADY; if (iouType === CONST.IOU.TYPE.SPLIT) { - IOU.startSplitBill(participants, currentUserPersonalDetails.login, currentUserPersonalDetails.accountID, '', '', '', receipt, reportID); + IOU.startSplitBill({ + participants: participants, + currentUserLogin: currentUserPersonalDetails?.login ? '', + currentUserAccountID: currentUserPersonalDetails?.accountID ? '', + comment: '', + receipt: receipt, + existingSplitChatReportID: reportID ?? 0, + billable: false, + category: '', + tag: '', + currency: transaction?.currency ?? 'USD', + }); return; } IOU.requestMoney( From 2df54af633ddef674317b161f04e855bde72b907 Mon Sep 17 00:00:00 2001 From: Alberto <alberto@expensify.com> Date: Thu, 11 Apr 2024 18:14:22 +0200 Subject: [PATCH 080/206] typo --- .../iou/request/step/IOURequestStepScan/index.native.tsx | 8 ++++---- src/pages/iou/request/step/IOURequestStepScan/index.tsx | 8 ++++---- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/pages/iou/request/step/IOURequestStepScan/index.native.tsx b/src/pages/iou/request/step/IOURequestStepScan/index.native.tsx index 291c66f0f93c..180f8375ff86 100644 --- a/src/pages/iou/request/step/IOURequestStepScan/index.native.tsx +++ b/src/pages/iou/request/step/IOURequestStepScan/index.native.tsx @@ -229,11 +229,11 @@ function IOURequestStepScan({ receipt.state = CONST.IOU.RECEIPT_STATE.SCANREADY; if (iouType === CONST.IOU.TYPE.SPLIT) { IOU.startSplitBill({ - participants: participants, - currentUserLogin: currentUserPersonalDetails?.login ? '', - currentUserAccountID: currentUserPersonalDetails?.accountID ? '', + participants, + currentUserLogin: currentUserPersonalDetails?.login ?? '', + currentUserAccountID: currentUserPersonalDetails?.accountID ?? 0, comment: '', - receipt: receipt, + receipt, existingSplitChatReportID: reportID ?? 0, billable: false, category: '', diff --git a/src/pages/iou/request/step/IOURequestStepScan/index.tsx b/src/pages/iou/request/step/IOURequestStepScan/index.tsx index 71591e61e835..258dea35416e 100644 --- a/src/pages/iou/request/step/IOURequestStepScan/index.tsx +++ b/src/pages/iou/request/step/IOURequestStepScan/index.tsx @@ -257,11 +257,11 @@ function IOURequestStepScan({ receipt.state = CONST.IOU.RECEIPT_STATE.SCANREADY; if (iouType === CONST.IOU.TYPE.SPLIT) { IOU.startSplitBill({ - participants: participants, - currentUserLogin: currentUserPersonalDetails?.login ? '', - currentUserAccountID: currentUserPersonalDetails?.accountID ? '', + participants, + currentUserLogin: currentUserPersonalDetails?.login ?? '', + currentUserAccountID: currentUserPersonalDetails?.accountID ?? 0, comment: '', - receipt: receipt, + receipt, existingSplitChatReportID: reportID ?? 0, billable: false, category: '', From 06b604f90cd62090f3e2c49571494c73620adf8b Mon Sep 17 00:00:00 2001 From: Alberto <alberto@expensify.com> Date: Thu, 11 Apr 2024 18:21:14 +0200 Subject: [PATCH 081/206] add policy to props --- .../request/step/IOURequestStepScan/index.native.tsx | 9 +++++---- .../iou/request/step/IOURequestStepScan/index.tsx | 10 +++++----- 2 files changed, 10 insertions(+), 9 deletions(-) diff --git a/src/pages/iou/request/step/IOURequestStepScan/index.native.tsx b/src/pages/iou/request/step/IOURequestStepScan/index.native.tsx index 180f8375ff86..4cc0b8695b43 100644 --- a/src/pages/iou/request/step/IOURequestStepScan/index.native.tsx +++ b/src/pages/iou/request/step/IOURequestStepScan/index.native.tsx @@ -32,14 +32,13 @@ import StepScreenWrapper from '@pages/iou/request/step/StepScreenWrapper'; import withFullTransactionOrNotFound from '@pages/iou/request/step/withFullTransactionOrNotFound'; import type {WithWritableReportOrNotFoundProps} from '@pages/iou/request/step/withWritableReportOrNotFound'; import withWritableReportOrNotFound from '@pages/iou/request/step/withWritableReportOrNotFound'; -import {WithPolicyProps} from '@pages/workspace/withPolicy'; import * as IOU from '@userActions/IOU'; import CONST from '@src/CONST'; import ONYXKEYS from '@src/ONYXKEYS'; import ROUTES from '@src/ROUTES'; import type SCREENS from '@src/SCREENS'; import type * as OnyxTypes from '@src/types/onyx'; -import {PersonalDetailsList, Report} from '@src/types/onyx'; +import {PersonalDetailsList, Policy, Report} from '@src/types/onyx'; import CameraPermission from './CameraPermission'; import NavigationAwareCamera from './NavigationAwareCamera'; import type IOURequestStepOnyxProps from './types'; @@ -51,11 +50,13 @@ type IOURequestStepScanOnyxProps = { /** Personal details of all users */ personalDetails: OnyxEntry<PersonalDetailsList>; + + /** The policy which the user has access to and which the report is tied to */ + policy: OnyxEntry<Policy>; }; type IOURequestStepScanProps = IOURequestStepScanOnyxProps & WithCurrentUserPersonalDetailsProps & - WithPolicyProps & WithWritableReportOrNotFoundProps<typeof SCREENS.MONEY_REQUEST.STEP_SCAN> & { /** Holds data related to Money Request view state, rather than the underlying Money Request data. */ transaction: OnyxEntry<OnyxTypes.Transaction>; @@ -455,7 +456,7 @@ function IOURequestStepScan({ IOURequestStepScan.displayName = 'IOURequestStepScan'; -const IOURequestStepScanOnyxProps = withOnyx<IOURequestStepScanProps, IOURequestStepOnyxProps>({ +const IOURequestStepScanOnyxProps = withOnyx<IOURequestStepScanProps, IOURequestStepScanOnyxProps>({ policy: { key: ({report}) => `${ONYXKEYS.COLLECTION.POLICY}${report ? report.policyID : '0'}`, }, diff --git a/src/pages/iou/request/step/IOURequestStepScan/index.tsx b/src/pages/iou/request/step/IOURequestStepScan/index.tsx index 258dea35416e..ed2b94ec2912 100644 --- a/src/pages/iou/request/step/IOURequestStepScan/index.tsx +++ b/src/pages/iou/request/step/IOURequestStepScan/index.tsx @@ -1,4 +1,3 @@ -import PropTypes from 'prop-types'; import React, {useCallback, useContext, useEffect, useReducer, useRef, useState} from 'react'; import {ActivityIndicator, PanResponder, PixelRatio, View} from 'react-native'; import {OnyxEntry, withOnyx} from 'react-native-onyx'; @@ -33,7 +32,6 @@ import StepScreenDragAndDropWrapper from '@pages/iou/request/step/StepScreenDrag import withFullTransactionOrNotFound from '@pages/iou/request/step/withFullTransactionOrNotFound'; import type {WithWritableReportOrNotFoundProps} from '@pages/iou/request/step/withWritableReportOrNotFound'; import withWritableReportOrNotFound from '@pages/iou/request/step/withWritableReportOrNotFound'; -import type {WithPolicyProps} from '@pages/workspace/withPolicy'; import * as IOU from '@userActions/IOU'; import CONST from '@src/CONST'; import type {TranslationPaths} from '@src/languages/types'; @@ -41,7 +39,7 @@ import ONYXKEYS from '@src/ONYXKEYS'; import ROUTES from '@src/ROUTES'; import type SCREENS from '@src/SCREENS'; import type * as OnyxTypes from '@src/types/onyx'; -import {PersonalDetailsList, Report} from '@src/types/onyx'; +import {PersonalDetailsList, Policy, Report} from '@src/types/onyx'; import {isEmptyObject} from '@src/types/utils/EmptyObject'; import NavigationAwareCamera from './NavigationAwareCamera'; import type IOURequestStepOnyxProps from './types'; @@ -50,11 +48,13 @@ import {Receipt} from "@src/types/onyx/Transaction"; type IOURequestStepScanOnyxProps = { /** Personal details of all users */ personalDetails: OnyxEntry<PersonalDetailsList>; + + /** The policy which the user has access to and which the report is tied to */ + policy: OnyxEntry<Policy>; }; type IOURequestStepScanProps = IOURequestStepScanOnyxProps & WithCurrentUserPersonalDetailsProps & - WithPolicyProps & WithWritableReportOrNotFoundProps<typeof SCREENS.MONEY_REQUEST.STEP_SCAN> & { /** Holds data related to Money Request view state, rather than the underlying Money Request data. */ transaction: OnyxEntry<OnyxTypes.Transaction>; @@ -573,7 +573,7 @@ function IOURequestStepScan({ IOURequestStepScan.displayName = 'IOURequestStepScan'; -const IOURequestStepScanOnyxProps = withOnyx<IOURequestStepScanProps, IOURequestStepOnyxProps>({ +const IOURequestStepScanOnyxProps = withOnyx<IOURequestStepScanProps, IOURequestStepScanOnyxProps>({ policy: { key: ({report}) => `${ONYXKEYS.COLLECTION.POLICY}${report ? report.policyID : '0'}`, }, From 10d7e3e0c964bf47011e01b7e656b4103616b72b Mon Sep 17 00:00:00 2001 From: Alberto <alberto@expensify.com> Date: Thu, 11 Apr 2024 18:23:59 +0200 Subject: [PATCH 082/206] more onyx props fixes --- .../iou/request/step/IOURequestStepScan/index.native.tsx | 7 +++---- src/pages/iou/request/step/IOURequestStepScan/index.tsx | 7 +++---- 2 files changed, 6 insertions(+), 8 deletions(-) diff --git a/src/pages/iou/request/step/IOURequestStepScan/index.native.tsx b/src/pages/iou/request/step/IOURequestStepScan/index.native.tsx index 4cc0b8695b43..59c271c9d363 100644 --- a/src/pages/iou/request/step/IOURequestStepScan/index.native.tsx +++ b/src/pages/iou/request/step/IOURequestStepScan/index.native.tsx @@ -41,7 +41,6 @@ import type * as OnyxTypes from '@src/types/onyx'; import {PersonalDetailsList, Policy, Report} from '@src/types/onyx'; import CameraPermission from './CameraPermission'; import NavigationAwareCamera from './NavigationAwareCamera'; -import type IOURequestStepOnyxProps from './types'; import {Receipt} from "@src/types/onyx/Transaction"; type IOURequestStepScanOnyxProps = { @@ -53,6 +52,9 @@ type IOURequestStepScanOnyxProps = { /** The policy which the user has access to and which the report is tied to */ policy: OnyxEntry<Policy>; + + /** Whether the confirmation step should be skipped */ + skipConfirmation: OnyxEntry<boolean>; }; type IOURequestStepScanProps = IOURequestStepScanOnyxProps & @@ -60,9 +62,6 @@ type IOURequestStepScanProps = IOURequestStepScanOnyxProps & WithWritableReportOrNotFoundProps<typeof SCREENS.MONEY_REQUEST.STEP_SCAN> & { /** Holds data related to Money Request view state, rather than the underlying Money Request data. */ transaction: OnyxEntry<OnyxTypes.Transaction>; - - /** Whether the confirmation step should be skipped */ - skipConfirmation: boolean; }; function IOURequestStepScan({ diff --git a/src/pages/iou/request/step/IOURequestStepScan/index.tsx b/src/pages/iou/request/step/IOURequestStepScan/index.tsx index ed2b94ec2912..10daf079fe05 100644 --- a/src/pages/iou/request/step/IOURequestStepScan/index.tsx +++ b/src/pages/iou/request/step/IOURequestStepScan/index.tsx @@ -42,7 +42,6 @@ import type * as OnyxTypes from '@src/types/onyx'; import {PersonalDetailsList, Policy, Report} from '@src/types/onyx'; import {isEmptyObject} from '@src/types/utils/EmptyObject'; import NavigationAwareCamera from './NavigationAwareCamera'; -import type IOURequestStepOnyxProps from './types'; import {Receipt} from "@src/types/onyx/Transaction"; type IOURequestStepScanOnyxProps = { @@ -51,6 +50,9 @@ type IOURequestStepScanOnyxProps = { /** The policy which the user has access to and which the report is tied to */ policy: OnyxEntry<Policy>; + + /** Whether the confirmation step should be skipped */ + skipConfirmation: OnyxEntry<boolean>; }; type IOURequestStepScanProps = IOURequestStepScanOnyxProps & @@ -58,9 +60,6 @@ type IOURequestStepScanProps = IOURequestStepScanOnyxProps & WithWritableReportOrNotFoundProps<typeof SCREENS.MONEY_REQUEST.STEP_SCAN> & { /** Holds data related to Money Request view state, rather than the underlying Money Request data. */ transaction: OnyxEntry<OnyxTypes.Transaction>; - - /** Whether the confirmation step should be skipped */ - skipConfirmation: boolean; }; function IOURequestStepScan({ From 76f0050fd49809b09f3e8bc2ce57e05b0234a031 Mon Sep 17 00:00:00 2001 From: Alberto <alberto@expensify.com> Date: Thu, 11 Apr 2024 18:30:00 +0200 Subject: [PATCH 083/206] hopefully last one --- .../iou/request/step/IOURequestStepScan/index.native.tsx | 6 ++---- src/pages/iou/request/step/IOURequestStepScan/index.tsx | 6 ++---- src/pages/iou/steps/MoneyRequestAmountForm.tsx | 4 ++-- 3 files changed, 6 insertions(+), 10 deletions(-) diff --git a/src/pages/iou/request/step/IOURequestStepScan/index.native.tsx b/src/pages/iou/request/step/IOURequestStepScan/index.native.tsx index 59c271c9d363..c6e1c371390a 100644 --- a/src/pages/iou/request/step/IOURequestStepScan/index.native.tsx +++ b/src/pages/iou/request/step/IOURequestStepScan/index.native.tsx @@ -39,9 +39,9 @@ import ROUTES from '@src/ROUTES'; import type SCREENS from '@src/SCREENS'; import type * as OnyxTypes from '@src/types/onyx'; import {PersonalDetailsList, Policy, Report} from '@src/types/onyx'; +import {Receipt} from '@src/types/onyx/Transaction'; import CameraPermission from './CameraPermission'; import NavigationAwareCamera from './NavigationAwareCamera'; -import {Receipt} from "@src/types/onyx/Transaction"; type IOURequestStepScanOnyxProps = { /** The user */ @@ -91,9 +91,7 @@ function IOURequestStepScan({ // For quick button actions, we'll skip the confirmation page unless the report is archived or this is a workspace // request and the workspace requires a category or a tag const shouldSkipConfirmation = - skipConfirmation && - !ReportUtils.isArchivedRoom(report) && - !(ReportUtils.isPolicyExpenseChat(reportID) && ((policy?.requiresCategory ?? false) || (policy?.requiresTag ?? false))); + skipConfirmation && !ReportUtils.isArchivedRoom(report) && !(ReportUtils.isPolicyExpenseChat(report) && ((policy?.requiresCategory ?? false) || (policy?.requiresTag ?? false))); const {translate} = useLocalize(); diff --git a/src/pages/iou/request/step/IOURequestStepScan/index.tsx b/src/pages/iou/request/step/IOURequestStepScan/index.tsx index 10daf079fe05..eee357aa8aa9 100644 --- a/src/pages/iou/request/step/IOURequestStepScan/index.tsx +++ b/src/pages/iou/request/step/IOURequestStepScan/index.tsx @@ -40,9 +40,9 @@ import ROUTES from '@src/ROUTES'; import type SCREENS from '@src/SCREENS'; import type * as OnyxTypes from '@src/types/onyx'; import {PersonalDetailsList, Policy, Report} from '@src/types/onyx'; +import {Receipt} from '@src/types/onyx/Transaction'; import {isEmptyObject} from '@src/types/utils/EmptyObject'; import NavigationAwareCamera from './NavigationAwareCamera'; -import {Receipt} from "@src/types/onyx/Transaction"; type IOURequestStepScanOnyxProps = { /** Personal details of all users */ @@ -102,9 +102,7 @@ function IOURequestStepScan({ // For quick button actions, we'll skip the confirmation page unless the report is archived or this is a workspace // request and the workspace requires a category or a tag const shouldSkipConfirmation = - skipConfirmation && - !ReportUtils.isArchivedRoom(report) && - !(ReportUtils.isPolicyExpenseChat(reportID) && ((policy?.requiresCategory ?? false) || (policy?.requiresTag ?? false))); + skipConfirmation && !ReportUtils.isArchivedRoom(report) && !(ReportUtils.isPolicyExpenseChat(report) && ((policy?.requiresCategory ?? false) || (policy?.requiresTag ?? false))); /** * On phones that have ultra-wide lens, react-webcam uses ultra-wide by default. diff --git a/src/pages/iou/steps/MoneyRequestAmountForm.tsx b/src/pages/iou/steps/MoneyRequestAmountForm.tsx index 8390df819f6c..1c967ae2e4c4 100644 --- a/src/pages/iou/steps/MoneyRequestAmountForm.tsx +++ b/src/pages/iou/steps/MoneyRequestAmountForm.tsx @@ -23,7 +23,7 @@ import * as MoneyRequestUtils from '@libs/MoneyRequestUtils'; import Navigation from '@libs/Navigation/Navigation'; import type {BaseTextInputRef} from '@src/components/TextInput/BaseTextInput/types'; import CONST from '@src/CONST'; -import type {AllRoutes} from '@src/ROUTES'; +import type {Route} from '@src/ROUTES'; import ROUTES from '@src/ROUTES'; import type {SelectedTabRequest} from '@src/types/onyx'; import type {PaymentMethodType} from '@src/types/onyx/OriginalMessage'; @@ -53,7 +53,7 @@ type MoneyRequestAmountFormProps = { policyID?: string; /** Depending on expense report or personal IOU report, respective bank account route */ - bankAccountRoute?: AllRoutes; + bankAccountRoute?: Route; /** Whether the currency symbol is pressable */ isCurrencyPressable?: boolean; From d743b8f67c778d03123c8d6ccb6484e551f65c1d Mon Sep 17 00:00:00 2001 From: Alberto <alberto@expensify.com> Date: Thu, 11 Apr 2024 18:42:34 +0200 Subject: [PATCH 084/206] lint --- .../step/IOURequestStepScan/index.native.tsx | 14 +++++++------- .../iou/request/step/IOURequestStepScan/index.tsx | 14 +++++++------- 2 files changed, 14 insertions(+), 14 deletions(-) diff --git a/src/pages/iou/request/step/IOURequestStepScan/index.native.tsx b/src/pages/iou/request/step/IOURequestStepScan/index.native.tsx index c6e1c371390a..2e34293d9968 100644 --- a/src/pages/iou/request/step/IOURequestStepScan/index.native.tsx +++ b/src/pages/iou/request/step/IOURequestStepScan/index.native.tsx @@ -8,7 +8,6 @@ import {RESULTS} from 'react-native-permissions'; import Animated, {runOnJS, useAnimatedStyle, useSharedValue, withDelay, withSequence, withSpring, withTiming} from 'react-native-reanimated'; import type {Camera, PhotoFile, Point} from 'react-native-vision-camera'; import {useCameraDevice} from 'react-native-vision-camera'; -import _ from 'underscore'; import Hand from '@assets/images/hand.svg'; import Shutter from '@assets/images/shutter.svg'; import type {FileObject} from '@components/AttachmentModal'; @@ -19,7 +18,8 @@ import * as Expensicons from '@components/Icon/Expensicons'; import ImageSVG from '@components/ImageSVG'; import PressableWithFeedback from '@components/Pressable/PressableWithFeedback'; import Text from '@components/Text'; -import withCurrentUserPersonalDetails, {WithCurrentUserPersonalDetailsProps} from '@components/withCurrentUserPersonalDetails'; +import withCurrentUserPersonalDetails from '@components/withCurrentUserPersonalDetails'; +import type {WithCurrentUserPersonalDetailsProps} from '@components/withCurrentUserPersonalDetails'; import useLocalize from '@hooks/useLocalize'; import useTheme from '@hooks/useTheme'; import useThemeStyles from '@hooks/useThemeStyles'; @@ -38,8 +38,8 @@ import ONYXKEYS from '@src/ONYXKEYS'; import ROUTES from '@src/ROUTES'; import type SCREENS from '@src/SCREENS'; import type * as OnyxTypes from '@src/types/onyx'; -import {PersonalDetailsList, Policy, Report} from '@src/types/onyx'; -import {Receipt} from '@src/types/onyx/Transaction'; +import type {PersonalDetailsList, Policy} from '@src/types/onyx'; +import type {Receipt} from '@src/types/onyx/Transaction'; import CameraPermission from './CameraPermission'; import NavigationAwareCamera from './NavigationAwareCamera'; @@ -216,7 +216,7 @@ function IOURequestStepScan({ // If the transaction was created from the + menu from the composer inside of a chat, the participants can automatically // be added to the transaction (taken from the chat report participants) and then the person is taken to the confirmation step. const selectedParticipants = IOU.setMoneyRequestParticipantsFromReport(transactionID, report); - const participants = _.map(selectedParticipants, (participant) => { + const participants = selectedParticipants.map((participant) => { const participantAccountID = participant?.accountID ?? 0; return participantAccountID ? OptionsListUtils.getParticipantsOption(participant, personalDetails) : OptionsListUtils.getReportOption(participant); }); @@ -453,7 +453,7 @@ function IOURequestStepScan({ IOURequestStepScan.displayName = 'IOURequestStepScan'; -const IOURequestStepScanOnyxProps = withOnyx<IOURequestStepScanProps, IOURequestStepScanOnyxProps>({ +const IOURequestStepScanWithOnyx = withOnyx<IOURequestStepScanProps, IOURequestStepScanOnyxProps>({ policy: { key: ({report}) => `${ONYXKEYS.COLLECTION.POLICY}${report ? report.policyID : '0'}`, }, @@ -472,7 +472,7 @@ const IOURequestStepScanOnyxProps = withOnyx<IOURequestStepScanProps, IOURequest })(IOURequestStepScan); // eslint-disable-next-line rulesdir/no-negated-variables -const IOURequestStepScanWithCurrentUserPersonalDetails = withCurrentUserPersonalDetails(IOURequestStepScanOnyxProps); +const IOURequestStepScanWithCurrentUserPersonalDetails = withCurrentUserPersonalDetails(IOURequestStepScanWithOnyx); // eslint-disable-next-line rulesdir/no-negated-variables const IOURequestStepScanWithWritableReportOrNotFound = withWritableReportOrNotFound(IOURequestStepScanWithCurrentUserPersonalDetails); // eslint-disable-next-line rulesdir/no-negated-variables diff --git a/src/pages/iou/request/step/IOURequestStepScan/index.tsx b/src/pages/iou/request/step/IOURequestStepScan/index.tsx index eee357aa8aa9..61de9a89ee78 100644 --- a/src/pages/iou/request/step/IOURequestStepScan/index.tsx +++ b/src/pages/iou/request/step/IOURequestStepScan/index.tsx @@ -2,7 +2,6 @@ import React, {useCallback, useContext, useEffect, useReducer, useRef, useState} import {ActivityIndicator, PanResponder, PixelRatio, View} from 'react-native'; import {OnyxEntry, withOnyx} from 'react-native-onyx'; import type Webcam from 'react-webcam'; -import _ from 'underscore'; import Hand from '@assets/images/hand.svg'; import ReceiptUpload from '@assets/images/receipt-upload.svg'; import Shutter from '@assets/images/shutter.svg'; @@ -16,7 +15,8 @@ import Icon from '@components/Icon'; import * as Expensicons from '@components/Icon/Expensicons'; import PressableWithFeedback from '@components/Pressable/PressableWithFeedback'; import Text from '@components/Text'; -import withCurrentUserPersonalDetails, {WithCurrentUserPersonalDetailsProps} from '@components/withCurrentUserPersonalDetails'; +import withCurrentUserPersonalDetails from '@components/withCurrentUserPersonalDetails'; +import type {WithCurrentUserPersonalDetailsProps} from '@components/withCurrentUserPersonalDetails'; import useLocalize from '@hooks/useLocalize'; import useTabNavigatorFocus from '@hooks/useTabNavigatorFocus'; import useTheme from '@hooks/useTheme'; @@ -39,8 +39,8 @@ import ONYXKEYS from '@src/ONYXKEYS'; import ROUTES from '@src/ROUTES'; import type SCREENS from '@src/SCREENS'; import type * as OnyxTypes from '@src/types/onyx'; -import {PersonalDetailsList, Policy, Report} from '@src/types/onyx'; -import {Receipt} from '@src/types/onyx/Transaction'; +import type {PersonalDetailsList, Policy} from '@src/types/onyx'; +import type {Receipt} from '@src/types/onyx/Transaction'; import {isEmptyObject} from '@src/types/utils/EmptyObject'; import NavigationAwareCamera from './NavigationAwareCamera'; @@ -243,7 +243,7 @@ function IOURequestStepScan({ // If the transaction was created from the + menu from the composer inside of a chat, the participants can automatically // be added to the transaction (taken from the chat report participants) and then the person is taken to the confirmation step. const selectedParticipants = IOU.setMoneyRequestParticipantsFromReport(transactionID, report); - const participants = _.map(selectedParticipants, (participant) => { + const participants = selectedParticipants.map((participant) => { const participantAccountID = participant?.accountID ?? 0; return participantAccountID ? OptionsListUtils.getParticipantsOption(participant, personalDetails) : OptionsListUtils.getReportOption(participant); }); @@ -570,7 +570,7 @@ function IOURequestStepScan({ IOURequestStepScan.displayName = 'IOURequestStepScan'; -const IOURequestStepScanOnyxProps = withOnyx<IOURequestStepScanProps, IOURequestStepScanOnyxProps>({ +const IOURequestStepScanWithOnyx = withOnyx<IOURequestStepScanProps, IOURequestStepScanOnyxProps>({ policy: { key: ({report}) => `${ONYXKEYS.COLLECTION.POLICY}${report ? report.policyID : '0'}`, }, @@ -586,7 +586,7 @@ const IOURequestStepScanOnyxProps = withOnyx<IOURequestStepScanProps, IOURequest })(IOURequestStepScan); // eslint-disable-next-line rulesdir/no-negated-variables -const IOURequestStepScanWithCurrentUserPersonalDetails = withCurrentUserPersonalDetails(IOURequestStepScanOnyxProps); +const IOURequestStepScanWithCurrentUserPersonalDetails = withCurrentUserPersonalDetails(IOURequestStepScanWithOnyx); // eslint-disable-next-line rulesdir/no-negated-variables const IOURequestStepScanWithWritableReportOrNotFound = withWritableReportOrNotFound(IOURequestStepScanWithCurrentUserPersonalDetails); // eslint-disable-next-line rulesdir/no-negated-variables From dcf1f685aae19699c8463969c2fee92f384a3f18 Mon Sep 17 00:00:00 2001 From: Alberto <alberto@expensify.com> Date: Thu, 11 Apr 2024 18:53:52 +0200 Subject: [PATCH 085/206] import fixes --- .../request/step/IOURequestStepScan/index.native.tsx | 5 ++--- .../iou/request/step/IOURequestStepScan/index.tsx | 10 +++++----- 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/src/pages/iou/request/step/IOURequestStepScan/index.native.tsx b/src/pages/iou/request/step/IOURequestStepScan/index.native.tsx index 2e34293d9968..197e2124e22d 100644 --- a/src/pages/iou/request/step/IOURequestStepScan/index.native.tsx +++ b/src/pages/iou/request/step/IOURequestStepScan/index.native.tsx @@ -38,7 +38,6 @@ import ONYXKEYS from '@src/ONYXKEYS'; import ROUTES from '@src/ROUTES'; import type SCREENS from '@src/SCREENS'; import type * as OnyxTypes from '@src/types/onyx'; -import type {PersonalDetailsList, Policy} from '@src/types/onyx'; import type {Receipt} from '@src/types/onyx/Transaction'; import CameraPermission from './CameraPermission'; import NavigationAwareCamera from './NavigationAwareCamera'; @@ -48,10 +47,10 @@ type IOURequestStepScanOnyxProps = { user: OnyxEntry<OnyxTypes.User>; /** Personal details of all users */ - personalDetails: OnyxEntry<PersonalDetailsList>; + personalDetails: OnyxEntry<OnyxTypes.PersonalDetailsList>; /** The policy which the user has access to and which the report is tied to */ - policy: OnyxEntry<Policy>; + policy: OnyxEntry<OnyxTypes.Policy>; /** Whether the confirmation step should be skipped */ skipConfirmation: OnyxEntry<boolean>; diff --git a/src/pages/iou/request/step/IOURequestStepScan/index.tsx b/src/pages/iou/request/step/IOURequestStepScan/index.tsx index 61de9a89ee78..dd72274cc34c 100644 --- a/src/pages/iou/request/step/IOURequestStepScan/index.tsx +++ b/src/pages/iou/request/step/IOURequestStepScan/index.tsx @@ -1,6 +1,7 @@ import React, {useCallback, useContext, useEffect, useReducer, useRef, useState} from 'react'; import {ActivityIndicator, PanResponder, PixelRatio, View} from 'react-native'; -import {OnyxEntry, withOnyx} from 'react-native-onyx'; +import {withOnyx} from 'react-native-onyx'; +import type {OnyxEntry} from 'react-native-onyx'; import type Webcam from 'react-webcam'; import Hand from '@assets/images/hand.svg'; import ReceiptUpload from '@assets/images/receipt-upload.svg'; @@ -38,18 +39,17 @@ import type {TranslationPaths} from '@src/languages/types'; import ONYXKEYS from '@src/ONYXKEYS'; import ROUTES from '@src/ROUTES'; import type SCREENS from '@src/SCREENS'; -import type * as OnyxTypes from '@src/types/onyx'; -import type {PersonalDetailsList, Policy} from '@src/types/onyx'; +import type * as OnyxTypes from '@src/types/onyx';; import type {Receipt} from '@src/types/onyx/Transaction'; import {isEmptyObject} from '@src/types/utils/EmptyObject'; import NavigationAwareCamera from './NavigationAwareCamera'; type IOURequestStepScanOnyxProps = { /** Personal details of all users */ - personalDetails: OnyxEntry<PersonalDetailsList>; + personalDetails: OnyxEntry<OnyxTypes.PersonalDetailsList>; /** The policy which the user has access to and which the report is tied to */ - policy: OnyxEntry<Policy>; + policy: OnyxEntry<OnyxTypes.Policy>; /** Whether the confirmation step should be skipped */ skipConfirmation: OnyxEntry<boolean>; From aeb636f6810c12e9d576b3276201b368375c95eb Mon Sep 17 00:00:00 2001 From: Alberto <alberto@expensify.com> Date: Thu, 11 Apr 2024 19:00:47 +0200 Subject: [PATCH 086/206] typoo --- src/pages/iou/request/step/IOURequestStepScan/index.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pages/iou/request/step/IOURequestStepScan/index.tsx b/src/pages/iou/request/step/IOURequestStepScan/index.tsx index dd72274cc34c..7cae39c05233 100644 --- a/src/pages/iou/request/step/IOURequestStepScan/index.tsx +++ b/src/pages/iou/request/step/IOURequestStepScan/index.tsx @@ -39,7 +39,7 @@ import type {TranslationPaths} from '@src/languages/types'; import ONYXKEYS from '@src/ONYXKEYS'; import ROUTES from '@src/ROUTES'; import type SCREENS from '@src/SCREENS'; -import type * as OnyxTypes from '@src/types/onyx';; +import type * as OnyxTypes from '@src/types/onyx'; import type {Receipt} from '@src/types/onyx/Transaction'; import {isEmptyObject} from '@src/types/utils/EmptyObject'; import NavigationAwareCamera from './NavigationAwareCamera'; From 80961f41f01d094c11e63af87ed017a23b202b7b Mon Sep 17 00:00:00 2001 From: Alberto <alberto@expensify.com> Date: Fri, 12 Apr 2024 10:48:07 +0200 Subject: [PATCH 087/206] Fix split --- .../iou/request/step/IOURequestStepAmount.js | 14 +++++++++++- .../request/step/IOURequestStepDistance.js | 22 ++++++++++--------- 2 files changed, 25 insertions(+), 11 deletions(-) diff --git a/src/pages/iou/request/step/IOURequestStepAmount.js b/src/pages/iou/request/step/IOURequestStepAmount.js index c6a5fc723154..bfbad28a278b 100644 --- a/src/pages/iou/request/step/IOURequestStepAmount.js +++ b/src/pages/iou/request/step/IOURequestStepAmount.js @@ -171,7 +171,19 @@ function IOURequestStepAmount({ if (shouldSkipConfirmation) { if (iouType === CONST.IOU.TYPE.SPLIT) { - IOU.splitBillAndOpenReport(participants, currentUserPersonalDetails.login, currentUserPersonalDetails.accountID, backendAmount, '', currency, '', '', ''); + IOU.splitBillAndOpenReport({ + participants, + currentUserLogin: currentUserPersonalDetails.login || '', + currentUserAccountID: currentUserPersonalDetails.accountID || 0, + amount: backendAmount, + comment: '', + currency: currency, + tag: '', + category: '', + created: transaction.created, + billable: false, + iouRequestType: CONST.IOU.REQUEST_TYPE.MANUAL + }); return; } if (iouType === CONST.IOU.TYPE.SEND) { diff --git a/src/pages/iou/request/step/IOURequestStepDistance.js b/src/pages/iou/request/step/IOURequestStepDistance.js index 501badc8e519..ca66fa72fe85 100644 --- a/src/pages/iou/request/step/IOURequestStepDistance.js +++ b/src/pages/iou/request/step/IOURequestStepDistance.js @@ -203,17 +203,19 @@ function IOURequestStepDistance({ }); if (shouldSkipConfirmation) { if (iouType === CONST.IOU.TYPE.SPLIT) { - IOU.splitBillAndOpenReport( + IOU.splitBillAndOpenReport({ participants, - currentUserPersonalDetails.login, - currentUserPersonalDetails.accountID, - 0, - '', - transaction.currency, - translate('iou.routePending'), - transaction.created, - '', - ); + currentUserLogin: currentUserPersonalDetails.login, + currentUserAccountID: currentUserPersonalDetails.accountID, + aamount: 0, + currency: transaction.currency || 'USD', + merchant: translate('iou.routePending'), + created: transaction.created, + category: '', + tag: '', + billable: false, + iouRequestType: CONST.IOU.REQUEST_TYPE.DISTANCE, + }); return; } IOU.setMoneyRequestPendingFields(transactionID, {waypoints: CONST.RED_BRICK_ROAD_PENDING_ACTION.ADD}); From 4ee284b1c6ba3f647773d7d5c2d83b3bbaae5145 Mon Sep 17 00:00:00 2001 From: Alberto <alberto@expensify.com> Date: Fri, 12 Apr 2024 10:48:47 +0200 Subject: [PATCH 088/206] prettier --- src/pages/iou/request/step/IOURequestStepAmount.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pages/iou/request/step/IOURequestStepAmount.js b/src/pages/iou/request/step/IOURequestStepAmount.js index bfbad28a278b..909567e729ad 100644 --- a/src/pages/iou/request/step/IOURequestStepAmount.js +++ b/src/pages/iou/request/step/IOURequestStepAmount.js @@ -182,7 +182,7 @@ function IOURequestStepAmount({ category: '', created: transaction.created, billable: false, - iouRequestType: CONST.IOU.REQUEST_TYPE.MANUAL + iouRequestType: CONST.IOU.REQUEST_TYPE.MANUAL, }); return; } From 7c4897f31a5467fbbd1e7bb8b319565a252d8bbb Mon Sep 17 00:00:00 2001 From: Alberto <alberto@expensify.com> Date: Fri, 12 Apr 2024 10:59:15 +0200 Subject: [PATCH 089/206] shorthand --- src/pages/iou/request/step/IOURequestStepAmount.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pages/iou/request/step/IOURequestStepAmount.js b/src/pages/iou/request/step/IOURequestStepAmount.js index 909567e729ad..5d285cf7bc72 100644 --- a/src/pages/iou/request/step/IOURequestStepAmount.js +++ b/src/pages/iou/request/step/IOURequestStepAmount.js @@ -177,7 +177,7 @@ function IOURequestStepAmount({ currentUserAccountID: currentUserPersonalDetails.accountID || 0, amount: backendAmount, comment: '', - currency: currency, + currency, tag: '', category: '', created: transaction.created, From 747b8ea2f6bbc67d1f412fbbb12cb01687928067 Mon Sep 17 00:00:00 2001 From: brunovjk <brunovjk@gmail.com> Date: Fri, 12 Apr 2024 10:37:04 -0300 Subject: [PATCH 090/206] Replace all uses of the Old Component with the New Component --- .../MoneyTemporaryForRefactorRequestConfirmationList.tsx | 5 ++++- src/pages/iou/SplitBillDetailsPage.tsx | 4 +--- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/src/components/MoneyTemporaryForRefactorRequestConfirmationList.tsx b/src/components/MoneyTemporaryForRefactorRequestConfirmationList.tsx index 21815f00253b..6a63dcc9ff7d 100755 --- a/src/components/MoneyTemporaryForRefactorRequestConfirmationList.tsx +++ b/src/components/MoneyTemporaryForRefactorRequestConfirmationList.tsx @@ -112,7 +112,7 @@ type MoneyRequestConfirmationListProps = MoneyRequestConfirmationListOnyxProps & selectedParticipants: Participant[]; /** Payee of the money request with login */ - payeePersonalDetails?: OnyxTypes.PersonalDetails; + payeePersonalDetails?: OnyxEntry<OnyxTypes.PersonalDetails>; /** Can the participants be modified or not */ canModifyParticipants?: boolean; @@ -686,6 +686,7 @@ function MoneyTemporaryForRefactorRequestConfirmationList({ transaction?.transactionID ?? '', reportID, Navigation.getActiveRouteWithoutParams(), + reportActionID, ), ); }} @@ -797,6 +798,7 @@ function MoneyTemporaryForRefactorRequestConfirmationList({ transaction?.transactionID ?? '', reportID, Navigation.getActiveRouteWithoutParams(), + reportActionID, ), ) } @@ -829,6 +831,7 @@ function MoneyTemporaryForRefactorRequestConfirmationList({ transaction?.transactionID ?? '', reportID, Navigation.getActiveRouteWithoutParams(), + reportActionID, ), ) } diff --git a/src/pages/iou/SplitBillDetailsPage.tsx b/src/pages/iou/SplitBillDetailsPage.tsx index 91aa37dd01c2..fca3b713dec8 100644 --- a/src/pages/iou/SplitBillDetailsPage.tsx +++ b/src/pages/iou/SplitBillDetailsPage.tsx @@ -5,7 +5,7 @@ import {withOnyx} from 'react-native-onyx'; import type {OnyxEntry} from 'react-native-onyx'; import FullPageNotFoundView from '@components/BlockingViews/FullPageNotFoundView'; import HeaderWithBackButton from '@components/HeaderWithBackButton'; -import MoneyRequestConfirmationList from '@components/MoneyRequestConfirmationList'; +import MoneyRequestConfirmationList from '@components/MoneyTemporaryForRefactorRequestConfirmationList'; import MoneyRequestHeaderStatusBar from '@components/MoneyRequestHeaderStatusBar'; import ScreenWrapper from '@components/ScreenWrapper'; import useLocalize from '@hooks/useLocalize'; @@ -85,7 +85,6 @@ function SplitBillDetailsPage({personalDetails, report, route, reportActions, tr merchant: splitMerchant, created: splitCreated, category: splitCategory, - tag: splitTag, billable: splitBillable, } = ReportUtils.getTransactionDetails(isEditingSplitBill && draftTransaction ? draftTransaction : transaction) ?? {}; @@ -117,7 +116,6 @@ function SplitBillDetailsPage({personalDetails, report, route, reportActions, tr iouCreated={splitCreated} iouMerchant={splitMerchant} iouCategory={splitCategory} - iouTag={splitTag} iouIsBillable={splitBillable} iouType={CONST.IOU.TYPE.SPLIT} isReadOnly={!isEditingSplitBill} From dc3e2e5533dcf142648939169380811ed0bd7ccf Mon Sep 17 00:00:00 2001 From: brunovjk <brunovjk@gmail.com> Date: Fri, 12 Apr 2024 10:40:24 -0300 Subject: [PATCH 091/206] Remove Old Component --- .../MoneyRequestConfirmationList.tsx | 906 ------------------ 1 file changed, 906 deletions(-) delete mode 100755 src/components/MoneyRequestConfirmationList.tsx diff --git a/src/components/MoneyRequestConfirmationList.tsx b/src/components/MoneyRequestConfirmationList.tsx deleted file mode 100755 index cadad07b6585..000000000000 --- a/src/components/MoneyRequestConfirmationList.tsx +++ /dev/null @@ -1,906 +0,0 @@ -import {useIsFocused} from '@react-navigation/native'; -import {format} from 'date-fns'; -import React, {useCallback, useEffect, useMemo, useReducer, useState} from 'react'; -import type {StyleProp, ViewStyle} from 'react-native'; -import {View} from 'react-native'; -import type {OnyxEntry} from 'react-native-onyx'; -import {withOnyx} from 'react-native-onyx'; -import type {ValueOf} from 'type-fest'; -import useCurrentUserPersonalDetails from '@hooks/useCurrentUserPersonalDetails'; -import useLocalize from '@hooks/useLocalize'; -import usePermissions from '@hooks/usePermissions'; -import useTheme from '@hooks/useTheme'; -import useThemeStyles from '@hooks/useThemeStyles'; -import * as CurrencyUtils from '@libs/CurrencyUtils'; -import type {DefaultMileageRate} from '@libs/DistanceRequestUtils'; -import DistanceRequestUtils from '@libs/DistanceRequestUtils'; -import * as IOUUtils from '@libs/IOUUtils'; -import Log from '@libs/Log'; -import * as MoneyRequestUtils from '@libs/MoneyRequestUtils'; -import Navigation from '@libs/Navigation/Navigation'; -import * as OptionsListUtils from '@libs/OptionsListUtils'; -import * as PolicyUtils from '@libs/PolicyUtils'; -import * as ReceiptUtils from '@libs/ReceiptUtils'; -import * as ReportUtils from '@libs/ReportUtils'; -import * as TransactionUtils from '@libs/TransactionUtils'; -import * as IOU from '@userActions/IOU'; -import CONST from '@src/CONST'; -import ONYXKEYS from '@src/ONYXKEYS'; -import type {Route} from '@src/ROUTES'; -import ROUTES from '@src/ROUTES'; -import type * as OnyxTypes from '@src/types/onyx'; -import type {Participant} from '@src/types/onyx/IOU'; -import type {PaymentMethodType} from '@src/types/onyx/OriginalMessage'; -import type {ReceiptSource} from '@src/types/onyx/Transaction'; -import ButtonWithDropdownMenu from './ButtonWithDropdownMenu'; -import type {DropdownOption} from './ButtonWithDropdownMenu/types'; -import ConfirmedRoute from './ConfirmedRoute'; -import FormHelpMessage from './FormHelpMessage'; -import MenuItemWithTopDescription from './MenuItemWithTopDescription'; -import OptionsSelector from './OptionsSelector'; -import ReceiptEmptyState from './ReceiptEmptyState'; -import ReceiptImage from './ReceiptImage'; -import SettlementButton from './SettlementButton'; -import ShowMoreButton from './ShowMoreButton'; -import Switch from './Switch'; -import Text from './Text'; - -type IouType = ValueOf<typeof CONST.IOU.TYPE>; - -type MoneyRequestConfirmationListOnyxProps = { - /** Collection of categories attached to a policy */ - policyCategories: OnyxEntry<OnyxTypes.PolicyCategories>; - - /** Collection of tags attached to a policy */ - policyTags: OnyxEntry<OnyxTypes.PolicyTagList>; - - /** The policy of the report */ - policy: OnyxEntry<OnyxTypes.Policy>; - - /** Holds data related to Money Request view state, rather than the underlying Money Request data. */ - iou: OnyxEntry<OnyxTypes.IOU>; - - /** The session of the logged in user */ - session: OnyxEntry<OnyxTypes.Session>; - - /** Unit and rate used for if the money request is a distance request */ - mileageRate: OnyxEntry<DefaultMileageRate>; -}; -type MoneyRequestConfirmationListProps = MoneyRequestConfirmationListOnyxProps & { - /** Callback to inform parent modal of success */ - onConfirm?: (selectedParticipants: Array<Participant | ReportUtils.OptionData>) => void; - - /** Callback to parent modal to send money */ - onSendMoney?: (paymentMethod: IouType | PaymentMethodType | undefined) => void; - - /** Callback to inform a participant is selected */ - onSelectParticipant?: (option: Participant) => void; - - /** Should we request a single or multiple participant selection from user */ - hasMultipleParticipants: boolean; - - /** IOU amount */ - iouAmount: number; - - /** IOU comment */ - iouComment?: string; - - /** IOU currency */ - iouCurrencyCode?: string; - - /** IOU type */ - iouType?: IouType; - - /** IOU date */ - iouCreated?: string; - - /** IOU merchant */ - iouMerchant?: string; - - /** IOU Category */ - iouCategory?: string; - - /** IOU Tag */ - iouTag?: string; - - /** IOU isBillable */ - iouIsBillable?: boolean; - - /** Callback to toggle the billable state */ - onToggleBillable?: (isOn: boolean) => void; - - /** Selected participants from MoneyRequestModal with login / accountID */ - selectedParticipants: Array<Participant | ReportUtils.OptionData>; - - /** Payee of the money request with login */ - payeePersonalDetails?: OnyxEntry<OnyxTypes.PersonalDetails>; - - /** Can the participants be modified or not */ - canModifyParticipants?: boolean; - - /** Should the list be read only, and not editable? */ - isReadOnly?: boolean; - - /** Depending on expense report or personal IOU report, respective bank account route */ - bankAccountRoute?: Route; - - /** The policyID of the request */ - policyID?: string; - - /** The reportID of the request */ - reportID?: string; - - /** File path of the receipt */ - receiptPath?: ReceiptSource; - - /** File name of the receipt */ - receiptFilename?: string; - - /** List styles for OptionsSelector */ - listStyles?: StyleProp<ViewStyle>; - - /** ID of the transaction that represents the money request */ - transactionID?: string; - - /** Transaction that represents the money request */ - transaction?: OnyxEntry<OnyxTypes.Transaction>; - - /** Whether the money request is a distance request */ - isDistanceRequest?: boolean; - - /** Whether the money request is a scan request */ - isScanRequest?: boolean; - - /** Whether we're editing a split bill */ - isEditingSplitBill?: boolean; - - /** Whether we should show the amount, date, and merchant fields. */ - shouldShowSmartScanFields?: boolean; - - /** A flag for verifying that the current report is a sub-report of a workspace chat */ - isPolicyExpenseChat?: boolean; - - /** Whether smart scan failed */ - hasSmartScanFailed?: boolean; - - /** The ID of the report action */ - reportActionID?: string; -}; - -function MoneyRequestConfirmationList({ - transaction = null, - onSendMoney, - onConfirm, - onSelectParticipant, - iouType = CONST.IOU.TYPE.REQUEST, - isScanRequest = false, - iouAmount, - policyCategories, - mileageRate, - isDistanceRequest = false, - policy, - isPolicyExpenseChat = false, - iouCategory = '', - shouldShowSmartScanFields = true, - isEditingSplitBill, - policyTags, - iouCurrencyCode, - iouMerchant, - hasMultipleParticipants, - selectedParticipants: selectedParticipantsProp, - payeePersonalDetails: payeePersonalDetailsProp, - iou = { - id: '', - amount: 0, - currency: CONST.CURRENCY.USD, - comment: '', - merchant: '', - category: '', - tag: '', - billable: false, - created: '', - participants: [], - receiptPath: '', - }, - canModifyParticipants: canModifyParticipantsProp = false, - session, - isReadOnly = false, - bankAccountRoute = '', - policyID = '', - reportID = '', - receiptPath = '', - iouComment, - receiptFilename = '', - listStyles, - iouCreated, - iouIsBillable = false, - onToggleBillable, - iouTag = '', - transactionID = '', - hasSmartScanFailed, - reportActionID, -}: MoneyRequestConfirmationListProps) { - const theme = useTheme(); - const styles = useThemeStyles(); - const {translate, toLocaleDigit} = useLocalize(); - const {canUseViolations} = usePermissions(); - const currentUserPersonalDetails = useCurrentUserPersonalDetails(); - - const isTypeRequest = iouType === CONST.IOU.TYPE.REQUEST; - const isSplitBill = iouType === CONST.IOU.TYPE.SPLIT; - const isTypeSend = iouType === CONST.IOU.TYPE.SEND; - - const isSplitWithScan = isSplitBill && isScanRequest; - - const {unit, rate, currency} = mileageRate ?? { - unit: CONST.CUSTOM_UNITS.DISTANCE_UNIT_MILES, - rate: 0, - currency: CONST.CURRENCY.USD, - }; - const distance = transaction?.routes?.route0.distance ?? 0; - const shouldCalculateDistanceAmount = isDistanceRequest && iouAmount === 0; - const taxRates = policy?.taxRates; - - // A flag for showing the categories field - const shouldShowCategories = isPolicyExpenseChat && (!!iouCategory || OptionsListUtils.hasEnabledOptions(Object.values(policyCategories ?? {}))); - // A flag and a toggler for showing the rest of the form fields - const [shouldExpandFields, toggleShouldExpandFields] = useReducer((state) => !state, false); - - // Do not hide fields in case of send money request - const shouldShowAllFields = !!isDistanceRequest || shouldExpandFields || !shouldShowSmartScanFields || isTypeSend || isEditingSplitBill; - - // In Send Money and Split Bill with Scan flow, we don't allow the Merchant or Date to be edited. For distance requests, don't show the merchant as there's already another "Distance" menu item - const shouldShowDate = shouldShowAllFields && !isTypeSend && !isSplitWithScan; - const shouldShowMerchant = shouldShowAllFields && !isTypeSend && !isDistanceRequest && !isSplitWithScan; - - const policyTagLists = useMemo(() => PolicyUtils.getTagLists(policyTags), [policyTags]); - - // A flag for showing the tags field - const shouldShowTags = isPolicyExpenseChat && (!!iouTag || OptionsListUtils.hasEnabledTags(policyTagLists)); - - // A flag for showing tax fields - tax rate and tax amount - const shouldShowTax = isPolicyExpenseChat && (policy?.tax?.trackingEnabled ?? policy?.isTaxTrackingEnabled); - - // A flag for showing the billable field - const shouldShowBillable = !(policy?.disabledFields?.defaultBillable ?? true); - - const hasRoute = TransactionUtils.hasRoute(transaction); - const isDistanceRequestWithPendingRoute = isDistanceRequest && (!hasRoute || !rate); - const formattedAmount = isDistanceRequestWithPendingRoute - ? '' - : CurrencyUtils.convertToDisplayString( - shouldCalculateDistanceAmount ? DistanceRequestUtils.getDistanceRequestAmount(distance, unit, rate ?? 0) : iouAmount, - isDistanceRequest ? currency : iouCurrencyCode, - ); - const formattedTaxAmount = CurrencyUtils.convertToDisplayString(transaction?.taxAmount, iouCurrencyCode); - - const defaultTaxKey = taxRates?.defaultExternalID; - const defaultTaxName = (defaultTaxKey && `${taxRates.taxes[defaultTaxKey].name} (${taxRates.taxes[defaultTaxKey].value}) • ${translate('common.default')}`) ?? ''; - // eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing -- nullish coalescing is not working when a left hand side value is '' - const taxRateTitle = transaction?.taxRate?.text || defaultTaxName; - - const isFocused = useIsFocused(); - const [formError, setFormError] = useState(''); - - const [didConfirm, setDidConfirm] = useState(false); - const [didConfirmSplit, setDidConfirmSplit] = useState(false); - - const shouldDisplayFieldError: boolean = useMemo(() => { - if (!isEditingSplitBill) { - return false; - } - - return (!!hasSmartScanFailed && TransactionUtils.hasMissingSmartscanFields(transaction)) || (didConfirmSplit && TransactionUtils.areRequiredFieldsEmpty(transaction)); - }, [isEditingSplitBill, hasSmartScanFailed, transaction, didConfirmSplit]); - - const isMerchantEmpty = !iouMerchant || iouMerchant === CONST.TRANSACTION.PARTIAL_TRANSACTION_MERCHANT; - const shouldDisplayMerchantError = isPolicyExpenseChat && shouldDisplayFieldError && isMerchantEmpty; - - useEffect(() => { - if (shouldDisplayFieldError && didConfirmSplit) { - setFormError('iou.error.genericSmartscanFailureMessage'); - return; - } - if (shouldDisplayFieldError && hasSmartScanFailed) { - setFormError('iou.receiptScanningFailed'); - return; - } - // reset the form error whenever the screen gains or loses focus - setFormError(''); - }, [isFocused, transaction, shouldDisplayFieldError, hasSmartScanFailed, didConfirmSplit]); - - useEffect(() => { - if (!shouldCalculateDistanceAmount) { - return; - } - - const amount = DistanceRequestUtils.getDistanceRequestAmount(distance, unit, rate ?? 0); - IOU.setMoneyRequestAmount(amount); - }, [shouldCalculateDistanceAmount, distance, rate, unit]); - - /** - * Returns the participants with amount - */ - const getParticipantsWithAmount = useCallback( - (participantsList: Array<Participant | ReportUtils.OptionData>): Array<Participant | ReportUtils.OptionData> => { - const calculatedIouAmount = IOUUtils.calculateAmount(participantsList.length, iouAmount, iouCurrencyCode ?? ''); - return OptionsListUtils.getIOUConfirmationOptionsFromParticipants( - participantsList, - iouAmount > 0 ? CurrencyUtils.convertToDisplayString(calculatedIouAmount, iouCurrencyCode) : '', - ); - }, - [iouAmount, iouCurrencyCode], - ); - - // If completing a split bill fails, set didConfirm to false to allow the user to edit the fields again - if (isEditingSplitBill && didConfirm) { - setDidConfirm(false); - } - - const splitOrRequestOptions: Array<DropdownOption<IouType>> = useMemo(() => { - let text; - if (isSplitBill && iouAmount === 0) { - text = translate('iou.split'); - } else if ((!!receiptPath && isTypeRequest) || isDistanceRequestWithPendingRoute) { - text = translate('iou.request'); - if (iouAmount !== 0) { - text = translate('iou.requestAmount', {amount: formattedAmount}); - } - } else { - const translationKey = isSplitBill ? 'iou.splitAmount' : 'iou.requestAmount'; - text = translate(translationKey, {amount: formattedAmount}); - } - return [ - { - text: text[0].toUpperCase() + text.slice(1), - value: iouType, - }, - ]; - }, [isSplitBill, isTypeRequest, iouType, iouAmount, receiptPath, formattedAmount, isDistanceRequestWithPendingRoute, translate]); - - const selectedParticipants: Array<Participant | ReportUtils.OptionData> = useMemo( - () => selectedParticipantsProp.filter((participant) => participant.selected), - [selectedParticipantsProp], - ); - const payeePersonalDetails = useMemo(() => payeePersonalDetailsProp ?? currentUserPersonalDetails, [payeePersonalDetailsProp, currentUserPersonalDetails]); - const canModifyParticipants = !isReadOnly && canModifyParticipantsProp && hasMultipleParticipants; - const shouldDisablePaidBySection = canModifyParticipants; - - const optionSelectorSections: OptionsListUtils.CategorySection[] = useMemo(() => { - const sections = []; - const unselectedParticipants = selectedParticipantsProp.filter((participant) => !participant.selected); - if (hasMultipleParticipants) { - const formattedSelectedParticipants = getParticipantsWithAmount(selectedParticipants); - let formattedParticipantsList = [...new Set([...formattedSelectedParticipants, ...unselectedParticipants])]; - - if (!canModifyParticipants) { - formattedParticipantsList = formattedParticipantsList.map((participant) => ({ - ...participant, - isDisabled: ReportUtils.isOptimisticPersonalDetail(participant.accountID ?? -1), - })); - } - - const myIOUAmount = IOUUtils.calculateAmount(selectedParticipants.length, iouAmount, iouCurrencyCode ?? '', true); - const formattedPayeeOption = OptionsListUtils.getIOUConfirmationOptionsFromPayeePersonalDetail( - payeePersonalDetails, - iouAmount > 0 ? CurrencyUtils.convertToDisplayString(myIOUAmount, iouCurrencyCode) : '', - ); - - sections.push( - { - title: translate('moneyRequestConfirmationList.paidBy'), - data: [formattedPayeeOption], - shouldShow: true, - isDisabled: shouldDisablePaidBySection, - }, - { - title: translate('moneyRequestConfirmationList.splitWith'), - data: formattedParticipantsList, - shouldShow: true, - }, - ); - } else { - const formattedSelectedParticipants = selectedParticipantsProp.map((participant) => ({ - ...participant, - isDisabled: ReportUtils.isOptimisticPersonalDetail(participant.accountID ?? -1), - })); - sections.push({ - title: translate('common.to'), - data: formattedSelectedParticipants, - shouldShow: true, - }); - } - return sections; - }, [ - selectedParticipants, - hasMultipleParticipants, - iouAmount, - iouCurrencyCode, - getParticipantsWithAmount, - selectedParticipantsProp, - payeePersonalDetails, - translate, - shouldDisablePaidBySection, - canModifyParticipants, - ]); - - const selectedOptions: Array<Participant | ReportUtils.OptionData | OptionsListUtils.PayeePersonalDetails> = useMemo(() => { - if (!hasMultipleParticipants) { - return []; - } - return [...selectedParticipants, OptionsListUtils.getIOUConfirmationOptionsFromPayeePersonalDetail(payeePersonalDetails)]; - }, [selectedParticipants, hasMultipleParticipants, payeePersonalDetails]); - - useEffect(() => { - if (!isDistanceRequest) { - return; - } - - /* - Set pending waypoints based on the route status. We should handle this dynamically to cover cases such as: - When the user completes the initial steps of the IOU flow offline and then goes online on the confirmation page. - In this scenario, the route will be fetched from the server, and the waypoints will no longer be pending. - */ - IOU.setMoneyRequestPendingFields(transactionID, {waypoints: isDistanceRequestWithPendingRoute ? CONST.RED_BRICK_ROAD_PENDING_ACTION.ADD : null}); - - const distanceMerchant = DistanceRequestUtils.getDistanceMerchant(hasRoute, distance, unit, rate ?? 0, currency ?? CONST.CURRENCY.USD, translate, toLocaleDigit); - IOU.setMoneyRequestMerchant(transactionID, distanceMerchant, false); - }, [isDistanceRequestWithPendingRoute, hasRoute, distance, unit, rate, currency, translate, toLocaleDigit, isDistanceRequest, transactionID]); - - const selectParticipant = useCallback( - (option: Participant) => { - // Return early if selected option is currently logged in user. - if (option.accountID === session?.accountID) { - return; - } - onSelectParticipant?.(option); - }, - [session?.accountID, onSelectParticipant], - ); - - /** - * Navigate to report details or profile of selected user - */ - const navigateToReportOrUserDetail = (option: ReportUtils.OptionData) => { - if (option.accountID) { - const activeRoute = Navigation.getActiveRouteWithoutParams(); - - Navigation.navigate(ROUTES.PROFILE.getRoute(option.accountID, activeRoute)); - } else if (option.reportID) { - Navigation.navigate(ROUTES.REPORT_WITH_ID_DETAILS.getRoute(option.reportID)); - } - }; - - const confirm = useCallback( - (paymentMethod: IouType | PaymentMethodType | undefined) => { - if (!selectedParticipants.length) { - return; - } - if (iouCategory.length > CONST.API_TRANSACTION_CATEGORY_MAX_LENGTH) { - setFormError('iou.error.invalidCategoryLength'); - return; - } - if (iouType === CONST.IOU.TYPE.SEND) { - if (!paymentMethod) { - return; - } - - setDidConfirm(true); - - Log.info(`[IOU] Sending money via: ${paymentMethod}`); - onSendMoney?.(paymentMethod); - } else { - // validate the amount for distance requests - const decimals = CurrencyUtils.getCurrencyDecimals(iouCurrencyCode); - if (isDistanceRequest && !isDistanceRequestWithPendingRoute && !MoneyRequestUtils.validateAmount(String(iouAmount), decimals)) { - setFormError('common.error.invalidAmount'); - return; - } - - if (isEditingSplitBill && TransactionUtils.areRequiredFieldsEmpty(transaction)) { - setDidConfirmSplit(true); - return; - } - - setDidConfirm(true); - onConfirm?.(selectedParticipants); - } - }, - [ - selectedParticipants, - onSendMoney, - onConfirm, - isEditingSplitBill, - iouType, - isDistanceRequest, - iouCategory, - isDistanceRequestWithPendingRoute, - iouCurrencyCode, - iouAmount, - transaction, - ], - ); - - const footerContent = useMemo(() => { - if (isReadOnly) { - return; - } - - const shouldShowSettlementButton = iouType === CONST.IOU.TYPE.SEND; - const shouldDisableButton = selectedParticipants.length === 0; - - const button = shouldShowSettlementButton ? ( - <SettlementButton - pressOnEnter - isDisabled={shouldDisableButton} - onPress={confirm} - enablePaymentsRoute={ROUTES.IOU_SEND_ENABLE_PAYMENTS} - addBankAccountRoute={bankAccountRoute} - currency={iouCurrencyCode} - policyID={policyID} - buttonSize={CONST.DROPDOWN_BUTTON_SIZE.LARGE} - kycWallAnchorAlignment={{ - horizontal: CONST.MODAL.ANCHOR_ORIGIN_HORIZONTAL.LEFT, - vertical: CONST.MODAL.ANCHOR_ORIGIN_VERTICAL.BOTTOM, - }} - paymentMethodDropdownAnchorAlignment={{ - horizontal: CONST.MODAL.ANCHOR_ORIGIN_HORIZONTAL.RIGHT, - vertical: CONST.MODAL.ANCHOR_ORIGIN_VERTICAL.BOTTOM, - }} - shouldShowPersonalBankAccountOption - enterKeyEventListenerPriority={1} - /> - ) : ( - <ButtonWithDropdownMenu - success - pressOnEnter - isDisabled={shouldDisableButton} - // eslint-disable-next-line @typescript-eslint/naming-convention - onPress={(_event, value) => confirm(value)} - options={splitOrRequestOptions} - buttonSize={CONST.DROPDOWN_BUTTON_SIZE.LARGE} - enterKeyEventListenerPriority={1} - /> - ); - return ( - <> - {!!formError.length && ( - <FormHelpMessage - style={[styles.ph1, styles.mb2]} - isError - message={formError} - /> - )} - {button} - </> - ); - }, [isReadOnly, iouType, bankAccountRoute, iouCurrencyCode, policyID, selectedParticipants.length, confirm, splitOrRequestOptions, formError, styles.ph1, styles.mb2]); - - const { - image: receiptImage, - thumbnail: receiptThumbnail, - isThumbnail, - fileExtension, - } = receiptPath && receiptFilename ? ReceiptUtils.getThumbnailAndImageURIs(transaction, receiptPath, receiptFilename) : ({} as ReceiptUtils.ThumbnailAndImageURI); - return ( - // @ts-expect-error This component is deprecated and will not be migrated to TypeScript (context: https://expensify.slack.com/archives/C01GTK53T8Q/p1709232289899589?thread_ts=1709156803.359359&cid=C01GTK53T8Q) - <OptionsSelector - sections={optionSelectorSections} - onSelectRow={canModifyParticipants ? selectParticipant : navigateToReportOrUserDetail} - onAddToSelection={selectParticipant} - onConfirmSelection={confirm} - selectedOptions={selectedOptions} - canSelectMultipleOptions={canModifyParticipants} - disableArrowKeysActions={!canModifyParticipants} - boldStyle - showTitleTooltip - shouldTextInputAppearBelowOptions - shouldShowTextInput={false} - shouldUseStyleForChildren={false} - optionHoveredStyle={canModifyParticipants ? styles.hoveredComponentBG : {}} - footerContent={(!!iou?.id || isEditingSplitBill) && footerContent} - listStyles={listStyles} - shouldAllowScrollingChildren - > - {isDistanceRequest && ( - <View style={styles.confirmationListMapItem}> - <ConfirmedRoute transaction={transaction} /> - </View> - )} - {/* eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing */} - {receiptImage || receiptThumbnail ? ( - <ReceiptImage - style={styles.moneyRequestImage} - isThumbnail={isThumbnail} - source={String(receiptThumbnail ?? receiptImage)} - // AuthToken is required when retrieving the image from the server - // but we don't need it to load the blob:// or file:// image when starting a money request / split bill - // So if we have a thumbnail, it means we're retrieving the image from the server - isAuthTokenRequired={!!receiptThumbnail} - fileExtension={fileExtension} - /> - ) : ( - // The empty receipt component should only show for IOU Requests of a paid policy ("Team" or "Corporate") - PolicyUtils.isPaidGroupPolicy(policy) && - !isDistanceRequest && - iouType === CONST.IOU.TYPE.REQUEST && ( - <ReceiptEmptyState - onPress={() => - Navigation.navigate( - ROUTES.MONEY_REQUEST_STEP_SCAN.getRoute( - CONST.IOU.ACTION.CREATE, - iouType, - transaction?.transactionID ?? '', - reportID, - Navigation.getActiveRouteWithoutParams(), - ), - ) - } - /> - ) - )} - {shouldShowSmartScanFields && ( - <MenuItemWithTopDescription - shouldShowRightIcon={!isReadOnly && !isDistanceRequest} - title={formattedAmount} - description={translate('iou.amount')} - interactive={!isReadOnly} - onPress={() => { - if (isDistanceRequest) { - return; - } - Navigation.navigate( - ROUTES.MONEY_REQUEST_STEP_AMOUNT.getRoute(CONST.IOU.ACTION.EDIT, iouType, transaction?.transactionID ?? '', reportID, Navigation.getActiveRouteWithoutParams()), - ); - }} - style={[styles.moneyRequestMenuItem, styles.mt2]} - titleStyle={styles.moneyRequestConfirmationAmount} - disabled={didConfirm} - brickRoadIndicator={shouldDisplayFieldError && TransactionUtils.isAmountMissing(transaction) ? CONST.BRICK_ROAD_INDICATOR_STATUS.ERROR : undefined} - error={shouldDisplayFieldError && TransactionUtils.isAmountMissing(transaction) ? translate('common.error.enterAmount') : ''} - /> - )} - <MenuItemWithTopDescription - shouldShowRightIcon={!isReadOnly} - shouldParseTitle - title={iouComment} - description={translate('common.description')} - onPress={() => { - Navigation.navigate( - ROUTES.MONEY_REQUEST_STEP_DESCRIPTION.getRoute( - CONST.IOU.ACTION.EDIT, - iouType, - transaction?.transactionID ?? '', - reportID, - Navigation.getActiveRouteWithoutParams(), - reportActionID, - ), - ); - }} - style={styles.moneyRequestMenuItem} - titleStyle={styles.flex1} - disabled={didConfirm} - interactive={!isReadOnly} - numberOfLinesTitle={2} - /> - {!shouldShowAllFields && ( - <ShowMoreButton - containerStyle={[styles.mt1, styles.mb2]} - onPress={toggleShouldExpandFields} - /> - )} - {shouldShowAllFields && ( - <> - {shouldShowDate && ( - <MenuItemWithTopDescription - shouldShowRightIcon={!isReadOnly} - // eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing - title={iouCreated || format(new Date(), CONST.DATE.FNS_FORMAT_STRING)} - description={translate('common.date')} - style={styles.moneyRequestMenuItem} - titleStyle={styles.flex1} - onPress={() => { - Navigation.navigate( - ROUTES.MONEY_REQUEST_STEP_DATE.getRoute( - CONST.IOU.ACTION.EDIT, - iouType, - transaction?.transactionID ?? '', - reportID, - Navigation.getActiveRouteWithoutParams(), - ), - ); - }} - disabled={didConfirm} - interactive={!isReadOnly} - brickRoadIndicator={shouldDisplayFieldError && TransactionUtils.isCreatedMissing(transaction) ? CONST.BRICK_ROAD_INDICATOR_STATUS.ERROR : undefined} - error={shouldDisplayFieldError && TransactionUtils.isCreatedMissing(transaction) ? translate('common.error.enterDate') : ''} - /> - )} - {isDistanceRequest && ( - <MenuItemWithTopDescription - shouldShowRightIcon={!isReadOnly} - title={iouMerchant} - description={translate('common.distance')} - style={styles.moneyRequestMenuItem} - titleStyle={styles.flex1} - onPress={() => - Navigation.navigate( - ROUTES.MONEY_REQUEST_STEP_DISTANCE.getRoute( - CONST.IOU.ACTION.EDIT, - iouType, - transaction?.transactionID ?? '', - reportID, - Navigation.getActiveRouteWithoutParams(), - ), - ) - } - disabled={didConfirm} - interactive={!isReadOnly} - /> - )} - {shouldShowMerchant && ( - <MenuItemWithTopDescription - shouldShowRightIcon={!isReadOnly} - title={isMerchantEmpty ? '' : iouMerchant} - description={translate('common.merchant')} - style={styles.moneyRequestMenuItem} - titleStyle={styles.flex1} - onPress={() => { - Navigation.navigate( - ROUTES.MONEY_REQUEST_STEP_MERCHANT.getRoute( - CONST.IOU.ACTION.EDIT, - iouType, - transaction?.transactionID ?? '', - reportID, - Navigation.getActiveRouteWithoutParams(), - ), - ); - }} - disabled={didConfirm} - interactive={!isReadOnly} - brickRoadIndicator={shouldDisplayMerchantError ? CONST.BRICK_ROAD_INDICATOR_STATUS.ERROR : undefined} - error={shouldDisplayMerchantError ? translate('common.error.enterMerchant') : ''} - /> - )} - {shouldShowCategories && ( - <MenuItemWithTopDescription - shouldShowRightIcon={!isReadOnly} - title={iouCategory} - description={translate('common.category')} - numberOfLinesTitle={2} - onPress={() => { - Navigation.navigate( - ROUTES.MONEY_REQUEST_STEP_CATEGORY.getRoute( - CONST.IOU.ACTION.EDIT, - iouType, - transaction?.transactionID ?? '', - reportID, - Navigation.getActiveRouteWithoutParams(), - reportActionID, - ), - ); - }} - style={styles.moneyRequestMenuItem} - titleStyle={styles.flex1} - disabled={didConfirm} - interactive={!isReadOnly} - rightLabel={canUseViolations && !!policy?.requiresCategory ? translate('common.required') : ''} - /> - )} - {shouldShowTags && - policyTagLists.map(({name}, index) => ( - <MenuItemWithTopDescription - key={name} - shouldShowRightIcon={!isReadOnly} - title={TransactionUtils.getTagForDisplay(transaction, index)} - description={name} - numberOfLinesTitle={2} - onPress={() => { - if (!isEditingSplitBill) { - return; - } - - Navigation.navigate( - ROUTES.MONEY_REQUEST_STEP_TAG.getRoute( - CONST.IOU.ACTION.EDIT, - CONST.IOU.TYPE.SPLIT, - index, - transaction?.transactionID ?? '', - reportID, - Navigation.getActiveRouteWithoutParams(), - reportActionID, - ), - ); - }} - style={styles.moneyRequestMenuItem} - disabled={didConfirm} - interactive={!isReadOnly} - rightLabel={canUseViolations && !!policy?.requiresTag ? translate('common.required') : ''} - /> - ))} - - {shouldShowTax && ( - <MenuItemWithTopDescription - shouldShowRightIcon={!isReadOnly} - title={taxRateTitle} - description={taxRates?.name} - style={styles.moneyRequestMenuItem} - titleStyle={styles.flex1} - onPress={() => - Navigation.navigate( - ROUTES.MONEY_REQUEST_STEP_TAX_RATE.getRoute( - CONST.IOU.ACTION.CREATE, - iouType, - transaction?.transactionID ?? '', - reportID, - Navigation.getActiveRouteWithoutParams(), - ), - ) - } - disabled={didConfirm} - interactive={!isReadOnly} - /> - )} - - {shouldShowTax && ( - <MenuItemWithTopDescription - shouldShowRightIcon={!isReadOnly} - title={formattedTaxAmount} - description={taxRates?.name} - style={styles.moneyRequestMenuItem} - titleStyle={styles.flex1} - onPress={() => - Navigation.navigate( - ROUTES.MONEY_REQUEST_STEP_TAX_AMOUNT.getRoute( - CONST.IOU.ACTION.CREATE, - iouType, - transaction?.transactionID ?? '', - reportID, - Navigation.getActiveRouteWithoutParams(), - ), - ) - } - disabled={didConfirm} - interactive={!isReadOnly} - /> - )} - - {shouldShowBillable && ( - <View style={[styles.flexRow, styles.justifyContentBetween, styles.alignItemsCenter, styles.ml5, styles.mr8, styles.optionRow]}> - <Text color={!iouIsBillable ? theme.textSupporting : undefined}>{translate('common.billable')}</Text> - <Switch - accessibilityLabel={translate('common.billable')} - isOn={iouIsBillable} - onToggle={(isOn) => onToggleBillable?.(isOn)} - /> - </View> - )} - </> - )} - </OptionsSelector> - ); -} - -MoneyRequestConfirmationList.displayName = 'MoneyRequestConfirmationList'; - -export default withOnyx<MoneyRequestConfirmationListProps, MoneyRequestConfirmationListOnyxProps>({ - session: { - key: ONYXKEYS.SESSION, - }, - policyCategories: { - key: ({policyID}) => `${ONYXKEYS.COLLECTION.POLICY_CATEGORIES}${policyID}`, - }, - policyTags: { - key: ({policyID}) => `${ONYXKEYS.COLLECTION.POLICY_TAGS}${policyID}`, - }, - mileageRate: { - key: ({policyID}) => `${ONYXKEYS.COLLECTION.POLICY}${policyID}`, - selector: DistanceRequestUtils.getDefaultMileageRate, - }, - policy: { - key: ({policyID}) => `${ONYXKEYS.COLLECTION.POLICY}${policyID}`, - }, - iou: { - key: ONYXKEYS.IOU, - }, -})(MoneyRequestConfirmationList); From 032f118290ad6bba28882f408ff0eed6bf3b631d Mon Sep 17 00:00:00 2001 From: brunovjk <brunovjk@gmail.com> Date: Fri, 12 Apr 2024 10:45:03 -0300 Subject: [PATCH 092/206] Rename 'MoneyTemporaryForRefactorRequestConfirmationList' and in all its uses --- ...onfirmationList.tsx => MoneyRequestConfirmationList.tsx} | 6 +++--- src/pages/iou/SplitBillDetailsPage.tsx | 2 +- src/pages/iou/request/step/IOURequestStepConfirmation.tsx | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) rename src/components/{MoneyTemporaryForRefactorRequestConfirmationList.tsx => MoneyRequestConfirmationList.tsx} (99%) diff --git a/src/components/MoneyTemporaryForRefactorRequestConfirmationList.tsx b/src/components/MoneyRequestConfirmationList.tsx similarity index 99% rename from src/components/MoneyTemporaryForRefactorRequestConfirmationList.tsx rename to src/components/MoneyRequestConfirmationList.tsx index 6a63dcc9ff7d..6e0de099b847 100755 --- a/src/components/MoneyTemporaryForRefactorRequestConfirmationList.tsx +++ b/src/components/MoneyRequestConfirmationList.tsx @@ -168,7 +168,7 @@ const getTaxAmount = (transaction: OnyxEntry<OnyxTypes.Transaction>, defaultTaxV return TransactionUtils.calculateTaxAmount(percentage, transaction?.amount ?? 0); }; -function MoneyTemporaryForRefactorRequestConfirmationList({ +function MoneyRequestConfirmationList({ transaction = null, onSendMoney, onConfirm, @@ -1034,7 +1034,7 @@ function MoneyTemporaryForRefactorRequestConfirmationList({ ); } -MoneyTemporaryForRefactorRequestConfirmationList.displayName = 'MoneyTemporaryForRefactorRequestConfirmationList'; +MoneyRequestConfirmationList.displayName = 'MoneyRequestConfirmationList'; export default withOnyx<MoneyRequestConfirmationListProps, MoneyRequestConfirmationListOnyxProps>({ session: { @@ -1053,4 +1053,4 @@ export default withOnyx<MoneyRequestConfirmationListProps, MoneyRequestConfirmat policy: { key: ({policyID}) => `${ONYXKEYS.COLLECTION.POLICY}${policyID}`, }, -})(MoneyTemporaryForRefactorRequestConfirmationList); +})(MoneyRequestConfirmationList); diff --git a/src/pages/iou/SplitBillDetailsPage.tsx b/src/pages/iou/SplitBillDetailsPage.tsx index fca3b713dec8..c500c4a8175f 100644 --- a/src/pages/iou/SplitBillDetailsPage.tsx +++ b/src/pages/iou/SplitBillDetailsPage.tsx @@ -5,7 +5,7 @@ import {withOnyx} from 'react-native-onyx'; import type {OnyxEntry} from 'react-native-onyx'; import FullPageNotFoundView from '@components/BlockingViews/FullPageNotFoundView'; import HeaderWithBackButton from '@components/HeaderWithBackButton'; -import MoneyRequestConfirmationList from '@components/MoneyTemporaryForRefactorRequestConfirmationList'; +import MoneyRequestConfirmationList from '@components/MoneyRequestConfirmationList'; import MoneyRequestHeaderStatusBar from '@components/MoneyRequestHeaderStatusBar'; import ScreenWrapper from '@components/ScreenWrapper'; import useLocalize from '@hooks/useLocalize'; diff --git a/src/pages/iou/request/step/IOURequestStepConfirmation.tsx b/src/pages/iou/request/step/IOURequestStepConfirmation.tsx index 83f831708799..c45e05fb5ed3 100644 --- a/src/pages/iou/request/step/IOURequestStepConfirmation.tsx +++ b/src/pages/iou/request/step/IOURequestStepConfirmation.tsx @@ -5,7 +5,7 @@ import {withOnyx} from 'react-native-onyx'; import FullScreenLoadingIndicator from '@components/FullscreenLoadingIndicator'; import HeaderWithBackButton from '@components/HeaderWithBackButton'; import * as Expensicons from '@components/Icon/Expensicons'; -import MoneyRequestConfirmationList from '@components/MoneyTemporaryForRefactorRequestConfirmationList'; +import MoneyRequestConfirmationList from '@components/MoneyRequestConfirmationList'; import {usePersonalDetails} from '@components/OnyxProvider'; import ScreenWrapper from '@components/ScreenWrapper'; import useCurrentUserPersonalDetails from '@hooks/useCurrentUserPersonalDetails'; From 71b2bb91cfc3ccf56ea2274637373a527bb8ecf4 Mon Sep 17 00:00:00 2001 From: Bernhard Owen Josephus <bernhard.josephus@gmail.com> Date: Fri, 12 Apr 2024 22:43:13 +0800 Subject: [PATCH 093/206] fix here is your magic code shows briefly --- src/pages/ValidateLoginPage/index.website.tsx | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/pages/ValidateLoginPage/index.website.tsx b/src/pages/ValidateLoginPage/index.website.tsx index b8e8709215e8..9fb97aa46529 100644 --- a/src/pages/ValidateLoginPage/index.website.tsx +++ b/src/pages/ValidateLoginPage/index.website.tsx @@ -24,9 +24,11 @@ function ValidateLoginPage({ const isSignedIn = !!session?.authToken && session?.authTokenType !== CONST.AUTH_TOKEN_TYPES.ANONYMOUS; const is2FARequired = !!account?.requiresTwoFactorAuth; const cachedAccountID = credentials?.accountID; + const isUserClickedSignIn = !login && isSignedIn && (autoAuthState === CONST.AUTO_AUTH_STATE.SIGNING_IN || autoAuthState === CONST.AUTO_AUTH_STATE.JUST_SIGNED_IN); + const shouldStartSignInWithValidateCode = !isUserClickedSignIn && !isSignedIn && (login || exitTo); useEffect(() => { - if (!login && isSignedIn && (autoAuthState === CONST.AUTO_AUTH_STATE.SIGNING_IN || autoAuthState === CONST.AUTO_AUTH_STATE.JUST_SIGNED_IN)) { + if (isUserClickedSignIn) { // The user clicked the option to sign in the current tab Navigation.isNavigationReady().then(() => { Navigation.goBack(); @@ -35,7 +37,7 @@ function ValidateLoginPage({ } Session.initAutoAuthState(autoAuthState); - if (isSignedIn || (!login && !exitTo)) { + if (!shouldStartSignInWithValidateCode) { if (exitTo) { Session.handleExitToNavigation(exitTo); } @@ -71,13 +73,13 @@ function ValidateLoginPage({ {autoAuthState === CONST.AUTO_AUTH_STATE.FAILED && <ExpiredValidateCodeModal />} {autoAuthState === CONST.AUTO_AUTH_STATE.JUST_SIGNED_IN && is2FARequired && !isSignedIn && <JustSignedInModal is2FARequired />} {autoAuthState === CONST.AUTO_AUTH_STATE.JUST_SIGNED_IN && isSignedIn && !exitTo && <JustSignedInModal is2FARequired={false} />} - {autoAuthState === CONST.AUTO_AUTH_STATE.NOT_STARTED && !exitTo && ( + {autoAuthState === CONST.AUTO_AUTH_STATE.NOT_STARTED && !exitTo && !shouldStartSignInWithValidateCode && ( <ValidateCodeModal accountID={Number(accountID)} code={validateCode} /> )} - {autoAuthState === CONST.AUTO_AUTH_STATE.SIGNING_IN && <FullScreenLoadingIndicator />} + {(autoAuthState === CONST.AUTO_AUTH_STATE.SIGNING_IN || shouldStartSignInWithValidateCode) && <FullScreenLoadingIndicator />} </> ); } From bdeeb5a908c8ad0ab74fcc0b1718acdd8c327eed Mon Sep 17 00:00:00 2001 From: Bernhard Owen Josephus <bernhard.josephus@gmail.com> Date: Fri, 12 Apr 2024 23:00:50 +0800 Subject: [PATCH 094/206] lint --- src/pages/ValidateLoginPage/index.website.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pages/ValidateLoginPage/index.website.tsx b/src/pages/ValidateLoginPage/index.website.tsx index 9fb97aa46529..035ad1492f01 100644 --- a/src/pages/ValidateLoginPage/index.website.tsx +++ b/src/pages/ValidateLoginPage/index.website.tsx @@ -25,7 +25,7 @@ function ValidateLoginPage({ const is2FARequired = !!account?.requiresTwoFactorAuth; const cachedAccountID = credentials?.accountID; const isUserClickedSignIn = !login && isSignedIn && (autoAuthState === CONST.AUTO_AUTH_STATE.SIGNING_IN || autoAuthState === CONST.AUTO_AUTH_STATE.JUST_SIGNED_IN); - const shouldStartSignInWithValidateCode = !isUserClickedSignIn && !isSignedIn && (login || exitTo); + const shouldStartSignInWithValidateCode = !isUserClickedSignIn && !isSignedIn && (!!login || !!exitTo); useEffect(() => { if (isUserClickedSignIn) { From 5f09ff18cb053ca4daa22104abc11e14f6317600 Mon Sep 17 00:00:00 2001 From: Kevin Brian Bader <kevin.bader96@gmail.com> Date: Sat, 13 Apr 2024 00:59:40 +0300 Subject: [PATCH 095/206] Workspace switcher: Expensify is no longer bolded and missing RBR after refreshing the page --- src/libs/WorkspacesSettingsUtils.ts | 31 +++++++++++++++++++---------- src/pages/WorkspaceSwitcherPage.tsx | 29 ++++++++++----------------- 2 files changed, 31 insertions(+), 29 deletions(-) diff --git a/src/libs/WorkspacesSettingsUtils.ts b/src/libs/WorkspacesSettingsUtils.ts index 995bcba06a5c..17a7d65bd19c 100644 --- a/src/libs/WorkspacesSettingsUtils.ts +++ b/src/libs/WorkspacesSettingsUtils.ts @@ -6,6 +6,7 @@ import type {TranslationPaths} from '@src/languages/types'; import ONYXKEYS from '@src/ONYXKEYS'; import type {Policy, PolicyMembers, ReimbursementAccount, Report, ReportActions} from '@src/types/onyx'; import type {Unit} from '@src/types/onyx/Policy'; +import {isEmptyObject} from '@src/types/utils/EmptyObject'; import * as CollectionUtils from './CollectionUtils'; import * as CurrencyUtils from './CurrencyUtils'; import type {Phrase, PhraseParameters} from './Localize'; @@ -69,8 +70,8 @@ Onyx.connect({ * @param report * @returns BrickRoad for the policy passed as a param */ -const getBrickRoadForPolicy = (report: Report): BrickRoad => { - const reportActions = reportActionsByReport?.[report.reportID] ?? {}; +const getBrickRoadForPolicy = (report: Report, actionsByReport?: OnyxCollection<ReportActions>): BrickRoad => { + const reportActions = (isEmptyObject(actionsByReport) ? reportActionsByReport : actionsByReport)?.[report.reportID] ?? {}; const reportErrors = OptionsListUtils.getAllReportErrors(report, reportActions); const doesReportContainErrors = Object.keys(reportErrors ?? {}).length !== 0 ? CONST.BRICK_ROAD_INDICATOR_STATUS.ERROR : undefined; if (doesReportContainErrors) { @@ -157,14 +158,14 @@ function checkIfWorkspaceSettingsTabHasRBR(policyID?: string) { /** * @returns a map where the keys are policyIDs and the values are BrickRoads for each policy */ -function getWorkspacesBrickRoads(): Record<string, BrickRoad> { - if (!allReports) { +function getWorkspacesBrickRoads(reports: OnyxCollection<Report>, policies: OnyxCollection<Policy>, reportActions?: OnyxCollection<ReportActions>): Record<string, BrickRoad> { + if (!reports) { return {}; } // The key in this map is the workspace id const workspacesBrickRoadsMap: Record<string, BrickRoad> = {}; - Object.values(allPolicies ?? {}).forEach((policy) => { + Object.values(policies ?? {}).forEach((policy) => { // Only policies which user has access to on the list should be checked. Policies that don't have an ID and contain only information about the errors aren't displayed anywhere. if (!policy?.id) { return; @@ -175,12 +176,22 @@ function getWorkspacesBrickRoads(): Record<string, BrickRoad> { } }); - Object.values(allReports).forEach((report) => { + const actionsByReport: OnyxCollection<ReportActions> = {}; + Object.keys(reportActions ?? {}).forEach((key) => { + if (!reportActions) { + return; + } + + const reportID = CollectionUtils.extractCollectionItemID(key as typeof ONYXKEYS.COLLECTION.REPORT_ACTIONS); + actionsByReport[reportID] = reportActions[key]; + }); + + Object.values(reports).forEach((report) => { const policyID = report?.policyID ?? CONST.POLICY.EMPTY; if (!report || workspacesBrickRoadsMap[policyID] === CONST.BRICK_ROAD_INDICATOR_STATUS.ERROR) { return; } - const workspaceBrickRoad = getBrickRoadForPolicy(report); + const workspaceBrickRoad = getBrickRoadForPolicy(report, actionsByReport); if (!workspaceBrickRoad && !!workspacesBrickRoadsMap[policyID]) { return; @@ -195,14 +206,14 @@ function getWorkspacesBrickRoads(): Record<string, BrickRoad> { /** * @returns a map where the keys are policyIDs and the values are truthy booleans if policy has unread content */ -function getWorkspacesUnreadStatuses(): Record<string, boolean> { - if (!allReports) { +function getWorkspacesUnreadStatuses(reports: OnyxCollection<Report>): Record<string, boolean> { + if (!reports) { return {}; } const workspacesUnreadStatuses: Record<string, boolean> = {}; - Object.values(allReports).forEach((report) => { + Object.values(reports).forEach((report) => { const policyID = report?.policyID; if (!policyID || workspacesUnreadStatuses[policyID]) { return; diff --git a/src/pages/WorkspaceSwitcherPage.tsx b/src/pages/WorkspaceSwitcherPage.tsx index f1a439548f1b..5e659375c67e 100644 --- a/src/pages/WorkspaceSwitcherPage.tsx +++ b/src/pages/WorkspaceSwitcherPage.tsx @@ -1,7 +1,6 @@ import React, {useCallback, useMemo, useState} from 'react'; import {View} from 'react-native'; -import type {OnyxCollection} from 'react-native-onyx'; -import {withOnyx} from 'react-native-onyx'; +import {useOnyx} from 'react-native-onyx'; import HeaderWithBackButton from '@components/HeaderWithBackButton'; import Icon from '@components/Icon'; import * as Expensicons from '@components/Icon/Expensicons'; @@ -27,7 +26,6 @@ import {getWorkspacesBrickRoads, getWorkspacesUnreadStatuses} from '@libs/Worksp import * as App from '@userActions/App'; import CONST from '@src/CONST'; import ONYXKEYS from '@src/ONYXKEYS'; -import type {Policy} from '@src/types/onyx'; import {isEmptyObject} from '@src/types/utils/EmptyObject'; import WorkspaceCardCreateAWorkspace from './workspace/card/WorkspaceCardCreateAWorkspace'; @@ -47,14 +45,7 @@ const sortWorkspacesBySelected = (workspace1: SimpleWorkspaceItem, workspace2: S return workspace1.text?.toLowerCase().localeCompare(workspace2.text?.toLowerCase() ?? '') ?? 0; }; -type WorkspaceSwitcherPageOnyxProps = { - /** The list of this user's policies */ - policies: OnyxCollection<Policy>; -}; - -type WorkspaceSwitcherPageProps = WorkspaceSwitcherPageOnyxProps; - -function WorkspaceSwitcherPage({policies}: WorkspaceSwitcherPageProps) { +function WorkspaceSwitcherPage() { const theme = useTheme(); const styles = useThemeStyles(); const {isOffline} = useNetwork(); @@ -63,8 +54,12 @@ function WorkspaceSwitcherPage({policies}: WorkspaceSwitcherPageProps) { const {translate} = useLocalize(); const {activeWorkspaceID, setActiveWorkspaceID} = useActiveWorkspace(); - const brickRoadsForPolicies = useMemo(() => getWorkspacesBrickRoads(), []); - const unreadStatusesForPolicies = useMemo(() => getWorkspacesUnreadStatuses(), []); + const [reports] = useOnyx(ONYXKEYS.COLLECTION.REPORT); + const [reportActions] = useOnyx(ONYXKEYS.COLLECTION.REPORT_ACTIONS); + const [policies] = useOnyx(ONYXKEYS.COLLECTION.POLICY); + + const brickRoadsForPolicies = useMemo(() => getWorkspacesBrickRoads(reports, policies, reportActions), [reports, policies, reportActions]); + const unreadStatusesForPolicies = useMemo(() => getWorkspacesUnreadStatuses(reports), [reports]); const getIndicatorTypeForPolicy = useCallback( (policyId?: string) => { @@ -135,7 +130,7 @@ function WorkspaceSwitcherPage({policies}: WorkspaceSwitcherPageProps) { type: CONST.ICON_TYPE_WORKSPACE, }, ], - boldStyle: hasUnreadData(policy?.id), + isBold: hasUnreadData(policy?.id), keyForList: policy?.id, isPolicyAdmin: PolicyUtils.isPolicyAdmin(policy), isSelected: policy?.id === activeWorkspaceID, @@ -284,8 +279,4 @@ function WorkspaceSwitcherPage({policies}: WorkspaceSwitcherPageProps) { WorkspaceSwitcherPage.displayName = 'WorkspaceSwitcherPage'; -export default withOnyx<WorkspaceSwitcherPageProps, WorkspaceSwitcherPageOnyxProps>({ - policies: { - key: ONYXKEYS.COLLECTION.POLICY, - }, -})(WorkspaceSwitcherPage); +export default WorkspaceSwitcherPage; From fc00866d54a65ba7496d1e799d18ecbfa91e2cdc Mon Sep 17 00:00:00 2001 From: brunovjk <brunovjk@gmail.com> Date: Sat, 13 Apr 2024 08:59:20 -0300 Subject: [PATCH 096/206] fix lint --- src/components/MoneyRequestConfirmationList.tsx | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/src/components/MoneyRequestConfirmationList.tsx b/src/components/MoneyRequestConfirmationList.tsx index 8d2f878244bd..6e0de099b847 100755 --- a/src/components/MoneyRequestConfirmationList.tsx +++ b/src/components/MoneyRequestConfirmationList.tsx @@ -260,10 +260,7 @@ function MoneyRequestConfirmationList({ const formattedTaxAmount = CurrencyUtils.convertToDisplayString(transaction?.taxAmount, iouCurrencyCode); const taxRateTitle = taxRates && transaction ? TransactionUtils.getDefaultTaxName(taxRates, transaction) : ''; - const defaultTaxKey = taxRates?.defaultExternalID; - const defaultTaxName = (defaultTaxKey && `${taxRates.taxes[defaultTaxKey].name} (${taxRates.taxes[defaultTaxKey].value}) ${CONST.DOT_SEPARATOR} ${translate('common.default')}`) ?? ''; - // eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing -- nullish coalescing is not working when a left hand side value is '' - const taxRateTitle = transaction?.taxRate?.text || defaultTaxName; + const previousTransactionAmount = usePrevious(transaction?.amount); const isFocused = useIsFocused(); const [formError, setFormError] = useState(''); From 0fdc7cd65e8a3d96590e25ae4a2d59706b43b059 Mon Sep 17 00:00:00 2001 From: Shahe Shahinyan <shahe.shahinyan@gmail.com> Date: Sun, 14 Apr 2024 16:10:40 +0400 Subject: [PATCH 097/206] Update report actions in CONST.ts to use underscores --- src/CONST.ts | 76 +++++++-------- src/libs/ModifiedExpenseMessage.ts | 2 +- src/libs/OptionsListUtils.ts | 2 +- src/libs/ReportActionsUtils.ts | 94 +++++++++---------- src/libs/ReportUtils.ts | 42 ++++----- src/libs/SidebarUtils.ts | 12 +-- src/libs/TaskUtils.ts | 8 +- src/libs/actions/IOU.ts | 8 +- src/libs/actions/Report.ts | 2 +- src/libs/actions/Task.ts | 6 +- src/libs/actions/User.ts | 2 +- .../report/ContextMenu/ContextMenuActions.tsx | 2 +- src/pages/home/report/ReportActionItem.tsx | 16 ++-- .../home/report/ReportActionItemFragment.tsx | 4 +- .../home/report/ReportActionItemSingle.tsx | 2 +- src/pages/home/report/ReportActionsList.tsx | 2 +- .../report/ReportActionsListItemRenderer.tsx | 2 +- src/pages/home/report/ReportActionsView.tsx | 8 +- .../home/report/reportActionPropTypes.js | 2 +- src/types/onyx/OriginalMessage.ts | 56 +++++------ 20 files changed, 174 insertions(+), 174 deletions(-) diff --git a/src/CONST.ts b/src/CONST.ts index b7e90b070066..eb71cba16382 100755 --- a/src/CONST.ts +++ b/src/CONST.ts @@ -633,58 +633,58 @@ const CONST = { LIMIT: 50, // OldDot Actions render getMessage from Web-Expensify/lib/Report/Action PHP files via getMessageOfOldDotReportAction in ReportActionsUtils.ts TYPE: { - ACTIONABLEMENTIONWHISPER: 'ACTIONABLEMENTIONWHISPER', - ADDCOMMENT: 'ADDCOMMENT', - ACTIONABLEJOINREQUEST: 'ACTIONABLEJOINREQUEST', + ACTIONABLE_MENTION_WHISPER: 'ACTIONABLE_MENTION_WHISPER', + ADD_COMMENT: 'ADD_COMMENT', + ACTIONABLE_JOIN_REQUEST: 'ACTIONABLE_JOIN_REQUEST', APPROVED: 'APPROVED', - CHANGEFIELD: 'CHANGEFIELD', // OldDot Action - CHANGEPOLICY: 'CHANGEPOLICY', // OldDot Action - CHANGETYPE: 'CHANGETYPE', // OldDot Action - CHRONOSOOOLIST: 'CHRONOSOOOLIST', + CHANGE_FIELD: 'CHANGE_FIELD', // OldDot Action + CHANGE_POLICY: 'CHANGE_POLICY', // OldDot Action + CHANGE_TYPE: 'CHANGE_TYPE', // OldDot Action + CHRONOSOOLIST: 'CHRONOSOOLIST', CLOSED: 'CLOSED', CREATED: 'CREATED', - DELEGATESUBMIT: 'DELEGATESUBMIT', // OldDot Action - DELETEDACCOUNT: 'DELETEDACCOUNT', // OldDot Action + DELEGATE_SUBMIT: 'DELEGATE_SUBMIT', // OldDot Action + DELETED_ACCOUNT: 'DELETED_ACCOUNT', // OldDot Action DONATION: 'DONATION', // OldDot Action - EXPORTEDTOCSV: 'EXPORTEDTOCSV', // OldDot Action - EXPORTEDTOINTEGRATION: 'EXPORTEDTOINTEGRATION', // OldDot Action - EXPORTEDTOQUICKBOOKS: 'EXPORTEDTOQUICKBOOKS', // OldDot Action + EXPORTED_TO_CSV: 'EXPORTED_TO_CSV', // OldDot Action + EXPORTED_TO_INTEGRATION: 'EXPORTED_TO_INTEGRATION', // OldDot Action + EXPORTED_TO_QUICK_BOOKS: 'EXPORTED_TO_QUICK_BOOKS', // OldDot Action FORWARDED: 'FORWARDED', // OldDot Action HOLD: 'HOLD', - HOLDCOMMENT: 'HOLDCOMMENT', + HOLD_COMMENT: 'HOLD_COMMENT', IOU: 'IOU', - INTEGRATIONSMESSAGE: 'INTEGRATIONSMESSAGE', // OldDot Action - MANAGERATTACHRECEIPT: 'MANAGERATTACHRECEIPT', // OldDot Action - MANAGERDETACHRECEIPT: 'MANAGERDETACHRECEIPT', // OldDot Action - MARKEDREIMBURSED: 'MARKEDREIMBURSED', // OldDot Action - MARKREIMBURSEDFROMINTEGRATION: 'MARKREIMBURSEDFROMINTEGRATION', // OldDot Action - MODIFIEDEXPENSE: 'MODIFIEDEXPENSE', + INTEGRATIONS_MESSAGE: 'INTEGRATIONS_MESSAGE', // OldDot Action + MANAGER_ATTACH_RECEIPT: 'MANAGER_ATTACH_RECEIPT', // OldDot Action + MANAGER_DETACH_RECEIPT: 'MANAGER_DETACH_RECEIPT', // OldDot Action + MARKED_REIMBURSED: 'MARKED_REIMBURSED', // OldDot Action + MARK_REIMBURSED_FROM_INTEGRATION: 'MARK_REIMBURSED_FROM_INTEGRATION', // OldDot Action + MODIFIED_EXPENSE: 'MODIFIED_EXPENSE', MOVED: 'MOVED', - OUTDATEDBANKACCOUNT: 'OUTDATEDBANKACCOUNT', // OldDot Action - REIMBURSEMENTACHBOUNCE: 'REIMBURSEMENTACHBOUNCE', // OldDot Action - REIMBURSEMENTACHCANCELLED: 'REIMBURSEMENTACHCANCELLED', // OldDot Action - REIMBURSEMENTACCOUNTCHANGED: 'REIMBURSEMENTACCOUNTCHANGED', // OldDot Action - REIMBURSEMENTDELAYED: 'REIMBURSEMENTDELAYED', // OldDot Action - REIMBURSEMENTQUEUED: 'REIMBURSEMENTQUEUED', - REIMBURSEMENTDEQUEUED: 'REIMBURSEMENTDEQUEUED', - REIMBURSEMENTREQUESTED: 'REIMBURSEMENTREQUESTED', // OldDot Action - REIMBURSEMENTSETUP: 'REIMBURSEMENTSETUP', // OldDot Action + OUTDATED_BANK_ACCOUNT: 'OUTDATED_BANK_ACCOUNT', // OldDot Action + REIMBURSEMENTACH_BOUNCE: 'REIMBURSEMENTACH_BOUNCE', // OldDot Action + REIMBURSEMENTACH_CANCELLED: 'REIMBURSEMENTACH_CANCELLED', // OldDot Action + REIMBURSEMENT_ACCOUNT_CHANGED: 'REIMBURSEMENT_ACCOUNT_CHANGED', // OldDot Action + REIMBURSEMENT_DELAYED: 'REIMBURSEMENT_DELAYED', // OldDot Action + REIMBURSEMENT_QUEUED: 'REIMBURSEMENT_QUEUED', + REIMBURSEMENT_DEQUEUED: 'REIMBURSEMENT_DEQUEUED', + REIMBURSEMENT_REQUESTED: 'REIMBURSEMENT_REQUESTED', // OldDot Action + REIMBURSEMENT_SETUP: 'REIMBURSEMENT_SETUP', // OldDot Action RENAMED: 'RENAMED', - REPORTPREVIEW: 'REPORTPREVIEW', - SELECTEDFORRANDOMAUDIT: 'SELECTEDFORRANDOMAUDIT', // OldDot Action + REPORT_PREVIEW: 'REPORT_PREVIEW', + SELECTED_FOR_RANDOM_AUDIT: 'SELECTED_FOR_RANDOM_AUDIT', // OldDot Action SHARE: 'SHARE', // OldDot Action - STRIPEPAID: 'STRIPEPAID', // OldDot Action + STRIPE_PAID: 'STRIPE_PAID', // OldDot Action SUBMITTED: 'SUBMITTED', - TAKECONTROL: 'TAKECONTROL', // OldDot Action - TASKCANCELLED: 'TASKCANCELLED', - TASKCOMPLETED: 'TASKCOMPLETED', - TASKEDITED: 'TASKEDITED', - TASKREOPENED: 'TASKREOPENED', + TAKE_CONTROL: 'TAKE_CONTROL', // OldDot Action + TASK_CANCELLED: 'TASK_CANCELLED', + TASK_COMPLETED: 'TASK_COMPLETED', + TASK_EDITED: 'TASK_EDITED', + TASK_REOPENED: 'TASK_REOPENED', UNAPPROVED: 'UNAPPROVED', // OldDot Action UNHOLD: 'UNHOLD', UNSHARE: 'UNSHARE', // OldDot Action - UPDATEGROUPCHATMEMBERROLE: 'UPDATEGROUPCHATMEMBERROLE', - POLICYCHANGELOG: { + UPDATE_GROUP_CHAT_MEMBER_ROLE: 'UPDATE_GROUP_CHAT_MEMBER_ROLE', + POLICY_CHANGE_LOG: { ADD_APPROVER_RULE: 'POLICYCHANGELOG_ADD_APPROVER_RULE', ADD_BUDGET: 'POLICYCHANGELOG_ADD_BUDGET', ADD_CATEGORY: 'POLICYCHANGELOG_ADD_CATEGORY', diff --git a/src/libs/ModifiedExpenseMessage.ts b/src/libs/ModifiedExpenseMessage.ts index 0d961ea27115..77693b5e7ebe 100644 --- a/src/libs/ModifiedExpenseMessage.ts +++ b/src/libs/ModifiedExpenseMessage.ts @@ -106,7 +106,7 @@ function getForDistanceRequest(newDistance: string, oldDistance: string, newAmou * If we change this function be sure to update the backend as well. */ function getForReportAction(reportID: string | undefined, reportAction: OnyxEntry<ReportAction> | ReportAction | Record<string, never>): string { - if (reportAction?.actionName !== CONST.REPORT.ACTIONS.TYPE.MODIFIEDEXPENSE) { + if (reportAction?.actionName !== CONST.REPORT.ACTIONS.TYPE.MODIFIED_EXPENSE) { return ''; } const reportActionOriginalMessage = reportAction?.originalMessage as ExpenseOriginalMessage | undefined; diff --git a/src/libs/OptionsListUtils.ts b/src/libs/OptionsListUtils.ts index b2e243053bbc..730ab5f24c02 100644 --- a/src/libs/OptionsListUtils.ts +++ b/src/libs/OptionsListUtils.ts @@ -721,7 +721,7 @@ function createOption( let lastMessageText = lastMessageTextFromReport; const lastAction = visibleReportActionItems[report.reportID]; - const shouldDisplayLastActorName = lastAction && lastAction.actionName !== CONST.REPORT.ACTIONS.TYPE.REPORTPREVIEW && lastAction.actionName !== CONST.REPORT.ACTIONS.TYPE.IOU; + const shouldDisplayLastActorName = lastAction && lastAction.actionName !== CONST.REPORT.ACTIONS.TYPE.REPORT_PREVIEW && lastAction.actionName !== CONST.REPORT.ACTIONS.TYPE.IOU; if (shouldDisplayLastActorName && lastActorDisplayName && lastMessageTextFromReport) { lastMessageText = `${lastActorDisplayName}: ${lastMessageTextFromReport}`; diff --git a/src/libs/ReportActionsUtils.ts b/src/libs/ReportActionsUtils.ts index 20d5ab0905e7..fef755acbe72 100644 --- a/src/libs/ReportActionsUtils.ts +++ b/src/libs/ReportActionsUtils.ts @@ -48,7 +48,7 @@ type MemberChangeMessageRoomReferenceElement = { type MemberChangeMessageElement = MessageTextElement | MemberChangeMessageUserMentionElement | MemberChangeMessageRoomReferenceElement; -const policyChangeActionsSet = new Set<string>(Object.values(CONST.REPORT.ACTIONS.TYPE.POLICYCHANGELOG)); +const policyChangeActionsSet = new Set<string>(Object.values(CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG)); let allReports: OnyxCollection<Report> = {}; Onyx.connect({ @@ -127,7 +127,7 @@ function isMoneyRequestAction(reportAction: OnyxEntry<ReportAction>): reportActi } function isReportPreviewAction(reportAction: OnyxEntry<ReportAction>): boolean { - return reportAction?.actionName === CONST.REPORT.ACTIONS.TYPE.REPORTPREVIEW; + return reportAction?.actionName === CONST.REPORT.ACTIONS.TYPE.REPORT_PREVIEW; } function isReportActionSubmitted(reportAction: OnyxEntry<ReportAction>): boolean { @@ -135,7 +135,7 @@ function isReportActionSubmitted(reportAction: OnyxEntry<ReportAction>): boolean } function isModifiedExpenseAction(reportAction: OnyxEntry<ReportAction> | ReportAction | Record<string, never>): boolean { - return reportAction?.actionName === CONST.REPORT.ACTIONS.TYPE.MODIFIEDEXPENSE; + return reportAction?.actionName === CONST.REPORT.ACTIONS.TYPE.MODIFIED_EXPENSE; } function isWhisperAction(reportAction: OnyxEntry<ReportAction> | EmptyObject): boolean { @@ -153,24 +153,24 @@ function isWhisperActionTargetedToOthers(reportAction: OnyxEntry<ReportAction>): } function isReimbursementQueuedAction(reportAction: OnyxEntry<ReportAction>) { - return reportAction?.actionName === CONST.REPORT.ACTIONS.TYPE.REIMBURSEMENTQUEUED; + return reportAction?.actionName === CONST.REPORT.ACTIONS.TYPE.REIMBURSEMENT_QUEUED; } function isMemberChangeAction(reportAction: OnyxEntry<ReportAction>) { return ( reportAction?.actionName === CONST.REPORT.ACTIONS.TYPE.ROOMCHANGELOG.INVITE_TO_ROOM || reportAction?.actionName === CONST.REPORT.ACTIONS.TYPE.ROOMCHANGELOG.REMOVE_FROM_ROOM || - reportAction?.actionName === CONST.REPORT.ACTIONS.TYPE.POLICYCHANGELOG.INVITE_TO_ROOM || - reportAction?.actionName === CONST.REPORT.ACTIONS.TYPE.POLICYCHANGELOG.REMOVE_FROM_ROOM + reportAction?.actionName === CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.INVITE_TO_ROOM || + reportAction?.actionName === CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.REMOVE_FROM_ROOM ); } function isInviteMemberAction(reportAction: OnyxEntry<ReportAction>) { - return reportAction?.actionName === CONST.REPORT.ACTIONS.TYPE.ROOMCHANGELOG.INVITE_TO_ROOM || reportAction?.actionName === CONST.REPORT.ACTIONS.TYPE.POLICYCHANGELOG.INVITE_TO_ROOM; + return reportAction?.actionName === CONST.REPORT.ACTIONS.TYPE.ROOMCHANGELOG.INVITE_TO_ROOM || reportAction?.actionName === CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.INVITE_TO_ROOM; } function isReimbursementDeQueuedAction(reportAction: OnyxEntry<ReportAction>): reportAction is ReportActionBase & OriginalMessageReimbursementDequeued { - return reportAction?.actionName === CONST.REPORT.ACTIONS.TYPE.REIMBURSEMENTDEQUEUED; + return reportAction?.actionName === CONST.REPORT.ACTIONS.TYPE.REIMBURSEMENT_DEQUEUED; } /** @@ -279,9 +279,9 @@ function getSortedReportActions(reportActions: ReportAction[] | null, shouldSort if ((first.actionName === CONST.REPORT.ACTIONS.TYPE.CREATED || second.actionName === CONST.REPORT.ACTIONS.TYPE.CREATED) && first.actionName !== second.actionName) { return (first.actionName === CONST.REPORT.ACTIONS.TYPE.CREATED ? -1 : 1) * invertedMultiplier; } - // Ensure that `REPORTPREVIEW` actions always come after if they have the same timestamp as another action type - if ((first.actionName === CONST.REPORT.ACTIONS.TYPE.REPORTPREVIEW || second.actionName === CONST.REPORT.ACTIONS.TYPE.REPORTPREVIEW) && first.actionName !== second.actionName) { - return (first.actionName === CONST.REPORT.ACTIONS.TYPE.REPORTPREVIEW ? 1 : -1) * invertedMultiplier; + // Ensure that `REPORT_PREVIEW` actions always come after if they have the same timestamp as another action type + if ((first.actionName === CONST.REPORT.ACTIONS.TYPE.REPORT_PREVIEW || second.actionName === CONST.REPORT.ACTIONS.TYPE.REPORT_PREVIEW) && first.actionName !== second.actionName) { + return (first.actionName === CONST.REPORT.ACTIONS.TYPE.REPORT_PREVIEW ? 1 : -1) * invertedMultiplier; } // Then fallback on reportActionID as the final sorting criteria. It is a random number, @@ -487,7 +487,7 @@ function isReportActionDeprecated(reportAction: OnyxEntry<ReportAction>, key: st return false; } -const {POLICYCHANGELOG: policyChangelogTypes, ROOMCHANGELOG: roomChangeLogTypes, ...otherActionTypes} = CONST.REPORT.ACTIONS.TYPE; +const {POLICY_CHANGE_LOG: policyChangelogTypes, ROOMCHANGELOG: roomChangeLogTypes, ...otherActionTypes} = CONST.REPORT.ACTIONS.TYPE; const supportedActionTypes: ActionName[] = [...Object.values(otherActionTypes), ...Object.values(policyChangelogTypes), ...Object.values(roomChangeLogTypes)]; /** @@ -515,7 +515,7 @@ function shouldReportActionBeVisible(reportAction: OnyxEntry<ReportAction>, key: // Ignore markedAsReimbursed action here since we're already display message that explains the request was paid // elsewhere in the IOU reportAction - if (reportAction.actionName === CONST.REPORT.ACTIONS.TYPE.MARKEDREIMBURSED) { + if (reportAction.actionName === CONST.REPORT.ACTIONS.TYPE.MARKED_REIMBURSED) { return false; } @@ -556,7 +556,7 @@ function shouldReportActionBeVisibleAsLastAction(reportAction: OnyxEntry<ReportA return false; } - // If a whisper action is the REPORTPREVIEW action, we are displaying it. + // If a whisper action is the REPORT_PREVIEW action, we are displaying it. // If the action's message text is empty and it is not a deleted parent with visible child actions, hide it. Else, consider the action to be displayable. return ( shouldReportActionBeVisible(reportAction, reportAction.reportActionID) && @@ -765,7 +765,7 @@ function getMostRecentReportActionLastModified(): string { function getReportPreviewAction(chatReportID: string, iouReportID: string): OnyxEntry<ReportAction> { return ( Object.values(allReportActions?.[chatReportID] ?? {}).find( - (reportAction) => reportAction && reportAction.actionName === CONST.REPORT.ACTIONS.TYPE.REPORTPREVIEW && reportAction.originalMessage.linkedReportID === iouReportID, + (reportAction) => reportAction && reportAction.actionName === CONST.REPORT.ACTIONS.TYPE.REPORT_PREVIEW && reportAction.originalMessage.linkedReportID === iouReportID, ) ?? null ); } @@ -774,11 +774,11 @@ function getReportPreviewAction(chatReportID: string, iouReportID: string): Onyx * Get the iouReportID for a given report action. */ function getIOUReportIDFromReportActionPreview(reportAction: OnyxEntry<ReportAction>): string { - return reportAction?.actionName === CONST.REPORT.ACTIONS.TYPE.REPORTPREVIEW ? reportAction.originalMessage.linkedReportID : '0'; + return reportAction?.actionName === CONST.REPORT.ACTIONS.TYPE.REPORT_PREVIEW ? reportAction.originalMessage.linkedReportID : '0'; } function isCreatedTaskReportAction(reportAction: OnyxEntry<ReportAction>): boolean { - return reportAction?.actionName === CONST.REPORT.ACTIONS.TYPE.ADDCOMMENT && !!reportAction.originalMessage?.taskReportID; + return reportAction?.actionName === CONST.REPORT.ACTIONS.TYPE.ADD_COMMENT && !!reportAction.originalMessage?.taskReportID; } /** @@ -806,10 +806,10 @@ function isTrackExpenseAction(reportAction: OnyxEntry<ReportAction | OptimisticI function isTaskAction(reportAction: OnyxEntry<ReportAction>): boolean { const reportActionName = reportAction?.actionName; return ( - reportActionName === CONST.REPORT.ACTIONS.TYPE.TASKCOMPLETED || - reportActionName === CONST.REPORT.ACTIONS.TYPE.TASKCANCELLED || - reportActionName === CONST.REPORT.ACTIONS.TYPE.TASKREOPENED || - reportActionName === CONST.REPORT.ACTIONS.TYPE.TASKEDITED + reportActionName === CONST.REPORT.ACTIONS.TYPE.TASK_COMPLETED || + reportActionName === CONST.REPORT.ACTIONS.TYPE.TASK_CANCELLED || + reportActionName === CONST.REPORT.ACTIONS.TYPE.TASK_REOPENED || + reportActionName === CONST.REPORT.ACTIONS.TYPE.TASK_EDITED ); } @@ -854,7 +854,7 @@ function isNotifiableReportAction(reportAction: OnyxEntry<ReportAction>): boolea return false; } - const actions: ActionName[] = [CONST.REPORT.ACTIONS.TYPE.ADDCOMMENT, CONST.REPORT.ACTIONS.TYPE.IOU, CONST.REPORT.ACTIONS.TYPE.MODIFIEDEXPENSE]; + const actions: ActionName[] = [CONST.REPORT.ACTIONS.TYPE.ADD_COMMENT, CONST.REPORT.ACTIONS.TYPE.IOU, CONST.REPORT.ACTIONS.TYPE.MODIFIED_EXPENSE]; return actions.includes(reportAction.actionName); } @@ -939,32 +939,32 @@ function getMemberChangeMessageFragment(reportAction: OnyxEntry<ReportAction>): function isOldDotReportAction(action: ReportAction): boolean { return [ - CONST.REPORT.ACTIONS.TYPE.CHANGEFIELD, - CONST.REPORT.ACTIONS.TYPE.CHANGEPOLICY, - CONST.REPORT.ACTIONS.TYPE.CHANGETYPE, - CONST.REPORT.ACTIONS.TYPE.DELEGATESUBMIT, - CONST.REPORT.ACTIONS.TYPE.DELETEDACCOUNT, + CONST.REPORT.ACTIONS.TYPE.CHANGE_FIELD, + CONST.REPORT.ACTIONS.TYPE.CHANGE_POLICY, + CONST.REPORT.ACTIONS.TYPE.CHANGE_TYPE, + CONST.REPORT.ACTIONS.TYPE.DELEGATE_SUBMIT, + CONST.REPORT.ACTIONS.TYPE.DELETED_ACCOUNT, CONST.REPORT.ACTIONS.TYPE.DONATION, - CONST.REPORT.ACTIONS.TYPE.EXPORTEDTOCSV, - CONST.REPORT.ACTIONS.TYPE.EXPORTEDTOINTEGRATION, - CONST.REPORT.ACTIONS.TYPE.EXPORTEDTOQUICKBOOKS, + CONST.REPORT.ACTIONS.TYPE.EXPORTED_TO_CSV, + CONST.REPORT.ACTIONS.TYPE.EXPORTED_TO_INTEGRATION, + CONST.REPORT.ACTIONS.TYPE.EXPORTED_TO_QUICK_BOOKS, CONST.REPORT.ACTIONS.TYPE.FORWARDED, - CONST.REPORT.ACTIONS.TYPE.INTEGRATIONSMESSAGE, - CONST.REPORT.ACTIONS.TYPE.MANAGERATTACHRECEIPT, - CONST.REPORT.ACTIONS.TYPE.MANAGERDETACHRECEIPT, - CONST.REPORT.ACTIONS.TYPE.MARKEDREIMBURSED, - CONST.REPORT.ACTIONS.TYPE.MARKREIMBURSEDFROMINTEGRATION, - CONST.REPORT.ACTIONS.TYPE.OUTDATEDBANKACCOUNT, - CONST.REPORT.ACTIONS.TYPE.REIMBURSEMENTACHBOUNCE, - CONST.REPORT.ACTIONS.TYPE.REIMBURSEMENTACHCANCELLED, - CONST.REPORT.ACTIONS.TYPE.REIMBURSEMENTACCOUNTCHANGED, - CONST.REPORT.ACTIONS.TYPE.REIMBURSEMENTDELAYED, - CONST.REPORT.ACTIONS.TYPE.REIMBURSEMENTREQUESTED, - CONST.REPORT.ACTIONS.TYPE.REIMBURSEMENTSETUP, - CONST.REPORT.ACTIONS.TYPE.SELECTEDFORRANDOMAUDIT, + CONST.REPORT.ACTIONS.TYPE.INTEGRATIONS_MESSAGE, + CONST.REPORT.ACTIONS.TYPE.MANAGER_ATTACH_RECEIPT, + CONST.REPORT.ACTIONS.TYPE.MANAGER_DETACH_RECEIPT, + CONST.REPORT.ACTIONS.TYPE.MARKED_REIMBURSED, + CONST.REPORT.ACTIONS.TYPE.MARK_REIMBURSED_FROM_INTEGRATION, + CONST.REPORT.ACTIONS.TYPE.OUTDATED_BANK_ACCOUNT, + CONST.REPORT.ACTIONS.TYPE.REIMBURSEMENTACH_BOUNCE, + CONST.REPORT.ACTIONS.TYPE.REIMBURSEMENTACH_CANCELLED, + CONST.REPORT.ACTIONS.TYPE.REIMBURSEMENT_ACCOUNT_CHANGED, + CONST.REPORT.ACTIONS.TYPE.REIMBURSEMENT_DELAYED, + CONST.REPORT.ACTIONS.TYPE.REIMBURSEMENT_REQUESTED, + CONST.REPORT.ACTIONS.TYPE.REIMBURSEMENT_SETUP, + CONST.REPORT.ACTIONS.TYPE.SELECTED_FOR_RANDOM_AUDIT, CONST.REPORT.ACTIONS.TYPE.SHARE, - CONST.REPORT.ACTIONS.TYPE.STRIPEPAID, - CONST.REPORT.ACTIONS.TYPE.TAKECONTROL, + CONST.REPORT.ACTIONS.TYPE.STRIPE_PAID, + CONST.REPORT.ACTIONS.TYPE.TAKE_CONTROL, CONST.REPORT.ACTIONS.TYPE.UNAPPROVED, CONST.REPORT.ACTIONS.TYPE.UNSHARE, ].some((oldDotActionName) => oldDotActionName === action.actionName); @@ -1008,7 +1008,7 @@ function hasRequestFromCurrentAccount(reportID: string, currentAccountID: number * @param reportAction */ function isActionableMentionWhisper(reportAction: OnyxEntry<ReportAction>): reportAction is ReportActionBase & OriginalMessageActionableMentionWhisper { - return reportAction?.actionName === CONST.REPORT.ACTIONS.TYPE.ACTIONABLEMENTIONWHISPER; + return reportAction?.actionName === CONST.REPORT.ACTIONS.TYPE.ACTIONABLE_MENTION_WHISPER; } /** @@ -1064,7 +1064,7 @@ function isCurrentActionUnread(report: Report | EmptyObject, reportAction: Repor * @param reportAction */ function isActionableJoinRequest(reportAction: OnyxEntry<ReportAction>): boolean { - return reportAction?.actionName === CONST.REPORT.ACTIONS.TYPE.ACTIONABLEJOINREQUEST; + return reportAction?.actionName === CONST.REPORT.ACTIONS.TYPE.ACTIONABLE_JOIN_REQUEST; } /** diff --git a/src/libs/ReportUtils.ts b/src/libs/ReportUtils.ts index b03abbcdf9bb..8c3797dba8c1 100644 --- a/src/libs/ReportUtils.ts +++ b/src/libs/ReportUtils.ts @@ -1422,7 +1422,7 @@ function canAddOrDeleteTransactions(moneyRequestReport: OnyxEntry<Report>): bool } /** - * Can only delete if the author is this user and the action is an ADDCOMMENT action or an IOU action in an unsettled report, or if the user is a + * Can only delete if the author is this user and the action is an ADD_COMMENT action or an IOU action in an unsettled report, or if the user is a * policy admin */ function canDeleteReportAction(reportAction: OnyxEntry<ReportAction>, reportID: string): boolean { @@ -1448,7 +1448,7 @@ function canDeleteReportAction(reportAction: OnyxEntry<ReportAction>, reportID: } if ( - reportAction?.actionName !== CONST.REPORT.ACTIONS.TYPE.ADDCOMMENT || + reportAction?.actionName !== CONST.REPORT.ACTIONS.TYPE.ADD_COMMENT || reportAction?.pendingAction === CONST.RED_BRICK_ROAD_PENDING_ACTION.DELETE || ReportActionsUtils.isCreatedTaskReportAction(reportAction) || reportAction?.actorAccountID === CONST.ACCOUNT_ID.CONCIERGE @@ -2008,7 +2008,7 @@ function getDeletedParentActionMessageForChatReport(reportAction: OnyxEntry<Repo } /** - * Returns the preview message for `REIMBURSEMENTQUEUED` action + * Returns the preview message for `REIMBURSEMENT_QUEUED` action */ function getReimbursementQueuedActionMessage(reportAction: OnyxEntry<ReportAction>, report: OnyxEntry<Report>, shouldUseShortDisplayName = true): string { const submitterDisplayName = getDisplayNameForParticipant(report?.ownerAccountID, shouldUseShortDisplayName) ?? ''; @@ -2024,7 +2024,7 @@ function getReimbursementQueuedActionMessage(reportAction: OnyxEntry<ReportActio } /** - * Returns the preview message for `REIMBURSEMENTDEQUEUED` action + * Returns the preview message for `REIMBURSEMENT_DEQUEUED` action */ function getReimbursementDeQueuedActionMessage( reportAction: OnyxEntry<ReportActionBase & OriginalMessageReimbursementDequeued>, @@ -2044,12 +2044,12 @@ function getReimbursementDeQueuedActionMessage( } /** - * Builds an optimistic REIMBURSEMENTDEQUEUED report action with a randomly generated reportActionID. + * Builds an optimistic REIMBURSEMENT_DEQUEUED report action with a randomly generated reportActionID. * */ function buildOptimisticCancelPaymentReportAction(expenseReportID: string, amount: number, currency: string): OptimisticCancelPaymentReportAction { return { - actionName: CONST.REPORT.ACTIONS.TYPE.REIMBURSEMENTDEQUEUED, + actionName: CONST.REPORT.ACTIONS.TYPE.REIMBURSEMENT_DEQUEUED, actorAccountID: currentUserAccountID, message: [ { @@ -2532,12 +2532,12 @@ function canEditFieldOfMoneyRequest(reportAction: OnyxEntry<ReportAction>, field * Can only edit if: * * - It was written by the current user - * - It's an ADDCOMMENT that is not an attachment + * - It's an ADD_COMMENT that is not an attachment * - It's money request where conditions for editability are defined in canEditMoneyRequest method * - It's not pending deletion */ function canEditReportAction(reportAction: OnyxEntry<ReportAction>): boolean { - const isCommentOrIOU = reportAction?.actionName === CONST.REPORT.ACTIONS.TYPE.ADDCOMMENT || reportAction?.actionName === CONST.REPORT.ACTIONS.TYPE.IOU; + const isCommentOrIOU = reportAction?.actionName === CONST.REPORT.ACTIONS.TYPE.ADD_COMMENT || reportAction?.actionName === CONST.REPORT.ACTIONS.TYPE.IOU; return Boolean( reportAction?.actorAccountID === currentUserAccountID && @@ -2912,7 +2912,7 @@ function getAdminRoomInvitedParticipants(parentReportAction: ReportAction | Reco return parentReportActionMessage; } const actionType = parentReportAction.actionName; - const isInviteAction = actionType === CONST.REPORT.ACTIONS.TYPE.ROOMCHANGELOG.INVITE_TO_ROOM || actionType === CONST.REPORT.ACTIONS.TYPE.POLICYCHANGELOG.INVITE_TO_ROOM; + const isInviteAction = actionType === CONST.REPORT.ACTIONS.TYPE.ROOMCHANGELOG.INVITE_TO_ROOM || actionType === CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.INVITE_TO_ROOM; const verbKey = isInviteAction ? 'workspace.invite.invited' : 'workspace.invite.removed'; const prepositionKey = isInviteAction ? 'workspace.invite.to' : 'workspace.invite.from'; @@ -3181,7 +3181,7 @@ function buildOptimisticAddCommentReportAction(text?: string, file?: FileObject, commentText, reportAction: { reportActionID: NumberUtils.rand64(), - actionName: CONST.REPORT.ACTIONS.TYPE.ADDCOMMENT, + actionName: CONST.REPORT.ACTIONS.TYPE.ADD_COMMENT, actorAccountID: accountID, person: [ { @@ -3693,7 +3693,7 @@ function buildOptimisticReportPreview(chatReport: OnyxEntry<Report>, iouReport: return { reportActionID: NumberUtils.rand64(), reportID: chatReport?.reportID, - actionName: CONST.REPORT.ACTIONS.TYPE.REPORTPREVIEW, + actionName: CONST.REPORT.ACTIONS.TYPE.REPORT_PREVIEW, pendingAction: CONST.RED_BRICK_ROAD_PENDING_ACTION.ADD, originalMessage: { linkedReportID: iouReport?.reportID, @@ -3730,7 +3730,7 @@ function buildOptimisticModifiedExpenseReportAction( ): OptimisticModifiedExpenseReportAction { const originalMessage = getModifiedExpenseOriginalMessage(oldTransaction, transactionChanges, isFromExpenseReport, policy); return { - actionName: CONST.REPORT.ACTIONS.TYPE.MODIFIEDEXPENSE, + actionName: CONST.REPORT.ACTIONS.TYPE.MODIFIED_EXPENSE, actorAccountID: currentUserAccountID, automatic: false, avatar: getCurrentUserAvatarOrDefault(), @@ -4042,7 +4042,7 @@ function buildOptimisticHoldReportAction(created = DateUtils.getDBTime()): Optim function buildOptimisticHoldReportActionComment(comment: string, created = DateUtils.getDBTime()): OptimisticHoldReportAction { return { reportActionID: NumberUtils.rand64(), - actionName: CONST.REPORT.ACTIONS.TYPE.HOLDCOMMENT, + actionName: CONST.REPORT.ACTIONS.TYPE.HOLD_COMMENT, pendingAction: CONST.RED_BRICK_ROAD_PENDING_ACTION.ADD, actorAccountID: currentUserAccountID, message: [ @@ -4118,7 +4118,7 @@ function buildOptimisticEditedTaskFieldReportAction({title, description}: Task): return { reportActionID: NumberUtils.rand64(), - actionName: CONST.REPORT.ACTIONS.TYPE.TASKEDITED, + actionName: CONST.REPORT.ACTIONS.TYPE.TASK_EDITED, pendingAction: CONST.RED_BRICK_ROAD_PENDING_ACTION.ADD, actorAccountID: currentUserAccountID, message: [ @@ -4145,7 +4145,7 @@ function buildOptimisticEditedTaskFieldReportAction({title, description}: Task): function buildOptimisticChangedTaskAssigneeReportAction(assigneeAccountID: number): OptimisticEditedTaskReportAction { return { reportActionID: NumberUtils.rand64(), - actionName: CONST.REPORT.ACTIONS.TYPE.TASKEDITED, + actionName: CONST.REPORT.ACTIONS.TYPE.TASK_EDITED, pendingAction: CONST.RED_BRICK_ROAD_PENDING_ACTION.ADD, actorAccountID: currentUserAccountID, message: [ @@ -4710,7 +4710,7 @@ function chatIncludesChronos(report: OnyxEntry<Report> | EmptyObject): boolean { * * - It was written by someone else and isn't a whisper * - It's a welcome message whisper - * - It's an ADDCOMMENT that is not an attachment + * - It's an ADD_COMMENT that is not an attachment */ function canFlagReportAction(reportAction: OnyxEntry<ReportAction>, reportID: string | undefined): boolean { let report = getReport(reportID); @@ -4722,9 +4722,9 @@ function canFlagReportAction(reportAction: OnyxEntry<ReportAction>, reportID: st } const isCurrentUserAction = reportAction?.actorAccountID === currentUserAccountID; const isOriginalMessageHaveHtml = - reportAction?.actionName === CONST.REPORT.ACTIONS.TYPE.ADDCOMMENT || + reportAction?.actionName === CONST.REPORT.ACTIONS.TYPE.ADD_COMMENT || reportAction?.actionName === CONST.REPORT.ACTIONS.TYPE.RENAMED || - reportAction?.actionName === CONST.REPORT.ACTIONS.TYPE.CHRONOSOOOLIST; + reportAction?.actionName === CONST.REPORT.ACTIONS.TYPE.CHRONOSOOLIST; if (ReportActionsUtils.isWhisperAction(reportAction)) { // Allow flagging welcome message whispers as they can be set by any room creator if (report?.description && !isCurrentUserAction && isOriginalMessageHaveHtml && reportAction?.originalMessage?.html === report.description) { @@ -4737,7 +4737,7 @@ function canFlagReportAction(reportAction: OnyxEntry<ReportAction>, reportID: st return Boolean( !isCurrentUserAction && - reportAction?.actionName === CONST.REPORT.ACTIONS.TYPE.ADDCOMMENT && + reportAction?.actionName === CONST.REPORT.ACTIONS.TYPE.ADD_COMMENT && !ReportActionsUtils.isDeletedAction(reportAction) && !ReportActionsUtils.isCreatedTaskReportAction(reportAction) && !isEmptyObject(report) && @@ -5782,7 +5782,7 @@ function isAllowedToSubmitDraftExpenseReport(report: OnyxEntry<Report>): boolean */ function getIndicatedMissingPaymentMethod(userWallet: OnyxEntry<UserWallet>, reportId: string, reportAction: ReportAction): MissingPaymentMethod | undefined { const isSubmitterOfUnsettledReport = isCurrentUserSubmitter(reportId) && !isSettled(reportId); - if (!isSubmitterOfUnsettledReport || reportAction.actionName !== CONST.REPORT.ACTIONS.TYPE.REIMBURSEMENTQUEUED) { + if (!isSubmitterOfUnsettledReport || reportAction.actionName !== CONST.REPORT.ACTIONS.TYPE.REIMBURSEMENT_QUEUED) { return undefined; } const paymentType = reportAction.originalMessage?.paymentType; @@ -5822,7 +5822,7 @@ function hasActionsWithErrors(reportID: string): boolean { function getReportActionActorAccountID(reportAction: OnyxEntry<ReportAction>, iouReport: OnyxEntry<Report> | undefined): number | undefined { switch (reportAction?.actionName) { - case CONST.REPORT.ACTIONS.TYPE.REPORTPREVIEW: + case CONST.REPORT.ACTIONS.TYPE.REPORT_PREVIEW: return iouReport ? iouReport.managerID : reportAction?.actorAccountID; case CONST.REPORT.ACTIONS.TYPE.SUBMITTED: diff --git a/src/libs/SidebarUtils.ts b/src/libs/SidebarUtils.ts index 69ce2cb90ba4..2ef16862d78d 100644 --- a/src/libs/SidebarUtils.ts +++ b/src/libs/SidebarUtils.ts @@ -324,7 +324,7 @@ function getOptionData({ const lastAction = visibleReportActionItems[report.reportID]; const isThreadMessage = - ReportUtils.isThread(report) && lastAction?.actionName === CONST.REPORT.ACTIONS.TYPE.ADDCOMMENT && lastAction?.pendingAction !== CONST.RED_BRICK_ROAD_PENDING_ACTION.DELETE; + ReportUtils.isThread(report) && lastAction?.actionName === CONST.REPORT.ACTIONS.TYPE.ADD_COMMENT && lastAction?.pendingAction !== CONST.RED_BRICK_ROAD_PENDING_ACTION.DELETE; if ((result.isChatRoom || result.isPolicyExpenseChat || result.isThread || result.isTaskReport || isThreadMessage) && !result.isArchivedRoom) { if (lastAction?.actionName === CONST.REPORT.ACTIONS.TYPE.RENAMED) { @@ -335,12 +335,12 @@ function getOptionData({ } else if ( lastAction?.actionName === CONST.REPORT.ACTIONS.TYPE.ROOMCHANGELOG.INVITE_TO_ROOM || lastAction?.actionName === CONST.REPORT.ACTIONS.TYPE.ROOMCHANGELOG.REMOVE_FROM_ROOM || - lastAction?.actionName === CONST.REPORT.ACTIONS.TYPE.POLICYCHANGELOG.INVITE_TO_ROOM || - lastAction?.actionName === CONST.REPORT.ACTIONS.TYPE.POLICYCHANGELOG.REMOVE_FROM_ROOM + lastAction?.actionName === CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.INVITE_TO_ROOM || + lastAction?.actionName === CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.REMOVE_FROM_ROOM ) { const targetAccountIDs = lastAction?.originalMessage?.targetAccountIDs ?? []; const verb = - lastAction.actionName === CONST.REPORT.ACTIONS.TYPE.ROOMCHANGELOG.INVITE_TO_ROOM || lastAction.actionName === CONST.REPORT.ACTIONS.TYPE.POLICYCHANGELOG.INVITE_TO_ROOM + lastAction.actionName === CONST.REPORT.ACTIONS.TYPE.ROOMCHANGELOG.INVITE_TO_ROOM || lastAction.actionName === CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.INVITE_TO_ROOM ? Localize.translate(preferredLocale, 'workspace.invite.invited') : Localize.translate(preferredLocale, 'workspace.invite.removed'); const users = Localize.translate(preferredLocale, targetAccountIDs.length > 1 ? 'workspace.invite.users' : 'workspace.invite.user'); @@ -349,12 +349,12 @@ function getOptionData({ const roomName = lastAction?.originalMessage?.roomName ?? ''; if (roomName) { const preposition = - lastAction.actionName === CONST.REPORT.ACTIONS.TYPE.ROOMCHANGELOG.INVITE_TO_ROOM || lastAction.actionName === CONST.REPORT.ACTIONS.TYPE.POLICYCHANGELOG.INVITE_TO_ROOM + lastAction.actionName === CONST.REPORT.ACTIONS.TYPE.ROOMCHANGELOG.INVITE_TO_ROOM || lastAction.actionName === CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.INVITE_TO_ROOM ? ` ${Localize.translate(preferredLocale, 'workspace.invite.to')}` : ` ${Localize.translate(preferredLocale, 'workspace.invite.from')}`; result.alternateText += `${preposition} ${roomName}`; } - } else if (lastAction?.actionName !== CONST.REPORT.ACTIONS.TYPE.REPORTPREVIEW && lastActorDisplayName && lastMessageTextFromReport) { + } else if (lastAction?.actionName !== CONST.REPORT.ACTIONS.TYPE.REPORT_PREVIEW && lastActorDisplayName && lastMessageTextFromReport) { result.alternateText = `${lastActorDisplayName}: ${lastMessageText}`; } else { result.alternateText = lastMessageTextFromReport.length > 0 ? lastMessageText : ReportActionsUtils.getLastVisibleMessage(report.reportID, {}, lastAction)?.lastMessageText; diff --git a/src/libs/TaskUtils.ts b/src/libs/TaskUtils.ts index 19e1025a09c8..17d724472611 100644 --- a/src/libs/TaskUtils.ts +++ b/src/libs/TaskUtils.ts @@ -21,13 +21,13 @@ Onyx.connect({ */ function getTaskReportActionMessage(action: OnyxEntry<ReportAction>): Pick<Message, 'text' | 'html'> { switch (action?.actionName) { - case CONST.REPORT.ACTIONS.TYPE.TASKCOMPLETED: + case CONST.REPORT.ACTIONS.TYPE.TASK_COMPLETED: return {text: Localize.translateLocal('task.messages.completed')}; - case CONST.REPORT.ACTIONS.TYPE.TASKCANCELLED: + case CONST.REPORT.ACTIONS.TYPE.TASK_CANCELLED: return {text: Localize.translateLocal('task.messages.canceled')}; - case CONST.REPORT.ACTIONS.TYPE.TASKREOPENED: + case CONST.REPORT.ACTIONS.TYPE.TASK_REOPENED: return {text: Localize.translateLocal('task.messages.reopened')}; - case CONST.REPORT.ACTIONS.TYPE.TASKEDITED: + case CONST.REPORT.ACTIONS.TYPE.TASK_EDITED: return { text: action?.message?.[0]?.text ?? '', html: action?.message?.[0]?.html, diff --git a/src/libs/actions/IOU.ts b/src/libs/actions/IOU.ts index cd0264ddb6ea..a048f28f473a 100644 --- a/src/libs/actions/IOU.ts +++ b/src/libs/actions/IOU.ts @@ -1236,7 +1236,7 @@ function getMoneyRequestInformation( // 2. CREATED action for the iouReport // 3. IOU action for the iouReport // 4. The transaction thread, which requires the iouAction, and CREATED action for the transaction thread - // 5. REPORTPREVIEW action for the chatReport + // 5. REPORT_PREVIEW action for the chatReport // Note: The CREATED action for the IOU report must be optimistically generated before the IOU action so there's no chance that it appears after the IOU action in the chat const [optimisticCreatedActionForChat, optimisticCreatedActionForIOUReport, iouAction, optimisticTransactionThread, optimisticCreatedActionForTransactionThread] = ReportUtils.buildOptimisticMoneyRequestEntities( @@ -1437,7 +1437,7 @@ function getTrackExpenseInformation( // 1. CREATED action for the iouReport (if tracking in the Expense chat) // 2. IOU action for the iouReport (if tracking in the Expense chat), otherwise – for chatReport // 3. The transaction thread, which requires the iouAction, and CREATED action for the transaction thread - // 4. REPORTPREVIEW action for the chatReport (if tracking in the Expense chat) + // 4. REPORT_PREVIEW action for the chatReport (if tracking in the Expense chat) const [, optimisticCreatedActionForIOUReport, iouAction, optimisticTransactionThread, optimisticCreatedActionForTransactionThread] = ReportUtils.buildOptimisticMoneyRequestEntities( shouldUseMoneyReport && iouReport ? iouReport : chatReport, CONST.IOU.REPORT_ACTION_TYPE.TRACK, @@ -2786,7 +2786,7 @@ function createSplitsAndOnyxData( // 2. CREATED action for the iouReport // 3. IOU action for the iouReport // 4. Transaction Thread and the CREATED action for it - // 5. REPORTPREVIEW action for the chatReport + // 5. REPORT_PREVIEW action for the chatReport const [oneOnOneCreatedActionForChat, oneOnOneCreatedActionForIOU, oneOnOneIOUAction, optimisticTransactionThread, optimisticCreatedActionForTransactionThread] = ReportUtils.buildOptimisticMoneyRequestEntities( oneOnOneIOUReport, @@ -4895,7 +4895,7 @@ function hasIOUToApproveOrPay(chatReport: OnyxEntry<OnyxTypes.Report> | EmptyObj const iouReport = ReportUtils.getReport(action.childReportID ?? ''); const policy = getPolicy(iouReport?.policyID); const shouldShowSettlementButton = canIOUBePaid(iouReport, chatReport, policy) || canApproveIOU(iouReport, chatReport, policy); - return action.childReportID?.toString() !== excludedIOUReportID && action.actionName === CONST.REPORT.ACTIONS.TYPE.REPORTPREVIEW && shouldShowSettlementButton; + return action.childReportID?.toString() !== excludedIOUReportID && action.actionName === CONST.REPORT.ACTIONS.TYPE.REPORT_PREVIEW && shouldShowSettlementButton; }); } diff --git a/src/libs/actions/Report.ts b/src/libs/actions/Report.ts index ac7edc38980d..6036dba50139 100644 --- a/src/libs/actions/Report.ts +++ b/src/libs/actions/Report.ts @@ -2177,7 +2177,7 @@ function showReportActionNotification(reportID: string, reportAction: ReportActi Navigation.navigate(ROUTES.REPORT_WITH_ID.getRoute(reportID)); }); - if (reportAction.actionName === CONST.REPORT.ACTIONS.TYPE.MODIFIEDEXPENSE) { + if (reportAction.actionName === CONST.REPORT.ACTIONS.TYPE.MODIFIED_EXPENSE) { LocalNotification.showModifiedExpenseNotification(report, reportAction, onClick); } else { LocalNotification.showCommentNotification(report, reportAction, onClick); diff --git a/src/libs/actions/Task.ts b/src/libs/actions/Task.ts index 9cf7b0b78008..6653ab0a77bf 100644 --- a/src/libs/actions/Task.ts +++ b/src/libs/actions/Task.ts @@ -298,7 +298,7 @@ function createTaskAndNavigate( function completeTask(taskReport: OnyxEntry<OnyxTypes.Report>) { const taskReportID = taskReport?.reportID ?? ''; const message = `marked as complete`; - const completedTaskReportAction = ReportUtils.buildOptimisticTaskReportAction(taskReportID, CONST.REPORT.ACTIONS.TYPE.TASKCOMPLETED, message); + const completedTaskReportAction = ReportUtils.buildOptimisticTaskReportAction(taskReportID, CONST.REPORT.ACTIONS.TYPE.TASK_COMPLETED, message); const optimisticData: OnyxUpdate[] = [ { @@ -365,7 +365,7 @@ function completeTask(taskReport: OnyxEntry<OnyxTypes.Report>) { function reopenTask(taskReport: OnyxEntry<OnyxTypes.Report>) { const taskReportID = taskReport?.reportID ?? ''; const message = `marked as incomplete`; - const reopenedTaskReportAction = ReportUtils.buildOptimisticTaskReportAction(taskReportID, CONST.REPORT.ACTIONS.TYPE.TASKREOPENED, message); + const reopenedTaskReportAction = ReportUtils.buildOptimisticTaskReportAction(taskReportID, CONST.REPORT.ACTIONS.TYPE.TASK_REOPENED, message); const optimisticData: OnyxUpdate[] = [ { @@ -816,7 +816,7 @@ function deleteTask(report: OnyxEntry<OnyxTypes.Report>) { return; } const message = `deleted task: ${report.reportName}`; - const optimisticCancelReportAction = ReportUtils.buildOptimisticTaskReportAction(report.reportID ?? '', CONST.REPORT.ACTIONS.TYPE.TASKCANCELLED, message); + const optimisticCancelReportAction = ReportUtils.buildOptimisticTaskReportAction(report.reportID ?? '', CONST.REPORT.ACTIONS.TYPE.TASK_CANCELLED, message); const optimisticReportActionID = optimisticCancelReportAction.reportActionID; const parentReportAction = getParentReportAction(report); const parentReport = getParentReport(report); diff --git a/src/libs/actions/User.ts b/src/libs/actions/User.ts index dcd6e025e23b..c8347a0140ed 100644 --- a/src/libs/actions/User.ts +++ b/src/libs/actions/User.ts @@ -517,7 +517,7 @@ function playSoundForMessageType(pushJSON: OnyxServerUpdate[]) { for (const data of flatten) { // Someone completes a task - if (data.actionName === 'TASKCOMPLETED') { + if (data.actionName === 'TASK_COMPLETED') { return playSound(SOUNDS.SUCCESS); } } diff --git a/src/pages/home/report/ContextMenu/ContextMenuActions.tsx b/src/pages/home/report/ContextMenu/ContextMenuActions.tsx index c1f31ae0de19..0bbafc1dde41 100644 --- a/src/pages/home/report/ContextMenu/ContextMenuActions.tsx +++ b/src/pages/home/report/ContextMenu/ContextMenuActions.tsx @@ -289,7 +289,7 @@ const ContextMenuActions: ContextMenuAction[] = [ const isDeletedAction = ReportActionsUtils.isDeletedAction(reportAction); const shouldDisplayThreadReplies = ReportUtils.shouldDisplayThreadReplies(reportAction, reportID); const subscribed = childReportNotificationPreference !== 'hidden'; - const isCommentAction = reportAction?.actionName === CONST.REPORT.ACTIONS.TYPE.ADDCOMMENT && !ReportUtils.isThreadFirstChat(reportAction, reportID); + const isCommentAction = reportAction?.actionName === CONST.REPORT.ACTIONS.TYPE.ADD_COMMENT && !ReportUtils.isThreadFirstChat(reportAction, reportID); const isWhisperAction = ReportActionsUtils.isWhisperAction(reportAction); return !subscribed && !isWhisperAction && isCommentAction && (!isDeletedAction || shouldDisplayThreadReplies); }, diff --git a/src/pages/home/report/ReportActionItem.tsx b/src/pages/home/report/ReportActionItem.tsx index 31019b60aefb..1535f59c00e0 100644 --- a/src/pages/home/report/ReportActionItem.tsx +++ b/src/pages/home/report/ReportActionItem.tsx @@ -279,7 +279,7 @@ function ReportActionItem({ // Removed messages should not be shown anyway and should not need this flow const latestDecision = action.message?.[0]?.moderationDecision?.decision ?? ''; useEffect(() => { - if (action.actionName !== CONST.REPORT.ACTIONS.TYPE.ADDCOMMENT) { + if (action.actionName !== CONST.REPORT.ACTIONS.TYPE.ADD_COMMENT) { return; } @@ -447,7 +447,7 @@ function ReportActionItem({ isWhisper={isWhisper} /> ); - } else if (action.actionName === CONST.REPORT.ACTIONS.TYPE.REPORTPREVIEW) { + } else if (action.actionName === CONST.REPORT.ACTIONS.TYPE.REPORT_PREVIEW) { children = ReportUtils.isClosedExpenseReportWithNoExpenses(iouReport) ? ( <RenderHTML html={`<comment>${translate('parentReportAction.deletedReport')}</comment>`} /> ) : ( @@ -469,7 +469,7 @@ function ReportActionItem({ children = ( <ShowContextMenuContext.Provider value={contextValue}> <TaskPreview - taskReportID={action.actionName === CONST.REPORT.ACTIONS.TYPE.ADDCOMMENT ? action.originalMessage.taskReportID?.toString() ?? '' : ''} + taskReportID={action.actionName === CONST.REPORT.ACTIONS.TYPE.ADD_COMMENT ? action.originalMessage.taskReportID?.toString() ?? '' : ''} chatReportID={report.reportID} action={action} isHovered={hovered} @@ -479,7 +479,7 @@ function ReportActionItem({ /> </ShowContextMenuContext.Provider> ); - } else if (action.actionName === CONST.REPORT.ACTIONS.TYPE.REIMBURSEMENTQUEUED) { + } else if (action.actionName === CONST.REPORT.ACTIONS.TYPE.REIMBURSEMENT_QUEUED) { const submitterDisplayName = PersonalDetailsUtils.getDisplayNameOrDefault(personalDetails[report.ownerAccountID ?? -1]); const paymentType = action.originalMessage.paymentType ?? ''; @@ -523,16 +523,16 @@ function ReportActionItem({ </> </ReportActionItemBasicMessage> ); - } else if (action.actionName === CONST.REPORT.ACTIONS.TYPE.REIMBURSEMENTDEQUEUED) { + } else if (action.actionName === CONST.REPORT.ACTIONS.TYPE.REIMBURSEMENT_DEQUEUED) { children = <ReportActionItemBasicMessage message={ReportUtils.getReimbursementDeQueuedActionMessage(action, report)} />; - } else if (action.actionName === CONST.REPORT.ACTIONS.TYPE.MODIFIEDEXPENSE) { + } else if (action.actionName === CONST.REPORT.ACTIONS.TYPE.MODIFIED_EXPENSE) { children = <ReportActionItemBasicMessage message={ModifiedExpenseMessage.getForReportAction(report.reportID, action)} />; } else if (ReportActionsUtils.isOldDotReportAction(action)) { // This handles all historical actions from OldDot that we just want to display the message text children = <ReportActionItemBasicMessage message={ReportActionsUtils.getMessageOfOldDotReportAction(action)} />; } else if (action.actionName === CONST.REPORT.ACTIONS.TYPE.HOLD) { children = <ReportActionItemBasicMessage message={translate('iou.heldRequest')} />; - } else if (action.actionName === CONST.REPORT.ACTIONS.TYPE.HOLDCOMMENT) { + } else if (action.actionName === CONST.REPORT.ACTIONS.TYPE.HOLD_COMMENT) { children = <ReportActionItemBasicMessage message={action.message?.[0]?.text ?? ''} />; } else if (action.actionName === CONST.REPORT.ACTIONS.TYPE.UNHOLD) { children = <ReportActionItemBasicMessage message={translate('iou.unheldRequest')} />; @@ -792,7 +792,7 @@ function ReportActionItem({ if (action.actionName === CONST.REPORT.ACTIONS.TYPE.RENAMED) { return <RenameAction action={action} />; } - if (action.actionName === CONST.REPORT.ACTIONS.TYPE.CHRONOSOOOLIST) { + if (action.actionName === CONST.REPORT.ACTIONS.TYPE.CHRONOSOOLIST) { return ( <ChronosOOOListActions action={action} diff --git a/src/pages/home/report/ReportActionItemFragment.tsx b/src/pages/home/report/ReportActionItemFragment.tsx index 07fca587ea24..421faae66bf0 100644 --- a/src/pages/home/report/ReportActionItemFragment.tsx +++ b/src/pages/home/report/ReportActionItemFragment.tsx @@ -66,11 +66,11 @@ type ReportActionItemFragmentProps = { }; const MUTED_ACTIONS = [ - ...Object.values(CONST.REPORT.ACTIONS.TYPE.POLICYCHANGELOG), + ...Object.values(CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG), CONST.REPORT.ACTIONS.TYPE.IOU, CONST.REPORT.ACTIONS.TYPE.APPROVED, CONST.REPORT.ACTIONS.TYPE.MOVED, - CONST.REPORT.ACTIONS.TYPE.ACTIONABLEJOINREQUEST, + CONST.REPORT.ACTIONS.TYPE.ACTIONABLE_JOIN_REQUEST, ] as ActionName[]; function ReportActionItemFragment({ diff --git a/src/pages/home/report/ReportActionItemSingle.tsx b/src/pages/home/report/ReportActionItemSingle.tsx index 1e0dc432b3fc..817db9117e9c 100644 --- a/src/pages/home/report/ReportActionItemSingle.tsx +++ b/src/pages/home/report/ReportActionItemSingle.tsx @@ -84,7 +84,7 @@ function ReportActionItemSingle({ const {avatar, login, pendingFields, status, fallbackIcon} = personalDetails[actorAccountID ?? -1] ?? {}; // eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing let actorHint = (login || (displayName ?? '')).replace(CONST.REGEX.MERGED_ACCOUNT_PREFIX, ''); - const displayAllActors = useMemo(() => action?.actionName === CONST.REPORT.ACTIONS.TYPE.REPORTPREVIEW && iouReport, [action?.actionName, iouReport]); + const displayAllActors = useMemo(() => action?.actionName === CONST.REPORT.ACTIONS.TYPE.REPORT_PREVIEW && iouReport, [action?.actionName, iouReport]); const isWorkspaceActor = ReportUtils.isPolicyExpenseChat(report) && (!actorAccountID || displayAllActors); let avatarSource = UserUtils.getAvatar(avatar ?? '', actorAccountID); diff --git a/src/pages/home/report/ReportActionsList.tsx b/src/pages/home/report/ReportActionsList.tsx index 361cedd56354..cb130b769b64 100644 --- a/src/pages/home/report/ReportActionsList.tsx +++ b/src/pages/home/report/ReportActionsList.tsx @@ -432,7 +432,7 @@ function ReportActionsList({ shouldDisplay = isCurrentMessageUnread && (!nextMessage || !isMessageUnread(nextMessage, lastReadTimeRef.current)) && !ReportActionsUtils.shouldHideNewMarker(reportAction); if (shouldDisplay && !messageManuallyMarkedUnread) { const isWithinVisibleThreshold = scrollingVerticalOffset.current < MSG_VISIBLE_THRESHOLD ? reportAction.created < (userActiveSince.current ?? '') : true; - // Prevent displaying a new marker line when report action is of type "REPORTPREVIEW" and last actor is the current user + // Prevent displaying a new marker line when report action is of type "REPORT_PREVIEW" and last actor is the current user shouldDisplay = (ReportActionsUtils.isReportPreviewAction(reportAction) ? !reportAction.childLastActorAccountID : reportAction.actorAccountID) !== Report.getCurrentUserAccountID() && isWithinVisibleThreshold; diff --git a/src/pages/home/report/ReportActionsListItemRenderer.tsx b/src/pages/home/report/ReportActionsListItemRenderer.tsx index 879f567762dd..7b0dea06eb45 100644 --- a/src/pages/home/report/ReportActionsListItemRenderer.tsx +++ b/src/pages/home/report/ReportActionsListItemRenderer.tsx @@ -154,7 +154,7 @@ function ReportActionsListItemRenderer({ shouldDisplayNewMarker={shouldDisplayNewMarker} shouldShowSubscriptAvatar={ (ReportUtils.isPolicyExpenseChat(report) || ReportUtils.isExpenseReport(report)) && - [CONST.REPORT.ACTIONS.TYPE.IOU, CONST.REPORT.ACTIONS.TYPE.REPORTPREVIEW, CONST.REPORT.ACTIONS.TYPE.SUBMITTED, CONST.REPORT.ACTIONS.TYPE.APPROVED].some( + [CONST.REPORT.ACTIONS.TYPE.IOU, CONST.REPORT.ACTIONS.TYPE.REPORT_PREVIEW, CONST.REPORT.ACTIONS.TYPE.SUBMITTED, CONST.REPORT.ACTIONS.TYPE.APPROVED].some( (type) => type === reportAction.actionName, ) } diff --git a/src/pages/home/report/ReportActionsView.tsx b/src/pages/home/report/ReportActionsView.tsx index 65d880879d61..0cb570b194f7 100755 --- a/src/pages/home/report/ReportActionsView.tsx +++ b/src/pages/home/report/ReportActionsView.tsx @@ -388,11 +388,11 @@ function ReportActionsView({ }, [hasCachedActionOnFirstRender]); useEffect(() => { - // Temporary solution for handling REPORTPREVIEW. More details: https://expensify.slack.com/archives/C035J5C9FAP/p1705417778466539?thread_ts=1705035404.136629&cid=C035J5C9FAP - // This code should be removed once REPORTPREVIEW is no longer repositioned. - // We need to call openReport for gaps created by moving REPORTPREVIEW, which causes mismatches in previousReportActionID and reportActionID of adjacent reportActions. The server returns the correct sequence, allowing us to overwrite incorrect data with the correct one. + // Temporary solution for handling REPORT_PREVIEW. More details: https://expensify.slack.com/archives/C035J5C9FAP/p1705417778466539?thread_ts=1705035404.136629&cid=C035J5C9FAP + // This code should be removed once REPORT_PREVIEW is no longer repositioned. + // We need to call openReport for gaps created by moving REPORT_PREVIEW, which causes mismatches in previousReportActionID and reportActionID of adjacent reportActions. The server returns the correct sequence, allowing us to overwrite incorrect data with the correct one. const shouldOpenReport = - newestReportAction?.actionName === CONST.REPORT.ACTIONS.TYPE.REPORTPREVIEW && + newestReportAction?.actionName === CONST.REPORT.ACTIONS.TYPE.REPORT_PREVIEW && !hasCreatedAction && isReadyForCommentLinking && reportActions.length < 24 && diff --git a/src/pages/home/report/reportActionPropTypes.js b/src/pages/home/report/reportActionPropTypes.js index 4d4809cd781f..f40e86aa7a7b 100644 --- a/src/pages/home/report/reportActionPropTypes.js +++ b/src/pages/home/report/reportActionPropTypes.js @@ -5,7 +5,7 @@ export default { /** The ID of the reportAction. It is the string representation of the a 64-bit integer. */ reportActionID: PropTypes.string, - /** Name of the action e.g. ADDCOMMENT */ + /** Name of the action e.g. ADD_COMMENT */ actionName: PropTypes.string, /** Person who created the action */ diff --git a/src/types/onyx/OriginalMessage.ts b/src/types/onyx/OriginalMessage.ts index 2e24fe00539a..b08a240bf0c1 100644 --- a/src/types/onyx/OriginalMessage.ts +++ b/src/types/onyx/OriginalMessage.ts @@ -6,26 +6,26 @@ type PaymentMethodType = DeepValueOf<typeof CONST.IOU.PAYMENT_TYPE | typeof CONS type ActionName = DeepValueOf<typeof CONST.REPORT.ACTIONS.TYPE>; type OriginalMessageActionName = - | 'ADDCOMMENT' + | 'ADD_COMMENT' | 'APPROVED' - | 'CHRONOSOOOLIST' + | 'CHRONOSOOLIST' | 'CLOSED' | 'CREATED' | 'HOLD' | 'UNHOLD' | 'IOU' - | 'MODIFIEDEXPENSE' - | 'REIMBURSEMENTQUEUED' + | 'MODIFIED_EXPENSE' + | 'REIMBURSEMENT_QUEUED' | 'RENAMED' - | 'REPORTPREVIEW' + | 'REPORT_PREVIEW' | 'SUBMITTED' - | 'TASKCANCELLED' - | 'TASKCOMPLETED' - | 'TASKEDITED' - | 'TASKREOPENED' - | 'ACTIONABLEJOINREQUEST' - | 'ACTIONABLEMENTIONWHISPER' - | ValueOf<typeof CONST.REPORT.ACTIONS.TYPE.POLICYCHANGELOG>; + | 'TASK_CANCELLED' + | 'TASK_COMPLETED' + | 'TASK_EDITED' + | 'TASK_REOPENED' + | 'ACTIONABLE_JOIN_REQUEST' + | 'ACTIONABLE_MENTION_WHISPER' + | ValueOf<typeof CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG>; type OriginalMessageApproved = { actionName: typeof CONST.REPORT.ACTIONS.TYPE.APPROVED; originalMessage: unknown; @@ -38,7 +38,7 @@ type OriginalMessageHold = { }; type OriginalMessageHoldComment = { - actionName: typeof CONST.REPORT.ACTIONS.TYPE.HOLDCOMMENT; + actionName: typeof CONST.REPORT.ACTIONS.TYPE.HOLD_COMMENT; originalMessage: unknown; }; @@ -123,7 +123,7 @@ type Closed = { }; type OriginalMessageAddComment = { - actionName: typeof CONST.REPORT.ACTIONS.TYPE.ADDCOMMENT; + actionName: typeof CONST.REPORT.ACTIONS.TYPE.ADD_COMMENT; originalMessage: { html: string; source?: OriginalMessageSource; @@ -140,7 +140,7 @@ type OriginalMessageAddComment = { }; type OriginalMessageActionableMentionWhisper = { - actionName: typeof CONST.REPORT.ACTIONS.TYPE.ACTIONABLEMENTIONWHISPER; + actionName: typeof CONST.REPORT.ACTIONS.TYPE.ACTIONABLE_MENTION_WHISPER; originalMessage: { inviteeAccountIDs: number[]; inviteeEmails: string; @@ -167,7 +167,7 @@ type OriginalMessageCreated = { }; type OriginalMessageMarkedReimbursed = { - actionName: typeof CONST.REPORT.ACTIONS.TYPE.MARKEDREIMBURSED; + actionName: typeof CONST.REPORT.ACTIONS.TYPE.MARKED_REIMBURSED; originalMessage?: unknown; }; @@ -203,7 +203,7 @@ type ChronosOOOEvent = { }; type OriginalMessageChronosOOOList = { - actionName: typeof CONST.REPORT.ACTIONS.TYPE.CHRONOSOOOLIST; + actionName: typeof CONST.REPORT.ACTIONS.TYPE.CHRONOSOOLIST; originalMessage: { edits: string[]; events: ChronosOOOEvent[]; @@ -213,7 +213,7 @@ type OriginalMessageChronosOOOList = { }; type OriginalMessageReportPreview = { - actionName: typeof CONST.REPORT.ACTIONS.TYPE.REPORTPREVIEW; + actionName: typeof CONST.REPORT.ACTIONS.TYPE.REPORT_PREVIEW; originalMessage: { linkedReportID: string; lastModified?: string; @@ -221,12 +221,12 @@ type OriginalMessageReportPreview = { }; type OriginalMessagePolicyChangeLog = { - actionName: ValueOf<typeof CONST.REPORT.ACTIONS.TYPE.POLICYCHANGELOG>; + actionName: ValueOf<typeof CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG>; originalMessage: ChangeLog; }; type OriginalMessageJoinPolicyChangeLog = { - actionName: typeof CONST.REPORT.ACTIONS.TYPE.ACTIONABLEJOINREQUEST; + actionName: typeof CONST.REPORT.ACTIONS.TYPE.ACTIONABLE_JOIN_REQUEST; originalMessage: { choice: string; email: string; @@ -243,16 +243,16 @@ type OriginalMessageRoomChangeLog = { type OriginalMessagePolicyTask = { actionName: - | typeof CONST.REPORT.ACTIONS.TYPE.TASKEDITED - | typeof CONST.REPORT.ACTIONS.TYPE.TASKCANCELLED - | typeof CONST.REPORT.ACTIONS.TYPE.TASKCOMPLETED - | typeof CONST.REPORT.ACTIONS.TYPE.TASKREOPENED - | typeof CONST.REPORT.ACTIONS.TYPE.MODIFIEDEXPENSE; + | typeof CONST.REPORT.ACTIONS.TYPE.TASK_EDITED + | typeof CONST.REPORT.ACTIONS.TYPE.TASK_CANCELLED + | typeof CONST.REPORT.ACTIONS.TYPE.TASK_COMPLETED + | typeof CONST.REPORT.ACTIONS.TYPE.TASK_REOPENED + | typeof CONST.REPORT.ACTIONS.TYPE.MODIFIED_EXPENSE; originalMessage: unknown; }; type OriginalMessageModifiedExpense = { - actionName: typeof CONST.REPORT.ACTIONS.TYPE.MODIFIEDEXPENSE; + actionName: typeof CONST.REPORT.ACTIONS.TYPE.MODIFIED_EXPENSE; originalMessage: { oldMerchant?: string; merchant?: string; @@ -278,14 +278,14 @@ type OriginalMessageModifiedExpense = { }; type OriginalMessageReimbursementQueued = { - actionName: typeof CONST.REPORT.ACTIONS.TYPE.REIMBURSEMENTQUEUED; + actionName: typeof CONST.REPORT.ACTIONS.TYPE.REIMBURSEMENT_QUEUED; originalMessage: { paymentType: DeepValueOf<typeof CONST.IOU.PAYMENT_TYPE>; }; }; type OriginalMessageReimbursementDequeued = { - actionName: typeof CONST.REPORT.ACTIONS.TYPE.REIMBURSEMENTDEQUEUED; + actionName: typeof CONST.REPORT.ACTIONS.TYPE.REIMBURSEMENT_DEQUEUED; originalMessage: { expenseReportID: string; }; From 819bf4a8c8585f162407c3bbf4305fe975f584dd Mon Sep 17 00:00:00 2001 From: Shahe Shahinyan <shahe.shahinyan@gmail.com> Date: Sun, 14 Apr 2024 16:42:54 +0400 Subject: [PATCH 098/206] Changes in missing places --- src/CONST.ts | 2 +- src/libs/ReportActionsUtils.ts | 12 +- src/libs/ReportUtils.ts | 2 +- src/libs/SidebarUtils.ts | 8 +- src/types/onyx/OriginalMessage.ts | 2 +- tests/actions/IOUTest.ts | 18 +- tests/actions/ReportTest.ts | 8 +- .../ModifiedExpenseMessage.perf-test.ts | 2 +- tests/perf-test/ReportUtils.perf-test.ts | 2 +- tests/ui/UnreadIndicatorsTest.tsx | 2 +- tests/unit/MigrationTest.ts | 16 +- tests/unit/ModifiedExpenseMessageTest.ts | 32 +-- tests/unit/ReportActionsUtilsTest.ts | 212 +++++++++--------- tests/unit/ReportUtilsTest.ts | 10 +- tests/unit/SidebarOrderTest.ts | 18 +- tests/utils/ReportTestUtils.ts | 4 +- tests/utils/TestHelper.ts | 2 +- 17 files changed, 176 insertions(+), 176 deletions(-) diff --git a/src/CONST.ts b/src/CONST.ts index eb71cba16382..11d6783eef75 100755 --- a/src/CONST.ts +++ b/src/CONST.ts @@ -751,7 +751,7 @@ const CONST = { UPDATE_TIME_ENABLED: 'POLICYCHANGELOG_UPDATE_TIME_ENABLED', UPDATE_TIME_RATE: 'POLICYCHANGELOG_UPDATE_TIME_RATE', }, - ROOMCHANGELOG: { + ROOM_CHANGE_LOG: { INVITE_TO_ROOM: 'INVITETOROOM', REMOVE_FROM_ROOM: 'REMOVEFROMROOM', LEAVE_ROOM: 'LEAVEROOM', diff --git a/src/libs/ReportActionsUtils.ts b/src/libs/ReportActionsUtils.ts index fef755acbe72..70c3d6ec0761 100644 --- a/src/libs/ReportActionsUtils.ts +++ b/src/libs/ReportActionsUtils.ts @@ -158,15 +158,15 @@ function isReimbursementQueuedAction(reportAction: OnyxEntry<ReportAction>) { function isMemberChangeAction(reportAction: OnyxEntry<ReportAction>) { return ( - reportAction?.actionName === CONST.REPORT.ACTIONS.TYPE.ROOMCHANGELOG.INVITE_TO_ROOM || - reportAction?.actionName === CONST.REPORT.ACTIONS.TYPE.ROOMCHANGELOG.REMOVE_FROM_ROOM || + reportAction?.actionName === CONST.REPORT.ACTIONS.TYPE.ROOM_CHANGE_LOG.INVITE_TO_ROOM || + reportAction?.actionName === CONST.REPORT.ACTIONS.TYPE.ROOM_CHANGE_LOG.REMOVE_FROM_ROOM || reportAction?.actionName === CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.INVITE_TO_ROOM || reportAction?.actionName === CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.REMOVE_FROM_ROOM ); } function isInviteMemberAction(reportAction: OnyxEntry<ReportAction>) { - return reportAction?.actionName === CONST.REPORT.ACTIONS.TYPE.ROOMCHANGELOG.INVITE_TO_ROOM || reportAction?.actionName === CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.INVITE_TO_ROOM; + return reportAction?.actionName === CONST.REPORT.ACTIONS.TYPE.ROOM_CHANGE_LOG.INVITE_TO_ROOM || reportAction?.actionName === CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.INVITE_TO_ROOM; } function isReimbursementDeQueuedAction(reportAction: OnyxEntry<ReportAction>): reportAction is ReportActionBase & OriginalMessageReimbursementDequeued { @@ -328,7 +328,7 @@ function getContinuousReportActionChain(sortedReportActions: ReportAction[], id? (endIndex < sortedReportActions.length - 1 && sortedReportActions[endIndex].previousReportActionID === sortedReportActions[endIndex + 1].reportActionID) || !!sortedReportActions[endIndex + 1]?.whisperedToAccountIDs?.length || !!sortedReportActions[endIndex]?.whisperedToAccountIDs?.length || - sortedReportActions[endIndex]?.actionName === CONST.REPORT.ACTIONS.TYPE.ROOMCHANGELOG.INVITE_TO_ROOM || + sortedReportActions[endIndex]?.actionName === CONST.REPORT.ACTIONS.TYPE.ROOM_CHANGE_LOG.INVITE_TO_ROOM || sortedReportActions[endIndex + 1]?.actionName === CONST.REPORT.ACTIONS.TYPE.CLOSED || sortedReportActions[endIndex + 1]?.actionName === CONST.REPORT.ACTIONS.TYPE.CREATED ) { @@ -346,7 +346,7 @@ function getContinuousReportActionChain(sortedReportActions: ReportAction[], id? sortedReportActions[startIndex - 1]?.pendingAction === CONST.RED_BRICK_ROAD_PENDING_ACTION.DELETE || // eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing sortedReportActions[startIndex - 1]?.isOptimisticAction || - sortedReportActions[startIndex - 1]?.actionName === CONST.REPORT.ACTIONS.TYPE.ROOMCHANGELOG.INVITE_TO_ROOM + sortedReportActions[startIndex - 1]?.actionName === CONST.REPORT.ACTIONS.TYPE.ROOM_CHANGE_LOG.INVITE_TO_ROOM ) { startIndex--; } @@ -487,7 +487,7 @@ function isReportActionDeprecated(reportAction: OnyxEntry<ReportAction>, key: st return false; } -const {POLICY_CHANGE_LOG: policyChangelogTypes, ROOMCHANGELOG: roomChangeLogTypes, ...otherActionTypes} = CONST.REPORT.ACTIONS.TYPE; +const {POLICY_CHANGE_LOG: policyChangelogTypes, ROOM_CHANGE_LOG: roomChangeLogTypes, ...otherActionTypes} = CONST.REPORT.ACTIONS.TYPE; const supportedActionTypes: ActionName[] = [...Object.values(otherActionTypes), ...Object.values(policyChangelogTypes), ...Object.values(roomChangeLogTypes)]; /** diff --git a/src/libs/ReportUtils.ts b/src/libs/ReportUtils.ts index 8c3797dba8c1..476847ec0acf 100644 --- a/src/libs/ReportUtils.ts +++ b/src/libs/ReportUtils.ts @@ -2912,7 +2912,7 @@ function getAdminRoomInvitedParticipants(parentReportAction: ReportAction | Reco return parentReportActionMessage; } const actionType = parentReportAction.actionName; - const isInviteAction = actionType === CONST.REPORT.ACTIONS.TYPE.ROOMCHANGELOG.INVITE_TO_ROOM || actionType === CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.INVITE_TO_ROOM; + const isInviteAction = actionType === CONST.REPORT.ACTIONS.TYPE.ROOM_CHANGE_LOG.INVITE_TO_ROOM || actionType === CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.INVITE_TO_ROOM; const verbKey = isInviteAction ? 'workspace.invite.invited' : 'workspace.invite.removed'; const prepositionKey = isInviteAction ? 'workspace.invite.to' : 'workspace.invite.from'; diff --git a/src/libs/SidebarUtils.ts b/src/libs/SidebarUtils.ts index 2ef16862d78d..30707b409898 100644 --- a/src/libs/SidebarUtils.ts +++ b/src/libs/SidebarUtils.ts @@ -333,14 +333,14 @@ function getOptionData({ } else if (ReportActionsUtils.isTaskAction(lastAction)) { result.alternateText = ReportUtils.formatReportLastMessageText(TaskUtils.getTaskReportActionMessage(lastAction).text); } else if ( - lastAction?.actionName === CONST.REPORT.ACTIONS.TYPE.ROOMCHANGELOG.INVITE_TO_ROOM || - lastAction?.actionName === CONST.REPORT.ACTIONS.TYPE.ROOMCHANGELOG.REMOVE_FROM_ROOM || + lastAction?.actionName === CONST.REPORT.ACTIONS.TYPE.ROOM_CHANGE_LOG.INVITE_TO_ROOM || + lastAction?.actionName === CONST.REPORT.ACTIONS.TYPE.ROOM_CHANGE_LOG.REMOVE_FROM_ROOM || lastAction?.actionName === CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.INVITE_TO_ROOM || lastAction?.actionName === CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.REMOVE_FROM_ROOM ) { const targetAccountIDs = lastAction?.originalMessage?.targetAccountIDs ?? []; const verb = - lastAction.actionName === CONST.REPORT.ACTIONS.TYPE.ROOMCHANGELOG.INVITE_TO_ROOM || lastAction.actionName === CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.INVITE_TO_ROOM + lastAction.actionName === CONST.REPORT.ACTIONS.TYPE.ROOM_CHANGE_LOG.INVITE_TO_ROOM || lastAction.actionName === CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.INVITE_TO_ROOM ? Localize.translate(preferredLocale, 'workspace.invite.invited') : Localize.translate(preferredLocale, 'workspace.invite.removed'); const users = Localize.translate(preferredLocale, targetAccountIDs.length > 1 ? 'workspace.invite.users' : 'workspace.invite.user'); @@ -349,7 +349,7 @@ function getOptionData({ const roomName = lastAction?.originalMessage?.roomName ?? ''; if (roomName) { const preposition = - lastAction.actionName === CONST.REPORT.ACTIONS.TYPE.ROOMCHANGELOG.INVITE_TO_ROOM || lastAction.actionName === CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.INVITE_TO_ROOM + lastAction.actionName === CONST.REPORT.ACTIONS.TYPE.ROOM_CHANGE_LOG.INVITE_TO_ROOM || lastAction.actionName === CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.INVITE_TO_ROOM ? ` ${Localize.translate(preferredLocale, 'workspace.invite.to')}` : ` ${Localize.translate(preferredLocale, 'workspace.invite.from')}`; result.alternateText += `${preposition} ${roomName}`; diff --git a/src/types/onyx/OriginalMessage.ts b/src/types/onyx/OriginalMessage.ts index b08a240bf0c1..f935ca5b4607 100644 --- a/src/types/onyx/OriginalMessage.ts +++ b/src/types/onyx/OriginalMessage.ts @@ -237,7 +237,7 @@ type OriginalMessageJoinPolicyChangeLog = { }; type OriginalMessageRoomChangeLog = { - actionName: ValueOf<typeof CONST.REPORT.ACTIONS.TYPE.ROOMCHANGELOG>; + actionName: ValueOf<typeof CONST.REPORT.ACTIONS.TYPE.ROOM_CHANGE_LOG>; originalMessage: ChangeLog; }; diff --git a/tests/actions/IOUTest.ts b/tests/actions/IOUTest.ts index c8c74d4198ab..22fb1741bb41 100644 --- a/tests/actions/IOUTest.ts +++ b/tests/actions/IOUTest.ts @@ -1717,7 +1717,7 @@ describe('actions/IOU', () => { callback: (allActions) => { Onyx.disconnect(connectionID); const updatedAction = Object.values(allActions ?? {}).find((reportAction) => !isEmptyObject(reportAction)); - expect(updatedAction?.actionName).toEqual('MODIFIEDEXPENSE'); + expect(updatedAction?.actionName).toEqual('MODIFIED_EXPENSE'); expect(updatedAction?.originalMessage).toEqual( expect.objectContaining({amount: 20000, newComment: 'Double the amount!', oldAmount: amount, oldComment: comment}), ); @@ -1873,7 +1873,7 @@ describe('actions/IOU', () => { callback: (allActions) => { Onyx.disconnect(connectionID); const updatedAction = Object.values(allActions ?? {}).find((reportAction) => !isEmptyObject(reportAction)); - expect(updatedAction?.actionName).toEqual('MODIFIEDEXPENSE'); + expect(updatedAction?.actionName).toEqual('MODIFIED_EXPENSE'); expect(Object.values(updatedAction?.errors ?? {})).toEqual(expect.arrayContaining([['iou.error.genericEditFailureMessage', {isTranslated: false}]])); resolve(); }, @@ -2121,7 +2121,7 @@ describe('actions/IOU', () => { let IOU_REPORT_ID: string; let reportActionID; const REPORT_ACTION: OnyxEntry<OnyxTypes.ReportAction> = { - actionName: CONST.REPORT.ACTIONS.TYPE.ADDCOMMENT, + actionName: CONST.REPORT.ACTIONS.TYPE.ADD_COMMENT, actorAccountID: TEST_USER_ACCOUNT_ID, automatic: false, avatar: 'https://d2k5nsl2zxldvw.cloudfront.net/images/avatars/avatar_3.png', @@ -2370,7 +2370,7 @@ describe('actions/IOU', () => { await waitForBatchedUpdates(); // Then verify that the comment is correctly added - const resultAction = Object.values(reportActions ?? {}).find((reportAction) => reportAction?.actionName === CONST.REPORT.ACTIONS.TYPE.ADDCOMMENT); + const resultAction = Object.values(reportActions ?? {}).find((reportAction) => reportAction?.actionName === CONST.REPORT.ACTIONS.TYPE.ADD_COMMENT); reportActionID = resultAction?.reportActionID ?? ''; expect(resultAction?.message).toEqual(REPORT_ACTION.message); @@ -2519,7 +2519,7 @@ describe('actions/IOU', () => { expect(report).toBeFalsy(); }); - it('delete the transaction thread if there are only changelogs (i.e. MODIFIEDEXPENSE actions) in the thread', async () => { + it('delete the transaction thread if there are only changelogs (i.e. MODIFIED_EXPENSE actions) in the thread', async () => { // Given all promises are resolved await waitForBatchedUpdates(); jest.advanceTimersByTime(10); @@ -2656,7 +2656,7 @@ describe('actions/IOU', () => { await waitForBatchedUpdates(); // Then comment details should match the expected report action - const resultAction = Object.values(reportActions ?? {}).find((reportAction) => reportAction?.actionName === CONST.REPORT.ACTIONS.TYPE.ADDCOMMENT); + const resultAction = Object.values(reportActions ?? {}).find((reportAction) => reportAction?.actionName === CONST.REPORT.ACTIONS.TYPE.ADD_COMMENT); reportActionID = resultAction?.reportActionID ?? ''; expect(resultAction?.message).toEqual(REPORT_ACTION.message); expect(resultAction?.person).toEqual(REPORT_ACTION.person); @@ -2766,7 +2766,7 @@ describe('actions/IOU', () => { }); }); - let resultAction = Object.values(reportActions ?? {}).find((reportAction) => reportAction?.actionName === CONST.REPORT.ACTIONS.TYPE.ADDCOMMENT); + let resultAction = Object.values(reportActions ?? {}).find((reportAction) => reportAction?.actionName === CONST.REPORT.ACTIONS.TYPE.ADD_COMMENT); reportActionID = resultAction?.reportActionID ?? ''; expect(resultAction?.message).toEqual(REPORT_ACTION.message); @@ -2798,7 +2798,7 @@ describe('actions/IOU', () => { Report.addComment(IOU_REPORT_ID, 'Testing a comment'); await waitForBatchedUpdates(); - resultAction = Object.values(reportActions ?? {}).find((reportAction) => reportAction?.actionName === CONST.REPORT.ACTIONS.TYPE.ADDCOMMENT); + resultAction = Object.values(reportActions ?? {}).find((reportAction) => reportAction?.actionName === CONST.REPORT.ACTIONS.TYPE.ADD_COMMENT); reportActionID = resultAction?.reportActionID ?? ''; expect(resultAction?.message).toEqual(REPORT_ACTION.message); @@ -2931,7 +2931,7 @@ describe('actions/IOU', () => { Report.addComment(IOU_REPORT_ID, 'Testing a comment'); await waitForBatchedUpdates(); - const resultAction = Object.values(reportActions ?? {}).find((reportAction) => reportAction?.actionName === CONST.REPORT.ACTIONS.TYPE.ADDCOMMENT); + const resultAction = Object.values(reportActions ?? {}).find((reportAction) => reportAction?.actionName === CONST.REPORT.ACTIONS.TYPE.ADD_COMMENT); reportActionID = resultAction?.reportActionID; expect(resultAction?.message).toEqual(REPORT_ACTION.message); diff --git a/tests/actions/ReportTest.ts b/tests/actions/ReportTest.ts index 6f1ea2c5ee7f..28aa84babfb5 100644 --- a/tests/actions/ReportTest.ts +++ b/tests/actions/ReportTest.ts @@ -60,7 +60,7 @@ describe('actions/Report', () => { const REPORT_ID = '1'; let reportActionID: string; const REPORT_ACTION = { - actionName: CONST.REPORT.ACTIONS.TYPE.ADDCOMMENT, + actionName: CONST.REPORT.ACTIONS.TYPE.ADD_COMMENT, actorAccountID: TEST_USER_ACCOUNT_ID, automatic: false, avatar: 'https://d2k5nsl2zxldvw.cloudfront.net/images/avatars/avatar_3.png', @@ -246,7 +246,7 @@ describe('actions/Report', () => { key: `${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${REPORT_ID}`, value: { 1: { - actionName: CONST.REPORT.ACTIONS.TYPE.ADDCOMMENT, + actionName: CONST.REPORT.ACTIONS.TYPE.ADD_COMMENT, actorAccountID: USER_2_ACCOUNT_ID, automatic: false, avatar: 'https://d2k5nsl2zxldvw.cloudfront.net/images/avatars/avatar_3.png', @@ -333,7 +333,7 @@ describe('actions/Report', () => { expect(report?.lastMessageText).toBe('Current User Comment 3'); const USER_1_BASE_ACTION = { - actionName: CONST.REPORT.ACTIONS.TYPE.ADDCOMMENT, + actionName: CONST.REPORT.ACTIONS.TYPE.ADD_COMMENT, actorAccountID: USER_1_ACCOUNT_ID, automatic: false, avatar: 'https://d2k5nsl2zxldvw.cloudfront.net/images/avatars/avatar_3.png', @@ -514,7 +514,7 @@ describe('actions/Report', () => { const TEST_USER_ACCOUNT_ID = 1; const REPORT_ID = '1'; const REPORT_ACTION = { - actionName: CONST.REPORT.ACTIONS.TYPE.ADDCOMMENT, + actionName: CONST.REPORT.ACTIONS.TYPE.ADD_COMMENT, }; // Setup user and pusher listeners diff --git a/tests/perf-test/ModifiedExpenseMessage.perf-test.ts b/tests/perf-test/ModifiedExpenseMessage.perf-test.ts index df9ffca59b7d..1711badd8c05 100644 --- a/tests/perf-test/ModifiedExpenseMessage.perf-test.ts +++ b/tests/perf-test/ModifiedExpenseMessage.perf-test.ts @@ -44,7 +44,7 @@ test('[ModifiedExpenseMessage] getForReportAction on 1k reports and policies', a const report = createRandomReport(1); const reportAction = { ...createRandomReportAction(1), - actionName: CONST.REPORT.ACTIONS.TYPE.MODIFIEDEXPENSE, + actionName: CONST.REPORT.ACTIONS.TYPE.MODIFIED_EXPENSE, originalMessage: { amount: randAmount(), currency: CONST.CURRENCY.USD, diff --git a/tests/perf-test/ReportUtils.perf-test.ts b/tests/perf-test/ReportUtils.perf-test.ts index ae3429bb9c01..40098d00ee6f 100644 --- a/tests/perf-test/ReportUtils.perf-test.ts +++ b/tests/perf-test/ReportUtils.perf-test.ts @@ -66,7 +66,7 @@ describe('ReportUtils', () => { test('[ReportUtils] canDeleteReportAction on 1k reports and policies', async () => { const reportID = '1'; - const reportAction = {...createRandomReportAction(1), actionName: CONST.REPORT.ACTIONS.TYPE.ADDCOMMENT} as unknown as ReportAction; + const reportAction = {...createRandomReportAction(1), actionName: CONST.REPORT.ACTIONS.TYPE.ADD_COMMENT} as unknown as ReportAction; await waitForBatchedUpdates(); await measureFunction(() => ReportUtils.canDeleteReportAction(reportAction, reportID)); diff --git a/tests/ui/UnreadIndicatorsTest.tsx b/tests/ui/UnreadIndicatorsTest.tsx index 2aeee2cc77bf..a7f689036d05 100644 --- a/tests/ui/UnreadIndicatorsTest.tsx +++ b/tests/ui/UnreadIndicatorsTest.tsx @@ -405,7 +405,7 @@ describe('Unread Indicators', () => { reportActionID: createdReportActionID, }, [commentReportActionID]: { - actionName: CONST.REPORT.ACTIONS.TYPE.ADDCOMMENT, + actionName: CONST.REPORT.ACTIONS.TYPE.ADD_COMMENT, actorAccountID: USER_C_ACCOUNT_ID, person: [{type: 'TEXT', style: 'strong', text: 'User C'}], created: format(NEW_REPORT_FIST_MESSAGE_CREATED_DATE, CONST.DATE.FNS_DB_FORMAT_STRING), diff --git a/tests/unit/MigrationTest.ts b/tests/unit/MigrationTest.ts index e50c7bdcee55..69e0e80e589a 100644 --- a/tests/unit/MigrationTest.ts +++ b/tests/unit/MigrationTest.ts @@ -42,10 +42,10 @@ describe('Migrations', () => { 1: { reportActionID: '1', created: '', - actionName: CONST.REPORT.ACTIONS.TYPE.MARKEDREIMBURSED, + actionName: CONST.REPORT.ACTIONS.TYPE.MARKED_REIMBURSED, reportID: '1', }, - 2: {reportActionID: '2', created: '', actionName: CONST.REPORT.ACTIONS.TYPE.MARKEDREIMBURSED, reportID: '1'}, + 2: {reportActionID: '2', created: '', actionName: CONST.REPORT.ACTIONS.TYPE.MARKED_REIMBURSED, reportID: '1'}, }, ], (item) => item[1].reportID ?? '', @@ -78,14 +78,14 @@ describe('Migrations', () => { reportActionID: '1', previousReportActionID: '0', created: '', - actionName: CONST.REPORT.ACTIONS.TYPE.MARKEDREIMBURSED, + actionName: CONST.REPORT.ACTIONS.TYPE.MARKED_REIMBURSED, reportID: '1', }, 2: { reportActionID: '2', previousReportActionID: '1', created: '', - actionName: CONST.REPORT.ACTIONS.TYPE.MARKEDREIMBURSED, + actionName: CONST.REPORT.ACTIONS.TYPE.MARKED_REIMBURSED, reportID: '1', }, }, @@ -126,13 +126,13 @@ describe('Migrations', () => { 1: { reportActionID: '1', created: '', - actionName: CONST.REPORT.ACTIONS.TYPE.MARKEDREIMBURSED, + actionName: CONST.REPORT.ACTIONS.TYPE.MARKED_REIMBURSED, reportID: '4', }, 2: { reportActionID: '2', created: '', - actionName: CONST.REPORT.ACTIONS.TYPE.MARKEDREIMBURSED, + actionName: CONST.REPORT.ACTIONS.TYPE.MARKED_REIMBURSED, reportID: '4', }, }, @@ -175,14 +175,14 @@ describe('Migrations', () => { reportActionID: '1', previousReportActionID: '10', created: '', - actionName: CONST.REPORT.ACTIONS.TYPE.MARKEDREIMBURSED, + actionName: CONST.REPORT.ACTIONS.TYPE.MARKED_REIMBURSED, reportID: '4', }, 2: { reportActionID: '2', previousReportActionID: '23', created: '', - actionName: CONST.REPORT.ACTIONS.TYPE.MARKEDREIMBURSED, + actionName: CONST.REPORT.ACTIONS.TYPE.MARKED_REIMBURSED, reportID: '4', }, }, diff --git a/tests/unit/ModifiedExpenseMessageTest.ts b/tests/unit/ModifiedExpenseMessageTest.ts index 5880f028d216..ff90124215cf 100644 --- a/tests/unit/ModifiedExpenseMessageTest.ts +++ b/tests/unit/ModifiedExpenseMessageTest.ts @@ -9,7 +9,7 @@ describe('ModifiedExpenseMessage', () => { describe('when the amount is changed', () => { const reportAction = { ...createRandomReportAction(1), - actionName: CONST.REPORT.ACTIONS.TYPE.MODIFIEDEXPENSE, + actionName: CONST.REPORT.ACTIONS.TYPE.MODIFIED_EXPENSE, originalMessage: { amount: 1800, currency: CONST.CURRENCY.USD, @@ -30,7 +30,7 @@ describe('ModifiedExpenseMessage', () => { describe('when the amount is changed while the original value was partial', () => { const reportAction = { ...createRandomReportAction(1), - actionName: CONST.REPORT.ACTIONS.TYPE.MODIFIEDEXPENSE, + actionName: CONST.REPORT.ACTIONS.TYPE.MODIFIED_EXPENSE, originalMessage: { amount: 1800, currency: CONST.CURRENCY.USD, @@ -51,7 +51,7 @@ describe('ModifiedExpenseMessage', () => { describe('when the amount is changed and the description is removed', () => { const reportAction = { ...createRandomReportAction(1), - actionName: CONST.REPORT.ACTIONS.TYPE.MODIFIEDEXPENSE, + actionName: CONST.REPORT.ACTIONS.TYPE.MODIFIED_EXPENSE, originalMessage: { amount: 1800, currency: CONST.CURRENCY.USD, @@ -74,7 +74,7 @@ describe('ModifiedExpenseMessage', () => { describe('when the amount is changed, the description is removed, and category is set', () => { const reportAction = { ...createRandomReportAction(1), - actionName: CONST.REPORT.ACTIONS.TYPE.MODIFIEDEXPENSE, + actionName: CONST.REPORT.ACTIONS.TYPE.MODIFIED_EXPENSE, originalMessage: { amount: 1800, currency: CONST.CURRENCY.USD, @@ -99,7 +99,7 @@ describe('ModifiedExpenseMessage', () => { describe('when the amount and merchant are changed', () => { const reportAction = { ...createRandomReportAction(1), - actionName: CONST.REPORT.ACTIONS.TYPE.MODIFIEDEXPENSE, + actionName: CONST.REPORT.ACTIONS.TYPE.MODIFIED_EXPENSE, originalMessage: { merchant: 'Taco Bell', oldMerchant: 'Big Belly', @@ -122,7 +122,7 @@ describe('ModifiedExpenseMessage', () => { describe('when the amount and merchant are changed, the description is removed, and category is set', () => { const reportAction = { ...createRandomReportAction(1), - actionName: CONST.REPORT.ACTIONS.TYPE.MODIFIEDEXPENSE, + actionName: CONST.REPORT.ACTIONS.TYPE.MODIFIED_EXPENSE, originalMessage: { merchant: 'Taco Bell', oldMerchant: 'Big Belly', @@ -150,7 +150,7 @@ describe('ModifiedExpenseMessage', () => { describe('when the amount, comment and merchant are changed', () => { const reportAction = { ...createRandomReportAction(1), - actionName: CONST.REPORT.ACTIONS.TYPE.MODIFIEDEXPENSE, + actionName: CONST.REPORT.ACTIONS.TYPE.MODIFIED_EXPENSE, originalMessage: { merchant: 'Taco Bell', oldMerchant: 'Big Belly', @@ -176,7 +176,7 @@ describe('ModifiedExpenseMessage', () => { describe('when the merchant is removed', () => { const reportAction = { ...createRandomReportAction(1), - actionName: CONST.REPORT.ACTIONS.TYPE.MODIFIEDEXPENSE, + actionName: CONST.REPORT.ACTIONS.TYPE.MODIFIED_EXPENSE, originalMessage: { merchant: '', oldMerchant: 'Big Belly', @@ -195,7 +195,7 @@ describe('ModifiedExpenseMessage', () => { describe('when the merchant is changed while the previous merchant was partial', () => { const reportAction = { ...createRandomReportAction(1), - actionName: CONST.REPORT.ACTIONS.TYPE.MODIFIEDEXPENSE, + actionName: CONST.REPORT.ACTIONS.TYPE.MODIFIED_EXPENSE, originalMessage: { merchant: 'KFC', oldMerchant: CONST.TRANSACTION.PARTIAL_TRANSACTION_MERCHANT, @@ -214,7 +214,7 @@ describe('ModifiedExpenseMessage', () => { describe('when the merchant and the description are removed', () => { const reportAction = { ...createRandomReportAction(1), - actionName: CONST.REPORT.ACTIONS.TYPE.MODIFIEDEXPENSE, + actionName: CONST.REPORT.ACTIONS.TYPE.MODIFIED_EXPENSE, originalMessage: { merchant: '', oldMerchant: 'Big Belly', @@ -235,7 +235,7 @@ describe('ModifiedExpenseMessage', () => { describe('when the merchant, the category and the description are removed', () => { const reportAction = { ...createRandomReportAction(1), - actionName: CONST.REPORT.ACTIONS.TYPE.MODIFIEDEXPENSE, + actionName: CONST.REPORT.ACTIONS.TYPE.MODIFIED_EXPENSE, originalMessage: { merchant: '', oldMerchant: 'Big Belly', @@ -258,7 +258,7 @@ describe('ModifiedExpenseMessage', () => { describe('when the merchant is set', () => { const reportAction = { ...createRandomReportAction(1), - actionName: CONST.REPORT.ACTIONS.TYPE.MODIFIEDEXPENSE, + actionName: CONST.REPORT.ACTIONS.TYPE.MODIFIED_EXPENSE, originalMessage: { oldMerchant: '', merchant: 'Big Belly', @@ -277,7 +277,7 @@ describe('ModifiedExpenseMessage', () => { describe('when the merchant and the description are set', () => { const reportAction = { ...createRandomReportAction(1), - actionName: CONST.REPORT.ACTIONS.TYPE.MODIFIEDEXPENSE, + actionName: CONST.REPORT.ACTIONS.TYPE.MODIFIED_EXPENSE, originalMessage: { oldMerchant: '', merchant: 'Big Belly', @@ -298,7 +298,7 @@ describe('ModifiedExpenseMessage', () => { describe('when the merchant, the category and the description are set', () => { const reportAction = { ...createRandomReportAction(1), - actionName: CONST.REPORT.ACTIONS.TYPE.MODIFIEDEXPENSE, + actionName: CONST.REPORT.ACTIONS.TYPE.MODIFIED_EXPENSE, originalMessage: { oldMerchant: '', merchant: 'Big Belly', @@ -321,7 +321,7 @@ describe('ModifiedExpenseMessage', () => { describe('when the created date is changed', () => { const reportAction = { ...createRandomReportAction(1), - actionName: CONST.REPORT.ACTIONS.TYPE.MODIFIEDEXPENSE, + actionName: CONST.REPORT.ACTIONS.TYPE.MODIFIED_EXPENSE, originalMessage: { created: '2023-12-27', oldCreated: '2023-12-26', @@ -340,7 +340,7 @@ describe('ModifiedExpenseMessage', () => { describe('when the created date was not changed', () => { const reportAction = { ...createRandomReportAction(1), - actionName: CONST.REPORT.ACTIONS.TYPE.MODIFIEDEXPENSE, + actionName: CONST.REPORT.ACTIONS.TYPE.MODIFIED_EXPENSE, originalMessage: { created: '2023-12-27', }, diff --git a/tests/unit/ReportActionsUtilsTest.ts b/tests/unit/ReportActionsUtilsTest.ts index a926d0589e80..3fd464f938f4 100644 --- a/tests/unit/ReportActionsUtilsTest.ts +++ b/tests/unit/ReportActionsUtilsTest.ts @@ -35,7 +35,7 @@ describe('ReportActionsUtils', () => { { created: '2022-11-09 22:27:01.825', reportActionID: '8401445780099176', - actionName: CONST.REPORT.ACTIONS.TYPE.ADDCOMMENT, + actionName: CONST.REPORT.ACTIONS.TYPE.ADD_COMMENT, originalMessage: { html: 'Hello world', whisperedTo: [], @@ -44,7 +44,7 @@ describe('ReportActionsUtils', () => { { created: '2022-11-09 22:27:01.600', reportActionID: '6401435781022176', - actionName: CONST.REPORT.ACTIONS.TYPE.ADDCOMMENT, + actionName: CONST.REPORT.ACTIONS.TYPE.ADD_COMMENT, originalMessage: { html: 'Hello world', whisperedTo: [], @@ -55,7 +55,7 @@ describe('ReportActionsUtils', () => { { created: '2022-11-09 22:26:48.789', reportActionID: '2962390724708756', - actionName: CONST.REPORT.ACTIONS.TYPE.ADDCOMMENT, + actionName: CONST.REPORT.ACTIONS.TYPE.ADD_COMMENT, originalMessage: { html: 'Hello world', whisperedTo: [], @@ -64,7 +64,7 @@ describe('ReportActionsUtils', () => { { created: '2022-11-09 22:26:48.789', reportActionID: '1609646094152486', - actionName: CONST.REPORT.ACTIONS.TYPE.ADDCOMMENT, + actionName: CONST.REPORT.ACTIONS.TYPE.ADD_COMMENT, originalMessage: { html: 'Hello world', whisperedTo: [], @@ -73,7 +73,7 @@ describe('ReportActionsUtils', () => { { created: '2022-11-09 22:26:48.789', reportActionID: '1661970171066218', - actionName: CONST.REPORT.ACTIONS.TYPE.ADDCOMMENT, + actionName: CONST.REPORT.ACTIONS.TYPE.ADD_COMMENT, originalMessage: { html: 'Hello world', whisperedTo: [], @@ -84,7 +84,7 @@ describe('ReportActionsUtils', () => { { created: '2022-11-09 22:26:48.789', reportActionID: '1609646094152486', - actionName: CONST.REPORT.ACTIONS.TYPE.ADDCOMMENT, + actionName: CONST.REPORT.ACTIONS.TYPE.ADD_COMMENT, originalMessage: { html: 'Hello world', whisperedTo: [], @@ -93,7 +93,7 @@ describe('ReportActionsUtils', () => { { created: '2022-11-09 22:26:48.789', reportActionID: '1661970171066218', - actionName: CONST.REPORT.ACTIONS.TYPE.ADDCOMMENT, + actionName: CONST.REPORT.ACTIONS.TYPE.ADD_COMMENT, originalMessage: { html: 'Hello world', whisperedTo: [], @@ -102,7 +102,7 @@ describe('ReportActionsUtils', () => { { created: '2022-11-09 22:26:48.789', reportActionID: '2962390724708756', - actionName: CONST.REPORT.ACTIONS.TYPE.ADDCOMMENT, + actionName: CONST.REPORT.ACTIONS.TYPE.ADD_COMMENT, originalMessage: { html: 'Hello world', whisperedTo: [], @@ -111,7 +111,7 @@ describe('ReportActionsUtils', () => { { created: '2022-11-09 22:27:01.600', reportActionID: '6401435781022176', - actionName: CONST.REPORT.ACTIONS.TYPE.ADDCOMMENT, + actionName: CONST.REPORT.ACTIONS.TYPE.ADD_COMMENT, originalMessage: { html: 'Hello world', whisperedTo: [], @@ -120,7 +120,7 @@ describe('ReportActionsUtils', () => { { created: '2022-11-09 22:27:01.825', reportActionID: '8401445780099176', - actionName: CONST.REPORT.ACTIONS.TYPE.ADDCOMMENT, + actionName: CONST.REPORT.ACTIONS.TYPE.ADD_COMMENT, originalMessage: { html: 'Hello world', whisperedTo: [], @@ -134,7 +134,7 @@ describe('ReportActionsUtils', () => { { created: '2023-01-10 22:25:47.132', reportActionID: '3', - actionName: CONST.REPORT.ACTIONS.TYPE.ADDCOMMENT, + actionName: CONST.REPORT.ACTIONS.TYPE.ADD_COMMENT, originalMessage: { html: 'Hello world', whisperedTo: [], @@ -152,7 +152,7 @@ describe('ReportActionsUtils', () => { { created: '2023-01-10 22:25:47.132', reportActionID: '1', - actionName: CONST.REPORT.ACTIONS.TYPE.ADDCOMMENT, + actionName: CONST.REPORT.ACTIONS.TYPE.ADD_COMMENT, originalMessage: { html: 'Hello world', whisperedTo: [], @@ -173,7 +173,7 @@ describe('ReportActionsUtils', () => { { created: '2023-01-10 22:25:47.132', reportActionID: '1', - actionName: CONST.REPORT.ACTIONS.TYPE.ADDCOMMENT, + actionName: CONST.REPORT.ACTIONS.TYPE.ADD_COMMENT, originalMessage: { html: 'Hello world', whisperedTo: [], @@ -182,7 +182,7 @@ describe('ReportActionsUtils', () => { { created: '2023-01-10 22:25:47.132', reportActionID: '3', - actionName: CONST.REPORT.ACTIONS.TYPE.ADDCOMMENT, + actionName: CONST.REPORT.ACTIONS.TYPE.ADD_COMMENT, originalMessage: { html: 'Hello world', whisperedTo: [], @@ -209,7 +209,7 @@ describe('ReportActionsUtils', () => { { created: '2022-11-13 22:27:01.825', reportActionID: '8401445780099176', - actionName: CONST.REPORT.ACTIONS.TYPE.ADDCOMMENT, + actionName: CONST.REPORT.ACTIONS.TYPE.ADD_COMMENT, originalMessage: { html: 'Hello world', whisperedTo: [], @@ -276,14 +276,14 @@ describe('ReportActionsUtils', () => { { created: '2022-11-09 22:27:01.825', reportActionID: '8049485084562457', - actionName: CONST.REPORT.ACTIONS.TYPE.POLICYCHANGELOG.UPDATE_FIELD, + actionName: CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.UPDATE_FIELD, originalMessage: {}, message: [{html: 'updated the Approval Mode from "Submit and Approve" to "Submit and Close"', type: 'Action type', text: 'Action text'}], }, { created: '2022-11-08 22:27:06.825', reportActionID: '1661970171066216', - actionName: CONST.REPORT.ACTIONS.TYPE.REIMBURSEMENTQUEUED, + actionName: CONST.REPORT.ACTIONS.TYPE.REIMBURSEMENT_QUEUED, originalMessage: { paymentType: 'ACH', }, @@ -292,7 +292,7 @@ describe('ReportActionsUtils', () => { { created: '2022-11-06 22:27:08.825', reportActionID: '1661970171066220', - actionName: CONST.REPORT.ACTIONS.TYPE.TASKEDITED, + actionName: CONST.REPORT.ACTIONS.TYPE.TASK_EDITED, originalMessage: { html: 'Hello world', whisperedTo: [], @@ -310,7 +310,7 @@ describe('ReportActionsUtils', () => { { created: '2022-11-13 22:27:01.825', reportActionID: '8401445780099176', - actionName: CONST.REPORT.ACTIONS.TYPE.ADDCOMMENT, + actionName: CONST.REPORT.ACTIONS.TYPE.ADD_COMMENT, originalMessage: { html: 'Hello world', whisperedTo: [], @@ -401,7 +401,7 @@ describe('ReportActionsUtils', () => { { created: '2022-11-13 22:27:01.825', reportActionID: '8401445780099176', - actionName: CONST.REPORT.ACTIONS.TYPE.ADDCOMMENT, + actionName: CONST.REPORT.ACTIONS.TYPE.ADD_COMMENT, originalMessage: { html: 'Hello world', whisperedTo: [], @@ -417,7 +417,7 @@ describe('ReportActionsUtils', () => { { created: '2022-11-12 22:27:01.825', reportActionID: '8401445780099175', - actionName: CONST.REPORT.ACTIONS.TYPE.ADDCOMMENT, + actionName: CONST.REPORT.ACTIONS.TYPE.ADD_COMMENT, originalMessage: { html: 'Hello world', whisperedTo: [], @@ -428,7 +428,7 @@ describe('ReportActionsUtils', () => { { created: '2022-11-11 22:27:01.825', reportActionID: '8401445780099174', - actionName: CONST.REPORT.ACTIONS.TYPE.ADDCOMMENT, + actionName: CONST.REPORT.ACTIONS.TYPE.ADD_COMMENT, originalMessage: { html: 'Hello world', whisperedTo: [], @@ -449,7 +449,7 @@ describe('ReportActionsUtils', () => { reportActionID: '1', previousReportActionID: undefined, created: '2022-11-13 22:27:01.825', - actionName: CONST.REPORT.ACTIONS.TYPE.ADDCOMMENT, + actionName: CONST.REPORT.ACTIONS.TYPE.ADD_COMMENT, originalMessage: { html: 'Hello world', whisperedTo: [], @@ -466,7 +466,7 @@ describe('ReportActionsUtils', () => { reportActionID: '2', previousReportActionID: '1', created: '2022-11-13 22:27:01.825', - actionName: CONST.REPORT.ACTIONS.TYPE.ADDCOMMENT, + actionName: CONST.REPORT.ACTIONS.TYPE.ADD_COMMENT, originalMessage: { html: 'Hello world', whisperedTo: [], @@ -483,7 +483,7 @@ describe('ReportActionsUtils', () => { reportActionID: '3', previousReportActionID: '2', created: '2022-11-13 22:27:01.825', - actionName: CONST.REPORT.ACTIONS.TYPE.ADDCOMMENT, + actionName: CONST.REPORT.ACTIONS.TYPE.ADD_COMMENT, originalMessage: { html: 'Hello world', whisperedTo: [], @@ -500,7 +500,7 @@ describe('ReportActionsUtils', () => { reportActionID: '4', previousReportActionID: '3', created: '2022-11-13 22:27:01.825', - actionName: CONST.REPORT.ACTIONS.TYPE.ADDCOMMENT, + actionName: CONST.REPORT.ACTIONS.TYPE.ADD_COMMENT, originalMessage: { html: 'Hello world', whisperedTo: [], @@ -517,7 +517,7 @@ describe('ReportActionsUtils', () => { reportActionID: '5', previousReportActionID: '4', created: '2022-11-13 22:27:01.825', - actionName: CONST.REPORT.ACTIONS.TYPE.ADDCOMMENT, + actionName: CONST.REPORT.ACTIONS.TYPE.ADD_COMMENT, originalMessage: { html: 'Hello world', whisperedTo: [], @@ -534,7 +534,7 @@ describe('ReportActionsUtils', () => { reportActionID: '6', previousReportActionID: '5', created: '2022-11-13 22:27:01.825', - actionName: CONST.REPORT.ACTIONS.TYPE.ADDCOMMENT, + actionName: CONST.REPORT.ACTIONS.TYPE.ADD_COMMENT, originalMessage: { html: 'Hello world', whisperedTo: [], @@ -551,7 +551,7 @@ describe('ReportActionsUtils', () => { reportActionID: '7', previousReportActionID: '6', created: '2022-11-13 22:27:01.825', - actionName: CONST.REPORT.ACTIONS.TYPE.ADDCOMMENT, + actionName: CONST.REPORT.ACTIONS.TYPE.ADD_COMMENT, originalMessage: { html: 'Hello world', whisperedTo: [], @@ -570,7 +570,7 @@ describe('ReportActionsUtils', () => { reportActionID: '9', previousReportActionID: '8', created: '2022-11-13 22:27:01.825', - actionName: CONST.REPORT.ACTIONS.TYPE.ADDCOMMENT, + actionName: CONST.REPORT.ACTIONS.TYPE.ADD_COMMENT, originalMessage: { html: 'Hello world', whisperedTo: [], @@ -587,7 +587,7 @@ describe('ReportActionsUtils', () => { reportActionID: '10', previousReportActionID: '9', created: '2022-11-13 22:27:01.825', - actionName: CONST.REPORT.ACTIONS.TYPE.ADDCOMMENT, + actionName: CONST.REPORT.ACTIONS.TYPE.ADD_COMMENT, originalMessage: { html: 'Hello world', whisperedTo: [], @@ -604,7 +604,7 @@ describe('ReportActionsUtils', () => { reportActionID: '11', previousReportActionID: '10', created: '2022-11-13 22:27:01.825', - actionName: CONST.REPORT.ACTIONS.TYPE.ADDCOMMENT, + actionName: CONST.REPORT.ACTIONS.TYPE.ADD_COMMENT, originalMessage: { html: 'Hello world', whisperedTo: [], @@ -621,7 +621,7 @@ describe('ReportActionsUtils', () => { reportActionID: '12', previousReportActionID: '11', created: '2022-11-13 22:27:01.825', - actionName: CONST.REPORT.ACTIONS.TYPE.ADDCOMMENT, + actionName: CONST.REPORT.ACTIONS.TYPE.ADD_COMMENT, originalMessage: { html: 'Hello world', whisperedTo: [], @@ -640,7 +640,7 @@ describe('ReportActionsUtils', () => { reportActionID: '14', previousReportActionID: '13', created: '2022-11-13 22:27:01.825', - actionName: CONST.REPORT.ACTIONS.TYPE.ADDCOMMENT, + actionName: CONST.REPORT.ACTIONS.TYPE.ADD_COMMENT, originalMessage: { html: 'Hello world', whisperedTo: [], @@ -657,7 +657,7 @@ describe('ReportActionsUtils', () => { reportActionID: '15', previousReportActionID: '14', created: '2022-11-13 22:27:01.825', - actionName: CONST.REPORT.ACTIONS.TYPE.ADDCOMMENT, + actionName: CONST.REPORT.ACTIONS.TYPE.ADD_COMMENT, originalMessage: { html: 'Hello world', whisperedTo: [], @@ -674,7 +674,7 @@ describe('ReportActionsUtils', () => { reportActionID: '16', previousReportActionID: '15', created: '2022-11-13 22:27:01.825', - actionName: CONST.REPORT.ACTIONS.TYPE.ADDCOMMENT, + actionName: CONST.REPORT.ACTIONS.TYPE.ADD_COMMENT, originalMessage: { html: 'Hello world', whisperedTo: [], @@ -691,7 +691,7 @@ describe('ReportActionsUtils', () => { reportActionID: '17', previousReportActionID: '16', created: '2022-11-13 22:27:01.825', - actionName: CONST.REPORT.ACTIONS.TYPE.ADDCOMMENT, + actionName: CONST.REPORT.ACTIONS.TYPE.ADD_COMMENT, originalMessage: { html: 'Hello world', whisperedTo: [], @@ -711,7 +711,7 @@ describe('ReportActionsUtils', () => { reportActionID: '1', previousReportActionID: undefined, created: '2022-11-13 22:27:01.825', - actionName: CONST.REPORT.ACTIONS.TYPE.ADDCOMMENT, + actionName: CONST.REPORT.ACTIONS.TYPE.ADD_COMMENT, originalMessage: { html: 'Hello world', whisperedTo: [], @@ -728,7 +728,7 @@ describe('ReportActionsUtils', () => { reportActionID: '2', previousReportActionID: '1', created: '2022-11-13 22:27:01.825', - actionName: CONST.REPORT.ACTIONS.TYPE.ADDCOMMENT, + actionName: CONST.REPORT.ACTIONS.TYPE.ADD_COMMENT, originalMessage: { html: 'Hello world', whisperedTo: [], @@ -745,7 +745,7 @@ describe('ReportActionsUtils', () => { reportActionID: '3', previousReportActionID: '2', created: '2022-11-13 22:27:01.825', - actionName: CONST.REPORT.ACTIONS.TYPE.ADDCOMMENT, + actionName: CONST.REPORT.ACTIONS.TYPE.ADD_COMMENT, originalMessage: { html: 'Hello world', whisperedTo: [], @@ -762,7 +762,7 @@ describe('ReportActionsUtils', () => { reportActionID: '4', previousReportActionID: '3', created: '2022-11-13 22:27:01.825', - actionName: CONST.REPORT.ACTIONS.TYPE.ADDCOMMENT, + actionName: CONST.REPORT.ACTIONS.TYPE.ADD_COMMENT, originalMessage: { html: 'Hello world', whisperedTo: [], @@ -779,7 +779,7 @@ describe('ReportActionsUtils', () => { reportActionID: '5', previousReportActionID: '4', created: '2022-11-13 22:27:01.825', - actionName: CONST.REPORT.ACTIONS.TYPE.ADDCOMMENT, + actionName: CONST.REPORT.ACTIONS.TYPE.ADD_COMMENT, originalMessage: { html: 'Hello world', whisperedTo: [], @@ -796,7 +796,7 @@ describe('ReportActionsUtils', () => { reportActionID: '6', previousReportActionID: '5', created: '2022-11-13 22:27:01.825', - actionName: CONST.REPORT.ACTIONS.TYPE.ADDCOMMENT, + actionName: CONST.REPORT.ACTIONS.TYPE.ADD_COMMENT, originalMessage: { html: 'Hello world', whisperedTo: [], @@ -813,7 +813,7 @@ describe('ReportActionsUtils', () => { reportActionID: '7', previousReportActionID: '6', created: '2022-11-13 22:27:01.825', - actionName: CONST.REPORT.ACTIONS.TYPE.ADDCOMMENT, + actionName: CONST.REPORT.ACTIONS.TYPE.ADD_COMMENT, originalMessage: { html: 'Hello world', whisperedTo: [], @@ -840,7 +840,7 @@ describe('ReportActionsUtils', () => { reportActionID: '1', previousReportActionID: undefined, created: '2022-11-13 22:27:01.825', - actionName: CONST.REPORT.ACTIONS.TYPE.ADDCOMMENT, + actionName: CONST.REPORT.ACTIONS.TYPE.ADD_COMMENT, originalMessage: { html: 'Hello world', whisperedTo: [], @@ -857,7 +857,7 @@ describe('ReportActionsUtils', () => { reportActionID: '2', previousReportActionID: '1', created: '2022-11-13 22:27:01.825', - actionName: CONST.REPORT.ACTIONS.TYPE.ADDCOMMENT, + actionName: CONST.REPORT.ACTIONS.TYPE.ADD_COMMENT, originalMessage: { html: 'Hello world', whisperedTo: [], @@ -874,7 +874,7 @@ describe('ReportActionsUtils', () => { reportActionID: '3', previousReportActionID: '2', created: '2022-11-13 22:27:01.825', - actionName: CONST.REPORT.ACTIONS.TYPE.ADDCOMMENT, + actionName: CONST.REPORT.ACTIONS.TYPE.ADD_COMMENT, originalMessage: { html: 'Hello world', whisperedTo: [], @@ -891,7 +891,7 @@ describe('ReportActionsUtils', () => { reportActionID: '4', previousReportActionID: '3', created: '2022-11-13 22:27:01.825', - actionName: CONST.REPORT.ACTIONS.TYPE.ADDCOMMENT, + actionName: CONST.REPORT.ACTIONS.TYPE.ADD_COMMENT, originalMessage: { html: 'Hello world', whisperedTo: [], @@ -908,7 +908,7 @@ describe('ReportActionsUtils', () => { reportActionID: '5', previousReportActionID: '4', created: '2022-11-13 22:27:01.825', - actionName: CONST.REPORT.ACTIONS.TYPE.ADDCOMMENT, + actionName: CONST.REPORT.ACTIONS.TYPE.ADD_COMMENT, originalMessage: { html: 'Hello world', whisperedTo: [], @@ -925,7 +925,7 @@ describe('ReportActionsUtils', () => { reportActionID: '6', previousReportActionID: '5', created: '2022-11-13 22:27:01.825', - actionName: CONST.REPORT.ACTIONS.TYPE.ADDCOMMENT, + actionName: CONST.REPORT.ACTIONS.TYPE.ADD_COMMENT, originalMessage: { html: 'Hello world', whisperedTo: [], @@ -942,7 +942,7 @@ describe('ReportActionsUtils', () => { reportActionID: '7', previousReportActionID: '6', created: '2022-11-13 22:27:01.825', - actionName: CONST.REPORT.ACTIONS.TYPE.ADDCOMMENT, + actionName: CONST.REPORT.ACTIONS.TYPE.ADD_COMMENT, originalMessage: { html: 'Hello world', whisperedTo: [], @@ -961,7 +961,7 @@ describe('ReportActionsUtils', () => { reportActionID: '9', previousReportActionID: '8', created: '2022-11-13 22:27:01.825', - actionName: CONST.REPORT.ACTIONS.TYPE.ADDCOMMENT, + actionName: CONST.REPORT.ACTIONS.TYPE.ADD_COMMENT, originalMessage: { html: 'Hello world', whisperedTo: [], @@ -978,7 +978,7 @@ describe('ReportActionsUtils', () => { reportActionID: '10', previousReportActionID: '9', created: '2022-11-13 22:27:01.825', - actionName: CONST.REPORT.ACTIONS.TYPE.ADDCOMMENT, + actionName: CONST.REPORT.ACTIONS.TYPE.ADD_COMMENT, originalMessage: { html: 'Hello world', whisperedTo: [], @@ -995,7 +995,7 @@ describe('ReportActionsUtils', () => { reportActionID: '11', previousReportActionID: '10', created: '2022-11-13 22:27:01.825', - actionName: CONST.REPORT.ACTIONS.TYPE.ADDCOMMENT, + actionName: CONST.REPORT.ACTIONS.TYPE.ADD_COMMENT, originalMessage: { html: 'Hello world', whisperedTo: [], @@ -1012,7 +1012,7 @@ describe('ReportActionsUtils', () => { reportActionID: '12', previousReportActionID: '11', created: '2022-11-13 22:27:01.825', - actionName: CONST.REPORT.ACTIONS.TYPE.ADDCOMMENT, + actionName: CONST.REPORT.ACTIONS.TYPE.ADD_COMMENT, originalMessage: { html: 'Hello world', whisperedTo: [], @@ -1031,7 +1031,7 @@ describe('ReportActionsUtils', () => { reportActionID: '14', previousReportActionID: '13', created: '2022-11-13 22:27:01.825', - actionName: CONST.REPORT.ACTIONS.TYPE.ADDCOMMENT, + actionName: CONST.REPORT.ACTIONS.TYPE.ADD_COMMENT, originalMessage: { html: 'Hello world', whisperedTo: [], @@ -1048,7 +1048,7 @@ describe('ReportActionsUtils', () => { reportActionID: '15', previousReportActionID: '14', created: '2022-11-13 22:27:01.825', - actionName: CONST.REPORT.ACTIONS.TYPE.ADDCOMMENT, + actionName: CONST.REPORT.ACTIONS.TYPE.ADD_COMMENT, originalMessage: { html: 'Hello world', whisperedTo: [], @@ -1065,7 +1065,7 @@ describe('ReportActionsUtils', () => { reportActionID: '16', previousReportActionID: '15', created: '2022-11-13 22:27:01.825', - actionName: CONST.REPORT.ACTIONS.TYPE.ADDCOMMENT, + actionName: CONST.REPORT.ACTIONS.TYPE.ADD_COMMENT, originalMessage: { html: 'Hello world', whisperedTo: [], @@ -1082,7 +1082,7 @@ describe('ReportActionsUtils', () => { reportActionID: '17', previousReportActionID: '16', created: '2022-11-13 22:27:01.825', - actionName: CONST.REPORT.ACTIONS.TYPE.ADDCOMMENT, + actionName: CONST.REPORT.ACTIONS.TYPE.ADD_COMMENT, originalMessage: { html: 'Hello world', whisperedTo: [], @@ -1102,7 +1102,7 @@ describe('ReportActionsUtils', () => { reportActionID: '9', previousReportActionID: '8', created: '2022-11-13 22:27:01.825', - actionName: CONST.REPORT.ACTIONS.TYPE.ADDCOMMENT, + actionName: CONST.REPORT.ACTIONS.TYPE.ADD_COMMENT, originalMessage: { html: 'Hello world', whisperedTo: [], @@ -1119,7 +1119,7 @@ describe('ReportActionsUtils', () => { reportActionID: '10', previousReportActionID: '9', created: '2022-11-13 22:27:01.825', - actionName: CONST.REPORT.ACTIONS.TYPE.ADDCOMMENT, + actionName: CONST.REPORT.ACTIONS.TYPE.ADD_COMMENT, originalMessage: { html: 'Hello world', whisperedTo: [], @@ -1136,7 +1136,7 @@ describe('ReportActionsUtils', () => { reportActionID: '11', previousReportActionID: '10', created: '2022-11-13 22:27:01.825', - actionName: CONST.REPORT.ACTIONS.TYPE.ADDCOMMENT, + actionName: CONST.REPORT.ACTIONS.TYPE.ADD_COMMENT, originalMessage: { html: 'Hello world', whisperedTo: [], @@ -1153,7 +1153,7 @@ describe('ReportActionsUtils', () => { reportActionID: '12', previousReportActionID: '11', created: '2022-11-13 22:27:01.825', - actionName: CONST.REPORT.ACTIONS.TYPE.ADDCOMMENT, + actionName: CONST.REPORT.ACTIONS.TYPE.ADD_COMMENT, originalMessage: { html: 'Hello world', whisperedTo: [], @@ -1180,7 +1180,7 @@ describe('ReportActionsUtils', () => { reportActionID: '1', previousReportActionID: undefined, created: '2022-11-13 22:27:01.825', - actionName: CONST.REPORT.ACTIONS.TYPE.ADDCOMMENT, + actionName: CONST.REPORT.ACTIONS.TYPE.ADD_COMMENT, originalMessage: { html: 'Hello world', whisperedTo: [], @@ -1197,7 +1197,7 @@ describe('ReportActionsUtils', () => { reportActionID: '2', previousReportActionID: '1', created: '2022-11-13 22:27:01.825', - actionName: CONST.REPORT.ACTIONS.TYPE.ADDCOMMENT, + actionName: CONST.REPORT.ACTIONS.TYPE.ADD_COMMENT, originalMessage: { html: 'Hello world', whisperedTo: [], @@ -1214,7 +1214,7 @@ describe('ReportActionsUtils', () => { reportActionID: '3', previousReportActionID: '2', created: '2022-11-13 22:27:01.825', - actionName: CONST.REPORT.ACTIONS.TYPE.ADDCOMMENT, + actionName: CONST.REPORT.ACTIONS.TYPE.ADD_COMMENT, originalMessage: { html: 'Hello world', whisperedTo: [], @@ -1231,7 +1231,7 @@ describe('ReportActionsUtils', () => { reportActionID: '4', previousReportActionID: '3', created: '2022-11-13 22:27:01.825', - actionName: CONST.REPORT.ACTIONS.TYPE.ADDCOMMENT, + actionName: CONST.REPORT.ACTIONS.TYPE.ADD_COMMENT, originalMessage: { html: 'Hello world', whisperedTo: [], @@ -1248,7 +1248,7 @@ describe('ReportActionsUtils', () => { reportActionID: '5', previousReportActionID: '4', created: '2022-11-13 22:27:01.825', - actionName: CONST.REPORT.ACTIONS.TYPE.ADDCOMMENT, + actionName: CONST.REPORT.ACTIONS.TYPE.ADD_COMMENT, originalMessage: { html: 'Hello world', whisperedTo: [], @@ -1265,7 +1265,7 @@ describe('ReportActionsUtils', () => { reportActionID: '6', previousReportActionID: '5', created: '2022-11-13 22:27:01.825', - actionName: CONST.REPORT.ACTIONS.TYPE.ADDCOMMENT, + actionName: CONST.REPORT.ACTIONS.TYPE.ADD_COMMENT, originalMessage: { html: 'Hello world', whisperedTo: [], @@ -1282,7 +1282,7 @@ describe('ReportActionsUtils', () => { reportActionID: '7', previousReportActionID: '6', created: '2022-11-13 22:27:01.825', - actionName: CONST.REPORT.ACTIONS.TYPE.ADDCOMMENT, + actionName: CONST.REPORT.ACTIONS.TYPE.ADD_COMMENT, originalMessage: { html: 'Hello world', whisperedTo: [], @@ -1301,7 +1301,7 @@ describe('ReportActionsUtils', () => { reportActionID: '9', previousReportActionID: '8', created: '2022-11-13 22:27:01.825', - actionName: CONST.REPORT.ACTIONS.TYPE.ADDCOMMENT, + actionName: CONST.REPORT.ACTIONS.TYPE.ADD_COMMENT, originalMessage: { html: 'Hello world', whisperedTo: [], @@ -1318,7 +1318,7 @@ describe('ReportActionsUtils', () => { reportActionID: '10', previousReportActionID: '9', created: '2022-11-13 22:27:01.825', - actionName: CONST.REPORT.ACTIONS.TYPE.ADDCOMMENT, + actionName: CONST.REPORT.ACTIONS.TYPE.ADD_COMMENT, originalMessage: { html: 'Hello world', whisperedTo: [], @@ -1335,7 +1335,7 @@ describe('ReportActionsUtils', () => { reportActionID: '11', previousReportActionID: '10', created: '2022-11-13 22:27:01.825', - actionName: CONST.REPORT.ACTIONS.TYPE.ADDCOMMENT, + actionName: CONST.REPORT.ACTIONS.TYPE.ADD_COMMENT, originalMessage: { html: 'Hello world', whisperedTo: [], @@ -1352,7 +1352,7 @@ describe('ReportActionsUtils', () => { reportActionID: '12', previousReportActionID: '11', created: '2022-11-13 22:27:01.825', - actionName: CONST.REPORT.ACTIONS.TYPE.ADDCOMMENT, + actionName: CONST.REPORT.ACTIONS.TYPE.ADD_COMMENT, originalMessage: { html: 'Hello world', whisperedTo: [], @@ -1371,7 +1371,7 @@ describe('ReportActionsUtils', () => { reportActionID: '14', previousReportActionID: '13', created: '2022-11-13 22:27:01.825', - actionName: CONST.REPORT.ACTIONS.TYPE.ADDCOMMENT, + actionName: CONST.REPORT.ACTIONS.TYPE.ADD_COMMENT, originalMessage: { html: 'Hello world', whisperedTo: [], @@ -1388,7 +1388,7 @@ describe('ReportActionsUtils', () => { reportActionID: '15', previousReportActionID: '14', created: '2022-11-13 22:27:01.825', - actionName: CONST.REPORT.ACTIONS.TYPE.ADDCOMMENT, + actionName: CONST.REPORT.ACTIONS.TYPE.ADD_COMMENT, originalMessage: { html: 'Hello world', whisperedTo: [], @@ -1405,7 +1405,7 @@ describe('ReportActionsUtils', () => { reportActionID: '16', previousReportActionID: '15', created: '2022-11-13 22:27:01.825', - actionName: CONST.REPORT.ACTIONS.TYPE.ADDCOMMENT, + actionName: CONST.REPORT.ACTIONS.TYPE.ADD_COMMENT, originalMessage: { html: 'Hello world', whisperedTo: [], @@ -1422,7 +1422,7 @@ describe('ReportActionsUtils', () => { reportActionID: '17', previousReportActionID: '16', created: '2022-11-13 22:27:01.825', - actionName: CONST.REPORT.ACTIONS.TYPE.ADDCOMMENT, + actionName: CONST.REPORT.ACTIONS.TYPE.ADD_COMMENT, originalMessage: { html: 'Hello world', whisperedTo: [], @@ -1442,7 +1442,7 @@ describe('ReportActionsUtils', () => { reportActionID: '14', previousReportActionID: '13', created: '2022-11-13 22:27:01.825', - actionName: CONST.REPORT.ACTIONS.TYPE.ADDCOMMENT, + actionName: CONST.REPORT.ACTIONS.TYPE.ADD_COMMENT, originalMessage: { html: 'Hello world', whisperedTo: [], @@ -1459,7 +1459,7 @@ describe('ReportActionsUtils', () => { reportActionID: '15', previousReportActionID: '14', created: '2022-11-13 22:27:01.825', - actionName: CONST.REPORT.ACTIONS.TYPE.ADDCOMMENT, + actionName: CONST.REPORT.ACTIONS.TYPE.ADD_COMMENT, originalMessage: { html: 'Hello world', whisperedTo: [], @@ -1476,7 +1476,7 @@ describe('ReportActionsUtils', () => { reportActionID: '16', previousReportActionID: '15', created: '2022-11-13 22:27:01.825', - actionName: CONST.REPORT.ACTIONS.TYPE.ADDCOMMENT, + actionName: CONST.REPORT.ACTIONS.TYPE.ADD_COMMENT, originalMessage: { html: 'Hello world', whisperedTo: [], @@ -1493,7 +1493,7 @@ describe('ReportActionsUtils', () => { reportActionID: '17', previousReportActionID: '16', created: '2022-11-13 22:27:01.825', - actionName: CONST.REPORT.ACTIONS.TYPE.ADDCOMMENT, + actionName: CONST.REPORT.ACTIONS.TYPE.ADD_COMMENT, originalMessage: { html: 'Hello world', whisperedTo: [], @@ -1520,7 +1520,7 @@ describe('ReportActionsUtils', () => { reportActionID: '1', previousReportActionID: undefined, created: '2022-11-13 22:27:01.825', - actionName: CONST.REPORT.ACTIONS.TYPE.ADDCOMMENT, + actionName: CONST.REPORT.ACTIONS.TYPE.ADD_COMMENT, originalMessage: { html: 'Hello world', whisperedTo: [], @@ -1537,7 +1537,7 @@ describe('ReportActionsUtils', () => { reportActionID: '2', previousReportActionID: '1', created: '2022-11-13 22:27:01.825', - actionName: CONST.REPORT.ACTIONS.TYPE.ADDCOMMENT, + actionName: CONST.REPORT.ACTIONS.TYPE.ADD_COMMENT, originalMessage: { html: 'Hello world', whisperedTo: [], @@ -1554,7 +1554,7 @@ describe('ReportActionsUtils', () => { reportActionID: '3', previousReportActionID: '2', created: '2022-11-13 22:27:01.825', - actionName: CONST.REPORT.ACTIONS.TYPE.ADDCOMMENT, + actionName: CONST.REPORT.ACTIONS.TYPE.ADD_COMMENT, originalMessage: { html: 'Hello world', whisperedTo: [], @@ -1571,7 +1571,7 @@ describe('ReportActionsUtils', () => { reportActionID: '4', previousReportActionID: '3', created: '2022-11-13 22:27:01.825', - actionName: CONST.REPORT.ACTIONS.TYPE.ADDCOMMENT, + actionName: CONST.REPORT.ACTIONS.TYPE.ADD_COMMENT, originalMessage: { html: 'Hello world', whisperedTo: [], @@ -1588,7 +1588,7 @@ describe('ReportActionsUtils', () => { reportActionID: '5', previousReportActionID: '4', created: '2022-11-13 22:27:01.825', - actionName: CONST.REPORT.ACTIONS.TYPE.ADDCOMMENT, + actionName: CONST.REPORT.ACTIONS.TYPE.ADD_COMMENT, originalMessage: { html: 'Hello world', whisperedTo: [], @@ -1605,7 +1605,7 @@ describe('ReportActionsUtils', () => { reportActionID: '6', previousReportActionID: '5', created: '2022-11-13 22:27:01.825', - actionName: CONST.REPORT.ACTIONS.TYPE.ADDCOMMENT, + actionName: CONST.REPORT.ACTIONS.TYPE.ADD_COMMENT, originalMessage: { html: 'Hello world', whisperedTo: [], @@ -1622,7 +1622,7 @@ describe('ReportActionsUtils', () => { reportActionID: '7', previousReportActionID: '6', created: '2022-11-13 22:27:01.825', - actionName: CONST.REPORT.ACTIONS.TYPE.ADDCOMMENT, + actionName: CONST.REPORT.ACTIONS.TYPE.ADD_COMMENT, originalMessage: { html: 'Hello world', whisperedTo: [], @@ -1641,7 +1641,7 @@ describe('ReportActionsUtils', () => { reportActionID: '9', previousReportActionID: '8', created: '2022-11-13 22:27:01.825', - actionName: CONST.REPORT.ACTIONS.TYPE.ADDCOMMENT, + actionName: CONST.REPORT.ACTIONS.TYPE.ADD_COMMENT, originalMessage: { html: 'Hello world', whisperedTo: [], @@ -1658,7 +1658,7 @@ describe('ReportActionsUtils', () => { reportActionID: '10', previousReportActionID: '9', created: '2022-11-13 22:27:01.825', - actionName: CONST.REPORT.ACTIONS.TYPE.ADDCOMMENT, + actionName: CONST.REPORT.ACTIONS.TYPE.ADD_COMMENT, originalMessage: { html: 'Hello world', whisperedTo: [], @@ -1675,7 +1675,7 @@ describe('ReportActionsUtils', () => { reportActionID: '11', previousReportActionID: '10', created: '2022-11-13 22:27:01.825', - actionName: CONST.REPORT.ACTIONS.TYPE.ADDCOMMENT, + actionName: CONST.REPORT.ACTIONS.TYPE.ADD_COMMENT, originalMessage: { html: 'Hello world', whisperedTo: [], @@ -1692,7 +1692,7 @@ describe('ReportActionsUtils', () => { reportActionID: '12', previousReportActionID: '11', created: '2022-11-13 22:27:01.825', - actionName: CONST.REPORT.ACTIONS.TYPE.ADDCOMMENT, + actionName: CONST.REPORT.ACTIONS.TYPE.ADD_COMMENT, originalMessage: { html: 'Hello world', whisperedTo: [], @@ -1711,7 +1711,7 @@ describe('ReportActionsUtils', () => { reportActionID: '14', previousReportActionID: '13', created: '2022-11-13 22:27:01.825', - actionName: CONST.REPORT.ACTIONS.TYPE.ADDCOMMENT, + actionName: CONST.REPORT.ACTIONS.TYPE.ADD_COMMENT, originalMessage: { html: 'Hello world', whisperedTo: [], @@ -1728,7 +1728,7 @@ describe('ReportActionsUtils', () => { reportActionID: '15', previousReportActionID: '14', created: '2022-11-13 22:27:01.825', - actionName: CONST.REPORT.ACTIONS.TYPE.ADDCOMMENT, + actionName: CONST.REPORT.ACTIONS.TYPE.ADD_COMMENT, originalMessage: { html: 'Hello world', whisperedTo: [], @@ -1745,7 +1745,7 @@ describe('ReportActionsUtils', () => { reportActionID: '16', previousReportActionID: '15', created: '2022-11-13 22:27:01.825', - actionName: CONST.REPORT.ACTIONS.TYPE.ADDCOMMENT, + actionName: CONST.REPORT.ACTIONS.TYPE.ADD_COMMENT, originalMessage: { html: 'Hello world', whisperedTo: [], @@ -1762,7 +1762,7 @@ describe('ReportActionsUtils', () => { reportActionID: '17', previousReportActionID: '16', created: '2022-11-13 22:27:01.825', - actionName: CONST.REPORT.ACTIONS.TYPE.ADDCOMMENT, + actionName: CONST.REPORT.ACTIONS.TYPE.ADD_COMMENT, originalMessage: { html: 'Hello world', whisperedTo: [], @@ -1791,7 +1791,7 @@ describe('ReportActionsUtils', () => { reportActionID: '1', previousReportActionID: undefined, created: '2022-11-13 22:27:01.825', - actionName: CONST.REPORT.ACTIONS.TYPE.ADDCOMMENT, + actionName: CONST.REPORT.ACTIONS.TYPE.ADD_COMMENT, originalMessage: { html: 'Hello world', whisperedTo: [], @@ -1809,7 +1809,7 @@ describe('ReportActionsUtils', () => { reportActionID: '2', previousReportActionID: '1', created: '2022-11-13 22:27:01.825', - actionName: CONST.REPORT.ACTIONS.TYPE.ADDCOMMENT, + actionName: CONST.REPORT.ACTIONS.TYPE.ADD_COMMENT, originalMessage: { html: 'Hello world', whisperedTo: [], @@ -1827,7 +1827,7 @@ describe('ReportActionsUtils', () => { reportActionID: '3', previousReportActionID: '2', created: '2022-11-13 22:27:01.825', - actionName: CONST.REPORT.ACTIONS.TYPE.ADDCOMMENT, + actionName: CONST.REPORT.ACTIONS.TYPE.ADD_COMMENT, originalMessage: { html: 'Hello world', whisperedTo: [], @@ -1845,7 +1845,7 @@ describe('ReportActionsUtils', () => { reportActionID: '4', previousReportActionID: '3', created: '2022-11-13 22:27:01.825', - actionName: CONST.REPORT.ACTIONS.TYPE.ADDCOMMENT, + actionName: CONST.REPORT.ACTIONS.TYPE.ADD_COMMENT, originalMessage: { html: 'Hello world', whisperedTo: [], @@ -1863,7 +1863,7 @@ describe('ReportActionsUtils', () => { reportActionID: '5', previousReportActionID: '4', created: '2022-11-13 22:27:01.825', - actionName: CONST.REPORT.ACTIONS.TYPE.ADDCOMMENT, + actionName: CONST.REPORT.ACTIONS.TYPE.ADD_COMMENT, originalMessage: { html: 'Hello world', whisperedTo: [], @@ -1881,7 +1881,7 @@ describe('ReportActionsUtils', () => { reportActionID: '6', previousReportActionID: '5', created: '2022-11-13 22:27:01.825', - actionName: CONST.REPORT.ACTIONS.TYPE.ADDCOMMENT, + actionName: CONST.REPORT.ACTIONS.TYPE.ADD_COMMENT, originalMessage: { html: 'Hello world', whisperedTo: [], @@ -1899,7 +1899,7 @@ describe('ReportActionsUtils', () => { reportActionID: '7', previousReportActionID: '6', created: '2022-11-13 22:27:01.825', - actionName: CONST.REPORT.ACTIONS.TYPE.ADDCOMMENT, + actionName: CONST.REPORT.ACTIONS.TYPE.ADD_COMMENT, originalMessage: { html: 'Hello world', whisperedTo: [], @@ -1932,7 +1932,7 @@ describe('ReportActionsUtils', () => { ...LHNTestUtils.getFakeReportAction('email1@test.com', 3), created: '2023-08-01 16:00:00', reportActionID: 'action1', - actionName: 'ADDCOMMENT', + actionName: 'ADD_COMMENT', originalMessage: { html: 'Hello world', whisperedTo: [], @@ -1942,7 +1942,7 @@ describe('ReportActionsUtils', () => { ...LHNTestUtils.getFakeReportAction('email2@test.com', 3), created: '2023-08-01 18:00:00', reportActionID: 'action2', - actionName: 'ADDCOMMENT', + actionName: 'ADD_COMMENT', originalMessage: { html: 'Hello world', whisperedTo: [], diff --git a/tests/unit/ReportUtilsTest.ts b/tests/unit/ReportUtilsTest.ts index b3c4f8bdb001..1a886591c2ef 100644 --- a/tests/unit/ReportUtilsTest.ts +++ b/tests/unit/ReportUtilsTest.ts @@ -770,7 +770,7 @@ describe('ReportUtils', () => { it("should disable on a whisper action and it's neither a report preview nor IOU action", () => { const reportAction = { - actionName: CONST.REPORT.ACTIONS.TYPE.MODIFIEDEXPENSE, + actionName: CONST.REPORT.ACTIONS.TYPE.MODIFIED_EXPENSE, whisperedToAccountIDs: [123456], } as ReportAction; expect(ReportUtils.shouldDisableThread(reportAction, reportID)).toBeTruthy(); @@ -794,10 +794,10 @@ describe('ReportUtils', () => { ]; const reportActions: ReportAction[] = [ - {reportActionID: '1', created: '2024-02-01 04:42:22.965', actionName: 'MARKEDREIMBURSED'}, - {reportActionID: '2', created: '2024-02-01 04:42:28.003', actionName: 'MARKEDREIMBURSED'}, - {reportActionID: '3', created: '2024-02-01 04:42:31.742', actionName: 'MARKEDREIMBURSED'}, - {reportActionID: '4', created: '2024-02-01 04:42:35.619', actionName: 'MARKEDREIMBURSED'}, + {reportActionID: '1', created: '2024-02-01 04:42:22.965', actionName: 'MARKED_REIMBURSED'}, + {reportActionID: '2', created: '2024-02-01 04:42:28.003', actionName: 'MARKED_REIMBURSED'}, + {reportActionID: '3', created: '2024-02-01 04:42:31.742', actionName: 'MARKED_REIMBURSED'}, + {reportActionID: '4', created: '2024-02-01 04:42:35.619', actionName: 'MARKED_REIMBURSED'}, ]; beforeAll(() => { diff --git a/tests/unit/SidebarOrderTest.ts b/tests/unit/SidebarOrderTest.ts index 2758d43fb81e..868630a8f7d2 100644 --- a/tests/unit/SidebarOrderTest.ts +++ b/tests/unit/SidebarOrderTest.ts @@ -122,7 +122,7 @@ describe('Sidebar', () => { const report2 = LHNTestUtils.getFakeReport([3, 4], 2); const report3 = LHNTestUtils.getFakeReport([5, 6], 1); - // Each report has at least one ADDCOMMENT action so should be rendered in the LNH + // Each report has at least one ADD_COMMENT action so should be rendered in the LNH Report.addComment(report1.reportID, 'Hi, this is a comment'); Report.addComment(report2.reportID, 'Hi, this is a comment'); Report.addComment(report3.reportID, 'Hi, this is a comment'); @@ -168,7 +168,7 @@ describe('Sidebar', () => { const report2 = LHNTestUtils.getFakeReport([3, 4], 2); const report3 = LHNTestUtils.getFakeReport([5, 6], 1); - // Each report has at least one ADDCOMMENT action so should be rendered in the LNH + // Each report has at least one ADD_COMMENT action so should be rendered in the LNH Report.addComment(report1.reportID, 'Hi, this is a comment'); Report.addComment(report2.reportID, 'Hi, this is a comment'); Report.addComment(report3.reportID, 'Hi, this is a comment'); @@ -219,7 +219,7 @@ describe('Sidebar', () => { const report2 = LHNTestUtils.getFakeReport([3, 4], 2); const report3 = LHNTestUtils.getFakeReport([5, 6], 1); - // Each report has at least one ADDCOMMENT action so should be rendered in the LNH + // Each report has at least one ADD_COMMENT action so should be rendered in the LNH Report.addComment(report1.reportID, 'Hi, this is a comment'); Report.addComment(report2.reportID, 'Hi, this is a comment'); Report.addComment(report3.reportID, 'Hi, this is a comment'); @@ -278,7 +278,7 @@ describe('Sidebar', () => { statusNum: CONST.REPORT.STATUS_NUM.OPEN, }; - // Each report has at least one ADDCOMMENT action so should be rendered in the LNH + // Each report has at least one ADD_COMMENT action so should be rendered in the LNH Report.addComment(report1.reportID, 'Hi, this is a comment'); Report.addComment(report2.reportID, 'Hi, this is a comment'); Report.addComment(report3.reportID, 'Hi, this is a comment'); @@ -342,7 +342,7 @@ describe('Sidebar', () => { }; report3.iouReportID = iouReport.reportID; - // Each report has at least one ADDCOMMENT action so should be rendered in the LNH + // Each report has at least one ADD_COMMENT action so should be rendered in the LNH Report.addComment(report1.reportID, 'Hi, this is a comment'); Report.addComment(report2.reportID, 'Hi, this is a comment'); Report.addComment(report3.reportID, 'Hi, this is a comment'); @@ -409,7 +409,7 @@ describe('Sidebar', () => { }; report3.iouReportID = expenseReport.reportID; - // Each report has at least one ADDCOMMENT action so should be rendered in the LNH + // Each report has at least one ADD_COMMENT action so should be rendered in the LNH Report.addComment(report1.reportID, 'Hi, this is a comment'); Report.addComment(report2.reportID, 'Hi, this is a comment'); Report.addComment(report3.reportID, 'Hi, this is a comment'); @@ -459,7 +459,7 @@ describe('Sidebar', () => { }; const report3 = LHNTestUtils.getFakeReport([5, 6], 1); - // Each report has at least one ADDCOMMENT action so should be rendered in the LNH + // Each report has at least one ADD_COMMENT action so should be rendered in the LNH Report.addComment(report1.reportID, 'Hi, this is a comment'); Report.addComment(report2.reportID, 'Hi, this is a comment'); Report.addComment(report3.reportID, 'Hi, this is a comment'); @@ -815,7 +815,7 @@ describe('Sidebar', () => { const report2 = LHNTestUtils.getFakeReport([3, 4]); const report3 = LHNTestUtils.getFakeReport([5, 6]); - // Each report has at least one ADDCOMMENT action so should be rendered in the LNH + // Each report has at least one ADD_COMMENT action so should be rendered in the LNH Report.addComment(report1.reportID, 'Hi, this is a comment'); Report.addComment(report2.reportID, 'Hi, this is a comment'); Report.addComment(report3.reportID, 'Hi, this is a comment'); @@ -1117,7 +1117,7 @@ describe('Sidebar', () => { lastVisibleActionCreated, }; - // Each report has at least one ADDCOMMENT action so should be rendered in the LNH + // Each report has at least one ADD_COMMENT action so should be rendered in the LNH Report.addComment(report1.reportID, 'Hi, this is a comment'); Report.addComment(report2.reportID, 'Hi, this is a comment'); Report.addComment(report3.reportID, 'Hi, this is a comment'); diff --git a/tests/utils/ReportTestUtils.ts b/tests/utils/ReportTestUtils.ts index 3948baca3113..2a737bc16a91 100644 --- a/tests/utils/ReportTestUtils.ts +++ b/tests/utils/ReportTestUtils.ts @@ -2,7 +2,7 @@ import type {ReportAction, ReportActions} from '@src/types/onyx'; import type {ActionName} from '@src/types/onyx/OriginalMessage'; import createRandomReportAction from './collections/reportActions'; -const actionNames: ActionName[] = ['ADDCOMMENT', 'IOU', 'REPORTPREVIEW', 'CLOSED']; +const actionNames: ActionName[] = ['ADD_COMMENT', 'IOU', 'REPORT_PREVIEW', 'CLOSED']; const getFakeReportAction = (index: number, actionName?: ActionName): ReportAction => ({ @@ -50,7 +50,7 @@ const getFakeReportAction = (index: number, actionName?: ActionName): ReportActi const getMockedSortedReportActions = (length = 100): ReportAction[] => Array.from({length}, (element, index): ReportAction => { - const actionName: ActionName = index === 0 ? 'CREATED' : 'ADDCOMMENT'; + const actionName: ActionName = index === 0 ? 'CREATED' : 'ADD_COMMENT'; return getFakeReportAction(index + 1, actionName); }).reverse(); diff --git a/tests/utils/TestHelper.ts b/tests/utils/TestHelper.ts index 9f3b28973923..562176288565 100644 --- a/tests/utils/TestHelper.ts +++ b/tests/utils/TestHelper.ts @@ -203,7 +203,7 @@ function setPersonalDetails(login: string, accountID: number) { function buildTestReportComment(created: string, actorAccountID: number, actionID: string | null = null, previousReportActionID: string | null = null) { const reportActionID = actionID ?? NumberUtils.rand64().toString(); return { - actionName: CONST.REPORT.ACTIONS.TYPE.ADDCOMMENT, + actionName: CONST.REPORT.ACTIONS.TYPE.ADD_COMMENT, person: [{type: 'TEXT', style: 'strong', text: 'User B'}], created, message: [{type: 'COMMENT', html: `Comment ${actionID}`, text: `Comment ${actionID}`}], From 3d510587d9687e80299c4a9470258439efc50fe1 Mon Sep 17 00:00:00 2001 From: Shahe Shahinyan <shahe.shahinyan@gmail.com> Date: Sun, 14 Apr 2024 16:48:55 +0400 Subject: [PATCH 099/206] Correction of omissions --- src/CONST.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/CONST.ts b/src/CONST.ts index 11d6783eef75..5688b6c68a64 100755 --- a/src/CONST.ts +++ b/src/CONST.ts @@ -752,10 +752,10 @@ const CONST = { UPDATE_TIME_RATE: 'POLICYCHANGELOG_UPDATE_TIME_RATE', }, ROOM_CHANGE_LOG: { - INVITE_TO_ROOM: 'INVITETOROOM', - REMOVE_FROM_ROOM: 'REMOVEFROMROOM', - LEAVE_ROOM: 'LEAVEROOM', - UPDATE_ROOM_DESCRIPTION: 'UPDATEROOMDESCRIPTION', + INVITE_TO_ROOM: 'INVITE_TO_ROOM', + REMOVE_FROM_ROOM: 'REMOVE_FROM_ROOM', + LEAVE_ROOM: 'LEAVE_ROOM', + UPDATE_ROOM_DESCRIPTION: 'UPDATE_ROOM_DESCRIPTION', }, }, THREAD_DISABLED: ['CREATED'], From 09e5300afb34dfc55ef073f9a888ec43f764484b Mon Sep 17 00:00:00 2001 From: Krishna Gupta <belivethatkg@gmail.com> Date: Mon, 15 Apr 2024 01:56:12 +0530 Subject: [PATCH 100/206] fix: Android - No bottom margin under the sign out button. Signed-off-by: Krishna Gupta <belivethatkg@gmail.com> --- src/pages/settings/InitialSettingsPage.tsx | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/pages/settings/InitialSettingsPage.tsx b/src/pages/settings/InitialSettingsPage.tsx index a307f6cf6a7f..fbad150f3e66 100755 --- a/src/pages/settings/InitialSettingsPage.tsx +++ b/src/pages/settings/InitialSettingsPage.tsx @@ -487,8 +487,7 @@ function InitialSettingsPage({session, userWallet, bankAccountList, fundList, wa onScroll={onScroll} scrollEventThrottle={16} // We use marginTop to prevent glitching on the initial frame that renders before scrollTo. - contentContainerStyle={[!isAfterOnLayout && !!scrollOffset && {marginTop: -scrollOffset}]} - style={[styles.w100, styles.pt4]} + contentContainerStyle={[!isAfterOnLayout && !!scrollOffset && {marginTop: -scrollOffset}, styles.w100, styles.pt4]} > {headerContent} {accountMenuItems} From 3911a9ec53e1d552d34c6e09715e96b3f3a3607a Mon Sep 17 00:00:00 2001 From: nkdengineer <nkdengineer@outlook.com> Date: Mon, 15 Apr 2024 15:48:58 +0700 Subject: [PATCH 101/206] Fix disconnected bank account still displayed in workflow page --- ios/Podfile.lock | 10 ++++---- .../resetFreePlanBankAccount.ts | 25 ++++++++++++++++++- 2 files changed, 29 insertions(+), 6 deletions(-) diff --git a/ios/Podfile.lock b/ios/Podfile.lock index f9244c515a2c..c4d42df41b97 100644 --- a/ios/Podfile.lock +++ b/ios/Podfile.lock @@ -1945,7 +1945,7 @@ PODS: - ReactCommon/turbomodule/bridging - ReactCommon/turbomodule/core - Yoga - - RNScreens (3.30.1): + - RNScreens (3.29.0): - glog - hermes-engine - RCT-Folly (= 2022.05.16.00) @@ -1963,9 +1963,9 @@ PODS: - React-utils - ReactCommon/turbomodule/bridging - ReactCommon/turbomodule/core - - RNScreens/common (= 3.30.1) + - RNScreens/common (= 3.29.0) - Yoga - - RNScreens/common (3.30.1): + - RNScreens/common (3.29.0): - glog - hermes-engine - RCT-Folly (= 2022.05.16.00) @@ -2571,7 +2571,7 @@ SPEC CHECKSUMS: RNPermissions: 8990fc2c10da3640938e6db1647cb6416095b729 RNReactNativeHapticFeedback: 616c35bdec7d20d4c524a7949ca9829c09e35f37 RNReanimated: 605409e0d0ced6f2e194ae585fedc2f8a1935bf2 - RNScreens: 65a936f4e227b91e4a8e2a7d4c4607355bfefda0 + RNScreens: f7b8bb892b4957f6f91e5dfd9a191e7f13ce8baa RNShare: 2a4cdfc0626ad56b0ef583d424f2038f772afe58 RNSound: 6c156f925295bdc83e8e422e7d8b38d33bc71852 RNSVG: db32cfcad0a221fd175e0882eff7bcba7690380a @@ -2582,7 +2582,7 @@ SPEC CHECKSUMS: SocketRocket: f32cd54efbe0f095c4d7594881e52619cfe80b17 Turf: 13d1a92d969ca0311bbc26e8356cca178ce95da2 VisionCamera: 3033e0dd5272d46e97bcb406adea4ae0e6907abf - Yoga: 64cd2a583ead952b0315d5135bf39e053ae9be70 + Yoga: 1b901a6d6eeba4e8a2e8f308f708691cdb5db312 PODFILE CHECKSUM: a25a81f2b50270f0c0bd0aff2e2ebe4d0b4ec06d diff --git a/src/libs/actions/ReimbursementAccount/resetFreePlanBankAccount.ts b/src/libs/actions/ReimbursementAccount/resetFreePlanBankAccount.ts index a1f0e070fcb3..df558f81a503 100644 --- a/src/libs/actions/ReimbursementAccount/resetFreePlanBankAccount.ts +++ b/src/libs/actions/ReimbursementAccount/resetFreePlanBankAccount.ts @@ -1,4 +1,4 @@ -import type {OnyxEntry} from 'react-native-onyx'; +import type {OnyxCollection, OnyxEntry} from 'react-native-onyx'; import Onyx from 'react-native-onyx'; import * as API from '@libs/API'; import {WRITE_COMMANDS} from '@libs/API/types'; @@ -10,6 +10,13 @@ import ONYXKEYS from '@src/ONYXKEYS'; import INPUT_IDS from '@src/types/form/ReimbursementAccountForm'; import type * as OnyxTypes from '@src/types/onyx'; +let allPolicies: OnyxCollection<OnyxTypes.Policy>; +Onyx.connect({ + key: ONYXKEYS.COLLECTION.POLICY, + waitForCollectionCallback: true, + callback: (value) => (allPolicies = value), +}); + /** * Reset user's reimbursement account. This will delete the bank account. */ @@ -21,6 +28,8 @@ function resetFreePlanBankAccount(bankAccountID: number | undefined, session: On throw new Error('Missing credentials when attempting to reset free plan bank account'); } + const policy = allPolicies?.[`${ONYXKEYS.COLLECTION.POLICY}${policyID}`] ?? ({} as Policy); + API.write( WRITE_COMMANDS.RESTART_BANK_ACCOUNT_SETUP, { @@ -40,6 +49,13 @@ function resetFreePlanBankAccount(bankAccountID: number | undefined, session: On achData: null, }, }, + { + onyxMethod: Onyx.METHOD.MERGE, + key: `${ONYXKEYS.COLLECTION.POLICY}${policyID}`, + value: { + achAccount: null, + }, + }, ], successData: [ { @@ -119,6 +135,13 @@ function resetFreePlanBankAccount(bankAccountID: number | undefined, session: On key: ONYXKEYS.REIMBURSEMENT_ACCOUNT, value: {isLoading: false, pendingAction: null}, }, + { + onyxMethod: Onyx.METHOD.MERGE, + key: `${ONYXKEYS.COLLECTION.POLICY}${policyID}`, + value: { + achAccount: policy?.achAccount, + }, + }, ], }, ); From 387586a94744bee03b55715c85518535e492e494 Mon Sep 17 00:00:00 2001 From: brunovjk <brunovjk@gmail.com> Date: Mon, 15 Apr 2024 08:32:04 -0300 Subject: [PATCH 102/206] Add validation error for category --- src/components/MoneyRequestConfirmationList.tsx | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/components/MoneyRequestConfirmationList.tsx b/src/components/MoneyRequestConfirmationList.tsx index 6e0de099b847..ef266ffc9de5 100755 --- a/src/components/MoneyRequestConfirmationList.tsx +++ b/src/components/MoneyRequestConfirmationList.tsx @@ -535,6 +535,10 @@ function MoneyRequestConfirmationList({ setMerchantError(true); return; } + if (iouCategory.length > CONST.API_TRANSACTION_CATEGORY_MAX_LENGTH) { + setFormError('iou.error.invalidCategoryLength'); + return; + } if (iouType === CONST.IOU.TYPE.SEND) { if (!paymentMethod) { From 4e8fef9514f8bd16466f3fbbf1a79d6c8e176c54 Mon Sep 17 00:00:00 2001 From: brunovjk <brunovjk@gmail.com> Date: Mon, 15 Apr 2024 08:46:33 -0300 Subject: [PATCH 103/206] reuse ShowMoreButton --- .../MoneyRequestConfirmationList.tsx | 20 +++++-------------- 1 file changed, 5 insertions(+), 15 deletions(-) diff --git a/src/components/MoneyRequestConfirmationList.tsx b/src/components/MoneyRequestConfirmationList.tsx index ef266ffc9de5..2ccfeb0bc16e 100755 --- a/src/components/MoneyRequestConfirmationList.tsx +++ b/src/components/MoneyRequestConfirmationList.tsx @@ -35,13 +35,11 @@ import type {Route} from '@src/ROUTES'; import type * as OnyxTypes from '@src/types/onyx'; import type {Participant} from '@src/types/onyx/IOU'; import type {PaymentMethodType} from '@src/types/onyx/OriginalMessage'; -import Button from './Button'; import ButtonWithDropdownMenu from './ButtonWithDropdownMenu'; import type {DropdownOption} from './ButtonWithDropdownMenu/types'; import ConfirmedRoute from './ConfirmedRoute'; import ConfirmModal from './ConfirmModal'; import FormHelpMessage from './FormHelpMessage'; -import * as Expensicons from './Icon/Expensicons'; import MenuItemWithTopDescription from './MenuItemWithTopDescription'; import OptionsSelector from './OptionsSelector'; import PDFThumbnail from './PDFThumbnail'; @@ -50,6 +48,7 @@ import ReceiptImage from './ReceiptImage'; import SettlementButton from './SettlementButton'; import Switch from './Switch'; import Text from './Text'; +import ShowMoreButton from './ShowMoreButton'; type MoneyRequestConfirmationListOnyxProps = { /** Collection of categories attached to a policy */ @@ -1010,19 +1009,10 @@ function MoneyRequestConfirmationList({ } {primaryFields} {!shouldShowAllFields && ( - <View style={[styles.flexRow, styles.justifyContentBetween, styles.mh3, styles.alignItemsCenter, styles.mb2, styles.mt1]}> - <View style={[styles.shortTermsHorizontalRule, styles.flex1, styles.mr0]} /> - <Button - small - onPress={toggleShouldExpandFields} - text={translate('common.showMore')} - shouldShowRightIcon - iconRight={Expensicons.DownArrow} - iconFill={theme.icon} - style={styles.mh0} - /> - <View style={[styles.shortTermsHorizontalRule, styles.flex1, styles.ml0]} /> - </View> + <ShowMoreButton + containerStyle={[styles.mt1, styles.mb2]} + onPress={toggleShouldExpandFields} + /> )} {shouldShowAllFields && supplementaryFields} <ConfirmModal From 650b186e3f1b131713f3e4cbdbe23e95b4c0798e Mon Sep 17 00:00:00 2001 From: brunovjk <brunovjk@gmail.com> Date: Mon, 15 Apr 2024 09:00:58 -0300 Subject: [PATCH 104/206] add tags within components --- src/components/MoneyRequestConfirmationList.tsx | 6 +++++- src/pages/iou/SplitBillDetailsPage.tsx | 2 ++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/src/components/MoneyRequestConfirmationList.tsx b/src/components/MoneyRequestConfirmationList.tsx index 2ccfeb0bc16e..a2824cfcea7e 100755 --- a/src/components/MoneyRequestConfirmationList.tsx +++ b/src/components/MoneyRequestConfirmationList.tsx @@ -100,6 +100,9 @@ type MoneyRequestConfirmationListProps = MoneyRequestConfirmationListOnyxProps & /** IOU Category */ iouCategory?: string; + + /** IOU Tag */ + iouTag?: string; /** IOU isBillable */ iouIsBillable?: boolean; @@ -181,6 +184,7 @@ function MoneyRequestConfirmationList({ policy, isPolicyExpenseChat = false, iouCategory = '', + iouTag = '', shouldShowSmartScanFields = true, isEditingSplitBill, policyTags, @@ -240,7 +244,7 @@ function MoneyRequestConfirmationList({ const policyTagLists = useMemo(() => PolicyUtils.getTagLists(policyTags), [policyTags]); // A flag for showing the tags field - const shouldShowTags = useMemo(() => isPolicyExpenseChat && OptionsListUtils.hasEnabledTags(policyTagLists), [isPolicyExpenseChat, policyTagLists]); + const shouldShowTags = isPolicyExpenseChat && (!!iouTag || OptionsListUtils.hasEnabledTags(policyTagLists)); // A flag for showing tax rate const shouldShowTax = isTaxTrackingEnabled(isPolicyExpenseChat, policy); diff --git a/src/pages/iou/SplitBillDetailsPage.tsx b/src/pages/iou/SplitBillDetailsPage.tsx index c500c4a8175f..91aa37dd01c2 100644 --- a/src/pages/iou/SplitBillDetailsPage.tsx +++ b/src/pages/iou/SplitBillDetailsPage.tsx @@ -85,6 +85,7 @@ function SplitBillDetailsPage({personalDetails, report, route, reportActions, tr merchant: splitMerchant, created: splitCreated, category: splitCategory, + tag: splitTag, billable: splitBillable, } = ReportUtils.getTransactionDetails(isEditingSplitBill && draftTransaction ? draftTransaction : transaction) ?? {}; @@ -116,6 +117,7 @@ function SplitBillDetailsPage({personalDetails, report, route, reportActions, tr iouCreated={splitCreated} iouMerchant={splitMerchant} iouCategory={splitCategory} + iouTag={splitTag} iouIsBillable={splitBillable} iouType={CONST.IOU.TYPE.SPLIT} isReadOnly={!isEditingSplitBill} From e669b1fca714f2024c8fa8ced8bee32c4f8b2a59 Mon Sep 17 00:00:00 2001 From: brunovjk <brunovjk@gmail.com> Date: Mon, 15 Apr 2024 09:14:21 -0300 Subject: [PATCH 105/206] Add useCallback dependency --- src/components/MoneyRequestConfirmationList.tsx | 1 + 1 file changed, 1 insertion(+) diff --git a/src/components/MoneyRequestConfirmationList.tsx b/src/components/MoneyRequestConfirmationList.tsx index a2824cfcea7e..9313bfb1906d 100755 --- a/src/components/MoneyRequestConfirmationList.tsx +++ b/src/components/MoneyRequestConfirmationList.tsx @@ -581,6 +581,7 @@ function MoneyRequestConfirmationList({ onSendMoney, iouCurrencyCode, isDistanceRequest, + iouCategory, isDistanceRequestWithPendingRoute, iouAmount, isEditingSplitBill, From b0b0992dd893347acf4cab18678c1b841608a93a Mon Sep 17 00:00:00 2001 From: nkdengineer <nkdengineer@outlook.com> Date: Mon, 15 Apr 2024 20:38:00 +0700 Subject: [PATCH 106/206] fix ts check --- .../actions/ReimbursementAccount/resetFreePlanBankAccount.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libs/actions/ReimbursementAccount/resetFreePlanBankAccount.ts b/src/libs/actions/ReimbursementAccount/resetFreePlanBankAccount.ts index df558f81a503..41fa0a4ccbd0 100644 --- a/src/libs/actions/ReimbursementAccount/resetFreePlanBankAccount.ts +++ b/src/libs/actions/ReimbursementAccount/resetFreePlanBankAccount.ts @@ -28,7 +28,7 @@ function resetFreePlanBankAccount(bankAccountID: number | undefined, session: On throw new Error('Missing credentials when attempting to reset free plan bank account'); } - const policy = allPolicies?.[`${ONYXKEYS.COLLECTION.POLICY}${policyID}`] ?? ({} as Policy); + const policy = allPolicies?.[`${ONYXKEYS.COLLECTION.POLICY}${policyID}`] ?? ({} as OnyxTypes.Policy); API.write( WRITE_COMMANDS.RESTART_BANK_ACCOUNT_SETUP, From f7f7c14c5a7825c005261d8b8d8d99267b04ffd1 Mon Sep 17 00:00:00 2001 From: brunovjk <brunovjk@gmail.com> Date: Mon, 15 Apr 2024 10:39:22 -0300 Subject: [PATCH 107/206] added small adjustments --- src/components/MoneyRequestConfirmationList.tsx | 1 + 1 file changed, 1 insertion(+) diff --git a/src/components/MoneyRequestConfirmationList.tsx b/src/components/MoneyRequestConfirmationList.tsx index 9313bfb1906d..1082916a4529 100755 --- a/src/components/MoneyRequestConfirmationList.tsx +++ b/src/components/MoneyRequestConfirmationList.tsx @@ -161,6 +161,7 @@ type MoneyRequestConfirmationListProps = MoneyRequestConfirmationListOnyxProps & /** Whether smart scan failed */ hasSmartScanFailed?: boolean; + /** The ID of the report action */ reportActionID?: string; }; From 0bee35b40fc75a697567c56aa8ebcdedd330a1a3 Mon Sep 17 00:00:00 2001 From: brunovjk <brunovjk@gmail.com> Date: Mon, 15 Apr 2024 11:17:07 -0300 Subject: [PATCH 108/206] 'resolve comments' --- .../MoneyRequestConfirmationList.tsx | 60 ++++++++++--------- 1 file changed, 31 insertions(+), 29 deletions(-) diff --git a/src/components/MoneyRequestConfirmationList.tsx b/src/components/MoneyRequestConfirmationList.tsx index 1082916a4529..010db6017c9d 100755 --- a/src/components/MoneyRequestConfirmationList.tsx +++ b/src/components/MoneyRequestConfirmationList.tsx @@ -50,6 +50,8 @@ import Switch from './Switch'; import Text from './Text'; import ShowMoreButton from './ShowMoreButton'; +type IouType = ValueOf<typeof CONST.IOU.TYPE>; + type MoneyRequestConfirmationListOnyxProps = { /** Collection of categories attached to a policy */ policyCategories: OnyxEntry<OnyxTypes.PolicyCategories>; @@ -72,7 +74,7 @@ type MoneyRequestConfirmationListProps = MoneyRequestConfirmationListOnyxProps & onConfirm?: (selectedParticipants: Participant[]) => void; /** Callback to parent modal to send money */ - onSendMoney?: (paymentMethod: PaymentMethodType | undefined) => void; + onSendMoney?: (paymentMethod: IouType | PaymentMethodType | undefined) => void; /** Callback to inform a participant is selected */ onSelectParticipant?: (option: Participant) => void; @@ -90,7 +92,7 @@ type MoneyRequestConfirmationListProps = MoneyRequestConfirmationListOnyxProps & iouCurrencyCode?: string; /** IOU type */ - iouType?: ValueOf<typeof CONST.IOU.TYPE>; + iouType?: IouType; /** IOU date */ iouCreated?: string; @@ -193,7 +195,7 @@ function MoneyRequestConfirmationList({ iouMerchant, hasMultipleParticipants, selectedParticipants: pickedParticipants, - payeePersonalDetails, + payeePersonalDetails: payeePersonalDetailsProp, canModifyParticipants = false, session, isReadOnly = false, @@ -224,7 +226,7 @@ function MoneyRequestConfirmationList({ const {unit, rate, currency} = mileageRate ?? { unit: CONST.CUSTOM_UNITS.DISTANCE_UNIT_MILES, rate: 0, - currency: 'USD', + currency: CONST.CURRENCY.USD, }; const distance = transaction?.routes?.route0.distance ?? 0; const shouldCalculateDistanceAmount = isDistanceRequest && iouAmount === 0; @@ -253,7 +255,7 @@ function MoneyRequestConfirmationList({ // A flag for showing the billable field const shouldShowBillable = policy?.disabledFields?.defaultBillable === false; - const hasRoute = TransactionUtils.hasRoute(transaction); + const hasRoute = TransactionUtils.hasRoute(transaction ); const isDistanceRequestWithPendingRoute = isDistanceRequest && (!hasRoute || !rate); const formattedAmount = isDistanceRequestWithPendingRoute ? '' @@ -285,7 +287,7 @@ function MoneyRequestConfirmationList({ return false; } - return (!!hasSmartScanFailed && TransactionUtils.hasMissingSmartscanFields(transaction)) || (didConfirmSplit && TransactionUtils.areRequiredFieldsEmpty(transaction)); + return (!!hasSmartScanFailed && TransactionUtils.hasMissingSmartscanFields(transaction )) || (didConfirmSplit && TransactionUtils.areRequiredFieldsEmpty(transaction )); }, [isEditingSplitBill, hasSmartScanFailed, transaction, didConfirmSplit]); const isMerchantEmpty = !iouMerchant || iouMerchant === CONST.TRANSACTION.PARTIAL_TRANSACTION_MERCHANT; @@ -359,7 +361,7 @@ function MoneyRequestConfirmationList({ setDidConfirm(false); } - const splitOrRequestOptions: Array<DropdownOption<string>> = useMemo(() => { + const splitOrRequestOptions: Array<DropdownOption<IouType>> = useMemo(() => { let text; if (isTypeTrackExpense) { text = translate('iou.trackExpense'); @@ -382,15 +384,15 @@ function MoneyRequestConfirmationList({ ]; }, [isTypeTrackExpense, isTypeSplit, iouAmount, receiptPath, isTypeRequest, isDistanceRequestWithPendingRoute, iouType, translate, formattedAmount]); - const selectedParticipants = useMemo(() => pickedParticipants.filter((participant) => participant.selected), [pickedParticipants]); - const personalDetailsOfPayee = useMemo(() => payeePersonalDetails ?? currentUserPersonalDetails, [payeePersonalDetails, currentUserPersonalDetails]); + const selectedParticipants: Participant[] = useMemo(() => pickedParticipants.filter((participant) => participant.selected), [pickedParticipants]); + const payeePersonalDetails = useMemo(() => payeePersonalDetailsProp ?? currentUserPersonalDetails, [payeePersonalDetailsProp, currentUserPersonalDetails]); const userCanModifyParticipants = useRef(!isReadOnly && canModifyParticipants && hasMultipleParticipants); useEffect(() => { userCanModifyParticipants.current = !isReadOnly && canModifyParticipants && hasMultipleParticipants; }, [isReadOnly, canModifyParticipants, hasMultipleParticipants]); const shouldDisablePaidBySection = userCanModifyParticipants.current; - const optionSelectorSections = useMemo(() => { + const optionSelectorSections: OptionsListUtils.CategorySection[] = useMemo(() => { const sections = []; const unselectedParticipants = pickedParticipants.filter((participant) => !participant.selected); if (hasMultipleParticipants) { @@ -406,7 +408,7 @@ function MoneyRequestConfirmationList({ const myIOUAmount = IOUUtils.calculateAmount(selectedParticipants.length, iouAmount, iouCurrencyCode ?? '', true); const formattedPayeeOption = OptionsListUtils.getIOUConfirmationOptionsFromPayeePersonalDetail( - personalDetailsOfPayee, + payeePersonalDetails, iouAmount > 0 ? CurrencyUtils.convertToDisplayString(myIOUAmount, iouCurrencyCode) : '', ); @@ -442,18 +444,18 @@ function MoneyRequestConfirmationList({ iouAmount, iouCurrencyCode, getParticipantsWithAmount, - personalDetailsOfPayee, + payeePersonalDetails, translate, shouldDisablePaidBySection, canModifyParticipants, ]); - const selectedOptions = useMemo(() => { + const selectedOptions: Array<Participant | OptionsListUtils.PayeePersonalDetails> = useMemo(() => { if (!hasMultipleParticipants) { return []; } - return [...selectedParticipants, OptionsListUtils.getIOUConfirmationOptionsFromPayeePersonalDetail(personalDetailsOfPayee)]; - }, [selectedParticipants, hasMultipleParticipants, personalDetailsOfPayee]); + return [...selectedParticipants, OptionsListUtils.getIOUConfirmationOptionsFromPayeePersonalDetail(payeePersonalDetails)]; + }, [selectedParticipants, hasMultipleParticipants, payeePersonalDetails]); useEffect(() => { if (!isDistanceRequest) { @@ -467,7 +469,7 @@ function MoneyRequestConfirmationList({ */ IOU.setMoneyRequestPendingFields(transaction?.transactionID ?? '', {waypoints: isDistanceRequestWithPendingRoute ? CONST.RED_BRICK_ROAD_PENDING_ACTION.ADD : null}); - const distanceMerchant = DistanceRequestUtils.getDistanceMerchant(hasRoute, distance, unit, rate ?? 0, currency ?? 'USD', translate, toLocaleDigit); + const distanceMerchant = DistanceRequestUtils.getDistanceMerchant(hasRoute, distance, unit, rate ?? 0, currency ?? CONST.CURRENCY.USD, translate, toLocaleDigit); IOU.setMoneyRequestMerchant(transaction?.transactionID ?? '', distanceMerchant, true); }, [isDistanceRequestWithPendingRoute, hasRoute, distance, unit, rate, currency, translate, toLocaleDigit, isDistanceRequest, transaction]); @@ -482,16 +484,16 @@ function MoneyRequestConfirmationList({ // Auto select the tag if there is only one enabled tag and it is required useEffect(() => { - let updatedTagsString = TransactionUtils.getTag(transaction); + let updatedTagsString = TransactionUtils.getTag(transaction ); policyTagLists.forEach((tagList, index) => { const enabledTags = Object.values(tagList.tags).filter((tag) => tag.enabled); const isTagListRequired = tagList.required === undefined ? false : tagList.required && canUseViolations; - if (!isTagListRequired || enabledTags.length !== 1 || TransactionUtils.getTag(transaction, index)) { + if (!isTagListRequired || enabledTags.length !== 1 || TransactionUtils.getTag(transaction , index)) { return; } updatedTagsString = IOUUtils.insertTagIntoTransactionTagsString(updatedTagsString, enabledTags[0] ? enabledTags[0].name : '', index); }); - if (updatedTagsString !== TransactionUtils.getTag(transaction) && updatedTagsString) { + if (updatedTagsString !== TransactionUtils.getTag(transaction ) && updatedTagsString) { IOU.setMoneyRequestTag(transaction?.transactionID ?? '', updatedTagsString); } }, [policyTagLists, transaction, policyTags, canUseViolations]); @@ -531,11 +533,11 @@ function MoneyRequestConfirmationList({ * @param {String} paymentMethod */ const confirm = useCallback( - (paymentMethod: PaymentMethodType | undefined) => { + (paymentMethod: IouType | PaymentMethodType | undefined) => { if (selectedParticipants.length === 0) { return; } - if ((isMerchantRequired && isMerchantEmpty) || (shouldDisplayFieldError && TransactionUtils.isMerchantMissing(transaction ?? null))) { + if ((isMerchantRequired && isMerchantEmpty) || (shouldDisplayFieldError && TransactionUtils.isMerchantMissing(transaction ))) { setMerchantError(true); return; } @@ -561,7 +563,7 @@ function MoneyRequestConfirmationList({ return; } - if (isEditingSplitBill && TransactionUtils.areRequiredFieldsEmpty(transaction ?? null)) { + if (isEditingSplitBill && TransactionUtils.areRequiredFieldsEmpty(transaction )) { setDidConfirmSplit(true); setFormError('iou.error.genericSmartscanFailureMessage'); return; @@ -624,7 +626,7 @@ function MoneyRequestConfirmationList({ success pressOnEnter isDisabled={shouldDisableButton} - onPress={(event, value) => confirm(value as PaymentMethodType)} + onPress={(_event, value) => confirm(value)} options={splitOrRequestOptions} buttonSize={CONST.DROPDOWN_BUTTON_SIZE.LARGE} enterKeyEventListenerPriority={1} @@ -672,8 +674,8 @@ function MoneyRequestConfirmationList({ style={[styles.moneyRequestMenuItem, styles.mt2]} titleStyle={styles.moneyRequestConfirmationAmount} disabled={didConfirm} - brickRoadIndicator={shouldDisplayFieldError && TransactionUtils.isAmountMissing(transaction ?? null) ? CONST.BRICK_ROAD_INDICATOR_STATUS.ERROR : undefined} - error={shouldDisplayFieldError && TransactionUtils.isAmountMissing(transaction ?? null) ? translate('common.error.enterAmount') : ''} + brickRoadIndicator={shouldDisplayFieldError && TransactionUtils.isAmountMissing(transaction ) ? CONST.BRICK_ROAD_INDICATOR_STATUS.ERROR : undefined} + error={shouldDisplayFieldError && TransactionUtils.isAmountMissing(transaction ) ? translate('common.error.enterAmount') : ''} /> ), shouldShow: shouldShowSmartScanFields, @@ -784,8 +786,8 @@ function MoneyRequestConfirmationList({ }} disabled={didConfirm} interactive={!isReadOnly} - brickRoadIndicator={shouldDisplayFieldError && TransactionUtils.isCreatedMissing(transaction) ? CONST.BRICK_ROAD_INDICATOR_STATUS.ERROR : undefined} - error={shouldDisplayFieldError && TransactionUtils.isCreatedMissing(transaction) ? translate('common.error.enterDate') : ''} + brickRoadIndicator={shouldDisplayFieldError && TransactionUtils.isCreatedMissing(transaction ) ? CONST.BRICK_ROAD_INDICATOR_STATUS.ERROR : undefined} + error={shouldDisplayFieldError && TransactionUtils.isCreatedMissing(transaction ) ? translate('common.error.enterDate') : ''} /> ), shouldShow: shouldShowDate, @@ -936,7 +938,7 @@ function MoneyRequestConfirmationList({ isThumbnail, fileExtension, isLocalFile, - } = receiptPath && receiptFilename ? ReceiptUtils.getThumbnailAndImageURIs(transaction ?? null, receiptPath, receiptFilename) : ({} as ReceiptUtils.ThumbnailAndImageURI); + } = receiptPath && receiptFilename ? ReceiptUtils.getThumbnailAndImageURIs(transaction , receiptPath, receiptFilename) : ({} as ReceiptUtils.ThumbnailAndImageURI); const receiptThumbnailContent = useMemo( () => @@ -987,7 +989,7 @@ function MoneyRequestConfirmationList({ > {isDistanceRequest && ( <View style={styles.confirmationListMapItem}> - <ConfirmedRoute transaction={transaction ?? ({} as OnyxTypes.Transaction)} /> + <ConfirmedRoute transaction={transaction} /> </View> )} { From cf1e5596864b10b8529a3701db8f524d8e58411e Mon Sep 17 00:00:00 2001 From: brunovjk <brunovjk@gmail.com> Date: Mon, 15 Apr 2024 11:31:53 -0300 Subject: [PATCH 109/206] fix type --- .../MoneyRequestConfirmationList.tsx | 53 ++++++++++--------- 1 file changed, 28 insertions(+), 25 deletions(-) diff --git a/src/components/MoneyRequestConfirmationList.tsx b/src/components/MoneyRequestConfirmationList.tsx index 010db6017c9d..fcccfcf2e1f1 100755 --- a/src/components/MoneyRequestConfirmationList.tsx +++ b/src/components/MoneyRequestConfirmationList.tsx @@ -35,6 +35,7 @@ import type {Route} from '@src/ROUTES'; import type * as OnyxTypes from '@src/types/onyx'; import type {Participant} from '@src/types/onyx/IOU'; import type {PaymentMethodType} from '@src/types/onyx/OriginalMessage'; +import type {ReceiptSource} from '@src/types/onyx/Transaction'; import ButtonWithDropdownMenu from './ButtonWithDropdownMenu'; import type {DropdownOption} from './ButtonWithDropdownMenu/types'; import ConfirmedRoute from './ConfirmedRoute'; @@ -46,9 +47,9 @@ import PDFThumbnail from './PDFThumbnail'; import ReceiptEmptyState from './ReceiptEmptyState'; import ReceiptImage from './ReceiptImage'; import SettlementButton from './SettlementButton'; +import ShowMoreButton from './ShowMoreButton'; import Switch from './Switch'; import Text from './Text'; -import ShowMoreButton from './ShowMoreButton'; type IouType = ValueOf<typeof CONST.IOU.TYPE>; @@ -71,7 +72,7 @@ type MoneyRequestConfirmationListOnyxProps = { type MoneyRequestConfirmationListProps = MoneyRequestConfirmationListOnyxProps & { /** Callback to inform parent modal of success */ - onConfirm?: (selectedParticipants: Participant[]) => void; + onConfirm?: (selectedParticipants: Array<Participant | ReportUtils.OptionData>) => void; /** Callback to parent modal to send money */ onSendMoney?: (paymentMethod: IouType | PaymentMethodType | undefined) => void; @@ -102,7 +103,7 @@ type MoneyRequestConfirmationListProps = MoneyRequestConfirmationListOnyxProps & /** IOU Category */ iouCategory?: string; - + /** IOU Tag */ iouTag?: string; @@ -113,7 +114,7 @@ type MoneyRequestConfirmationListProps = MoneyRequestConfirmationListOnyxProps & onToggleBillable?: (isOn: boolean) => void; /** Selected participants from MoneyRequestModal with login / accountID */ - selectedParticipants: Participant[]; + selectedParticipants: Array<Participant | ReportUtils.OptionData>; /** Payee of the money request with login */ payeePersonalDetails?: OnyxEntry<OnyxTypes.PersonalDetails>; @@ -134,7 +135,7 @@ type MoneyRequestConfirmationListProps = MoneyRequestConfirmationListOnyxProps & reportID?: string; /** File path of the receipt */ - receiptPath?: string; + receiptPath?: ReceiptSource; /** File name of the receipt */ receiptFilename?: string; @@ -194,7 +195,7 @@ function MoneyRequestConfirmationList({ iouCurrencyCode, iouMerchant, hasMultipleParticipants, - selectedParticipants: pickedParticipants, + selectedParticipants: selectedParticipantsProp, payeePersonalDetails: payeePersonalDetailsProp, canModifyParticipants = false, session, @@ -255,7 +256,7 @@ function MoneyRequestConfirmationList({ // A flag for showing the billable field const shouldShowBillable = policy?.disabledFields?.defaultBillable === false; - const hasRoute = TransactionUtils.hasRoute(transaction ); + const hasRoute = TransactionUtils.hasRoute(transaction); const isDistanceRequestWithPendingRoute = isDistanceRequest && (!hasRoute || !rate); const formattedAmount = isDistanceRequestWithPendingRoute ? '' @@ -287,7 +288,7 @@ function MoneyRequestConfirmationList({ return false; } - return (!!hasSmartScanFailed && TransactionUtils.hasMissingSmartscanFields(transaction )) || (didConfirmSplit && TransactionUtils.areRequiredFieldsEmpty(transaction )); + return (!!hasSmartScanFailed && TransactionUtils.hasMissingSmartscanFields(transaction)) || (didConfirmSplit && TransactionUtils.areRequiredFieldsEmpty(transaction)); }, [isEditingSplitBill, hasSmartScanFailed, transaction, didConfirmSplit]); const isMerchantEmpty = !iouMerchant || iouMerchant === CONST.TRANSACTION.PARTIAL_TRANSACTION_MERCHANT; @@ -349,7 +350,7 @@ function MoneyRequestConfirmationList({ * Returns the participants with amount */ const getParticipantsWithAmount = useCallback( - (participantsList: Participant[]) => { + (participantsList: Array<Participant | ReportUtils.OptionData>): Array<Participant | ReportUtils.OptionData> => { const amount = IOUUtils.calculateAmount(participantsList.length, iouAmount, iouCurrencyCode ?? ''); return OptionsListUtils.getIOUConfirmationOptionsFromParticipants(participantsList, amount > 0 ? CurrencyUtils.convertToDisplayString(amount, iouCurrencyCode) : ''); }, @@ -384,7 +385,10 @@ function MoneyRequestConfirmationList({ ]; }, [isTypeTrackExpense, isTypeSplit, iouAmount, receiptPath, isTypeRequest, isDistanceRequestWithPendingRoute, iouType, translate, formattedAmount]); - const selectedParticipants: Participant[] = useMemo(() => pickedParticipants.filter((participant) => participant.selected), [pickedParticipants]); + const selectedParticipants: Array<Participant | ReportUtils.OptionData> = useMemo( + () => selectedParticipantsProp.filter((participant) => participant.selected), + [selectedParticipantsProp], + ); const payeePersonalDetails = useMemo(() => payeePersonalDetailsProp ?? currentUserPersonalDetails, [payeePersonalDetailsProp, currentUserPersonalDetails]); const userCanModifyParticipants = useRef(!isReadOnly && canModifyParticipants && hasMultipleParticipants); useEffect(() => { @@ -394,7 +398,7 @@ function MoneyRequestConfirmationList({ const optionSelectorSections: OptionsListUtils.CategorySection[] = useMemo(() => { const sections = []; - const unselectedParticipants = pickedParticipants.filter((participant) => !participant.selected); + const unselectedParticipants = selectedParticipantsProp.filter((participant) => !participant.selected); if (hasMultipleParticipants) { const formattedSelectedParticipants = getParticipantsWithAmount(selectedParticipants); let formattedParticipantsList = [...new Set([...formattedSelectedParticipants, ...unselectedParticipants])]; @@ -439,7 +443,7 @@ function MoneyRequestConfirmationList({ return sections; }, [ selectedParticipants, - pickedParticipants, + selectedParticipantsProp, hasMultipleParticipants, iouAmount, iouCurrencyCode, @@ -450,7 +454,7 @@ function MoneyRequestConfirmationList({ canModifyParticipants, ]); - const selectedOptions: Array<Participant | OptionsListUtils.PayeePersonalDetails> = useMemo(() => { + const selectedOptions: Array<Participant | ReportUtils.OptionData | OptionsListUtils.PayeePersonalDetails> = useMemo(() => { if (!hasMultipleParticipants) { return []; } @@ -484,16 +488,16 @@ function MoneyRequestConfirmationList({ // Auto select the tag if there is only one enabled tag and it is required useEffect(() => { - let updatedTagsString = TransactionUtils.getTag(transaction ); + let updatedTagsString = TransactionUtils.getTag(transaction); policyTagLists.forEach((tagList, index) => { const enabledTags = Object.values(tagList.tags).filter((tag) => tag.enabled); const isTagListRequired = tagList.required === undefined ? false : tagList.required && canUseViolations; - if (!isTagListRequired || enabledTags.length !== 1 || TransactionUtils.getTag(transaction , index)) { + if (!isTagListRequired || enabledTags.length !== 1 || TransactionUtils.getTag(transaction, index)) { return; } updatedTagsString = IOUUtils.insertTagIntoTransactionTagsString(updatedTagsString, enabledTags[0] ? enabledTags[0].name : '', index); }); - if (updatedTagsString !== TransactionUtils.getTag(transaction ) && updatedTagsString) { + if (updatedTagsString !== TransactionUtils.getTag(transaction) && updatedTagsString) { IOU.setMoneyRequestTag(transaction?.transactionID ?? '', updatedTagsString); } }, [policyTagLists, transaction, policyTags, canUseViolations]); @@ -537,7 +541,7 @@ function MoneyRequestConfirmationList({ if (selectedParticipants.length === 0) { return; } - if ((isMerchantRequired && isMerchantEmpty) || (shouldDisplayFieldError && TransactionUtils.isMerchantMissing(transaction ))) { + if ((isMerchantRequired && isMerchantEmpty) || (shouldDisplayFieldError && TransactionUtils.isMerchantMissing(transaction))) { setMerchantError(true); return; } @@ -563,7 +567,7 @@ function MoneyRequestConfirmationList({ return; } - if (isEditingSplitBill && TransactionUtils.areRequiredFieldsEmpty(transaction )) { + if (isEditingSplitBill && TransactionUtils.areRequiredFieldsEmpty(transaction)) { setDidConfirmSplit(true); setFormError('iou.error.genericSmartscanFailureMessage'); return; @@ -674,8 +678,8 @@ function MoneyRequestConfirmationList({ style={[styles.moneyRequestMenuItem, styles.mt2]} titleStyle={styles.moneyRequestConfirmationAmount} disabled={didConfirm} - brickRoadIndicator={shouldDisplayFieldError && TransactionUtils.isAmountMissing(transaction ) ? CONST.BRICK_ROAD_INDICATOR_STATUS.ERROR : undefined} - error={shouldDisplayFieldError && TransactionUtils.isAmountMissing(transaction ) ? translate('common.error.enterAmount') : ''} + brickRoadIndicator={shouldDisplayFieldError && TransactionUtils.isAmountMissing(transaction) ? CONST.BRICK_ROAD_INDICATOR_STATUS.ERROR : undefined} + error={shouldDisplayFieldError && TransactionUtils.isAmountMissing(transaction) ? translate('common.error.enterAmount') : ''} /> ), shouldShow: shouldShowSmartScanFields, @@ -786,8 +790,8 @@ function MoneyRequestConfirmationList({ }} disabled={didConfirm} interactive={!isReadOnly} - brickRoadIndicator={shouldDisplayFieldError && TransactionUtils.isCreatedMissing(transaction ) ? CONST.BRICK_ROAD_INDICATOR_STATUS.ERROR : undefined} - error={shouldDisplayFieldError && TransactionUtils.isCreatedMissing(transaction ) ? translate('common.error.enterDate') : ''} + brickRoadIndicator={shouldDisplayFieldError && TransactionUtils.isCreatedMissing(transaction) ? CONST.BRICK_ROAD_INDICATOR_STATUS.ERROR : undefined} + error={shouldDisplayFieldError && TransactionUtils.isCreatedMissing(transaction) ? translate('common.error.enterDate') : ''} /> ), shouldShow: shouldShowDate, @@ -938,7 +942,7 @@ function MoneyRequestConfirmationList({ isThumbnail, fileExtension, isLocalFile, - } = receiptPath && receiptFilename ? ReceiptUtils.getThumbnailAndImageURIs(transaction , receiptPath, receiptFilename) : ({} as ReceiptUtils.ThumbnailAndImageURI); + } = receiptPath && receiptFilename ? ReceiptUtils.getThumbnailAndImageURIs(transaction, receiptPath, receiptFilename) : ({} as ReceiptUtils.ThumbnailAndImageURI); const receiptThumbnailContent = useMemo( () => @@ -955,8 +959,7 @@ function MoneyRequestConfirmationList({ <ReceiptImage style={styles.moneyRequestImage} isThumbnail={isThumbnail} - // eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing - source={receiptThumbnail || receiptImage || ''} + source={String(receiptThumbnail ?? receiptImage)} // AuthToken is required when retrieving the image from the server // but we don't need it to load the blob:// or file:// image when starting a money request / split bill // So if we have a thumbnail, it means we're retrieving the image from the server From e355f284c1d169f630875c0ba6dc6f00575d640d Mon Sep 17 00:00:00 2001 From: Alberto <alberto@expensify.com> Date: Mon, 15 Apr 2024 16:55:40 +0200 Subject: [PATCH 110/206] first typescript cleanup round --- .../iou/request/step/IOURequestStepAmount.tsx | 46 +++++++++---------- .../request/step/IOURequestStepDistance.tsx | 40 +++++++--------- 2 files changed, 39 insertions(+), 47 deletions(-) diff --git a/src/pages/iou/request/step/IOURequestStepAmount.tsx b/src/pages/iou/request/step/IOURequestStepAmount.tsx index 8c7161d12b82..3b4736efc456 100644 --- a/src/pages/iou/request/step/IOURequestStepAmount.tsx +++ b/src/pages/iou/request/step/IOURequestStepAmount.tsx @@ -1,17 +1,9 @@ import {useFocusEffect} from '@react-navigation/native'; import lodashGet from 'lodash/get'; -import lodashIsEmpty from 'lodash/isEmpty'; -import PropTypes from 'prop-types'; -import React, {useCallback, useEffect, useRef} from 'react'; +import React, {useCallback, useEffect, useMemo, useRef} from 'react'; import type {OnyxEntry} from 'react-native-onyx'; import {withOnyx} from 'react-native-onyx'; import _ from 'underscore'; -import transactionPropTypes from '@components/transactionPropTypes'; -import withCurrentUserPersonalDetails, { - withCurrentUserPersonalDetailsDefaultProps, - WithCurrentUserPersonalDetailsProps, - withCurrentUserPersonalDetailsPropTypes -} from '@components/withCurrentUserPersonalDetails'; import type {BaseTextInputRef} from '@components/TextInput/BaseTextInput/types'; import useLocalize from '@hooks/useLocalize'; import * as TransactionEdit from '@libs/actions/TransactionEdit'; @@ -22,8 +14,6 @@ import * as ReportUtils from '@libs/ReportUtils'; import * as TransactionUtils from '@libs/TransactionUtils'; import {getRequestType} from '@libs/TransactionUtils'; import MoneyRequestAmountForm from '@pages/iou/steps/MoneyRequestAmountForm'; -import personalDetailsPropType from '@pages/personalDetailsPropType'; -import reportPropTypes from '@pages/reportPropTypes'; import * as IOU from '@userActions/IOU'; import CONST from '@src/CONST'; import ONYXKEYS from '@src/ONYXKEYS'; @@ -36,10 +26,11 @@ import withFullTransactionOrNotFound from './withFullTransactionOrNotFound'; import type {WithWritableReportOrNotFoundProps} from './withWritableReportOrNotFound'; import withWritableReportOrNotFound from './withWritableReportOrNotFound'; import * as OnyxTypes from "@src/types/onyx"; -import IOURequestStepScanWithFullTransactionOrNotFound from "@pages/iou/request/step/IOURequestStepScan"; +import type {PaymentMethodType} from '@src/types/onyx/OriginalMessage'; type AmountParams = { amount: string; + paymentMethod?: PaymentMethodType; }; type IOURequestStepAmountOnyxProps = { @@ -94,7 +85,13 @@ function IOURequestStepAmount({ // For quick button actions, we'll skip the confirmation page unless the report is archived or this is a workspace request, as // the user will have to add a merchant. - const shouldSkipConfirmation = skipConfirmation && report.reportID && !ReportUtils.isArchivedRoom(report) && !ReportUtils.isPolicyExpenseChat(report); + const shouldSkipConfirmation: boolean = useMemo(() => { + if (!skipConfirmation || !report?.reportID) { + return false; + } + + return (!(ReportUtils.isArchivedRoom(report) || ReportUtils.isPolicyExpenseChat(report))); + }, [report, skipConfirmation]); useFocusEffect( useCallback(() => { @@ -145,7 +142,7 @@ function IOURequestStepAmount({ Navigation.navigate(ROUTES.MONEY_REQUEST_STEP_CURRENCY.getRoute(action, iouType, transactionID, reportID, backTo ? 'confirm' : '', Navigation.getActiveRouteWithoutParams())); }; - const navigateToNextPage = ({amount}: AmountParams, paymentMethod) => { + const navigateToNextPage = ({amount, paymentMethod}: AmountParams) => { isSaveButtonPressed.current = true; const amountInSmallestCurrencyUnits = CurrencyUtils.convertToBackendAmount(Number.parseFloat(amount)); @@ -171,14 +168,15 @@ function IOURequestStepAmount({ if (iouType === CONST.IOU.TYPE.SPLIT) { IOU.splitBillAndOpenReport({ participants, - currentUserLogin: currentUserPersonalDetails.login || '', - currentUserAccountID: currentUserPersonalDetails.accountID || 0, + currentUserLogin: currentUserPersonalDetails.login ?? '', + currentUserAccountID: currentUserPersonalDetails.accountID ?? 0, amount: backendAmount, comment: '', currency, + merchant: '', tag: '', category: '', - created: transaction.created, + created: transaction?.created ?? '', billable: false, iouRequestType: CONST.IOU.REQUEST_TYPE.MANUAL, }); @@ -198,13 +196,13 @@ function IOURequestStepAmount({ report, backendAmount, currency, - transaction.created, + transaction?.created ?? '', '', - currentUserPersonalDetails.login, - currentUserPersonalDetails.accountID, + currentUserPersonalDetails.login ?? '', + currentUserPersonalDetails.accountID ?? 0, participants[0], '', - null, + {}, ); return; } @@ -219,7 +217,7 @@ function IOURequestStepAmount({ Navigation.navigate(ROUTES.MONEY_REQUEST_STEP_PARTICIPANTS.getRoute(iouType, transactionID, reportID)); }; - const saveAmountAndCurrency = ({amount}: AmountParams, paymentMethod) => { + const saveAmountAndCurrency = ({amount, paymentMethod}: AmountParams) => { if (!isEditing) { navigateToNextPage({amount, paymentMethod}); return; @@ -255,9 +253,9 @@ function IOURequestStepAmount({ isEditing={!!backTo || isEditing} currency={currency} amount={Math.abs(transactionAmount)} - skipConfirmation={shouldSkipConfirmation} + skipConfirmation={shouldSkipConfirmation ?? false} iouType={iouType} - policyID={policy.policyID} + policyID={policy?.policyID ?? 0} bankAccountRoute={ReportUtils.getBankAccountRoute(report)} ref={(e) => (textInput.current = e)} onCurrencyButtonPress={navigateToCurrencySelectionPage} diff --git a/src/pages/iou/request/step/IOURequestStepDistance.tsx b/src/pages/iou/request/step/IOURequestStepDistance.tsx index 341cee0c158b..f87ca4726ef8 100644 --- a/src/pages/iou/request/step/IOURequestStepDistance.tsx +++ b/src/pages/iou/request/step/IOURequestStepDistance.tsx @@ -1,5 +1,4 @@ import lodashGet from 'lodash/get'; -import PropTypes from 'prop-types'; import {isEmpty, isEqual} from 'lodash'; import React, {useCallback, useEffect, useMemo, useRef, useState} from 'react'; import {View} from 'react-native'; @@ -13,11 +12,8 @@ import DistanceRequestFooter from '@components/DistanceRequest/DistanceRequestFo import DistanceRequestRenderItem from '@components/DistanceRequest/DistanceRequestRenderItem'; import DotIndicatorMessage from '@components/DotIndicatorMessage'; import DraggableList from '@components/DraggableList'; -import transactionPropTypes from '@components/transactionPropTypes'; import withCurrentUserPersonalDetails, { - withCurrentUserPersonalDetailsDefaultProps, WithCurrentUserPersonalDetailsProps, - withCurrentUserPersonalDetailsPropTypes } from '@components/withCurrentUserPersonalDetails'; import useLocalize from '@hooks/useLocalize'; import useNetwork from '@hooks/useNetwork'; @@ -28,10 +24,6 @@ import Navigation from '@libs/Navigation/Navigation'; import * as OptionsListUtils from '@libs/OptionsListUtils'; import * as ReportUtils from '@libs/ReportUtils'; import * as TransactionUtils from '@libs/TransactionUtils'; -import personalDetailsPropType from '@pages/personalDetailsPropType'; -import reportPropTypes from '@pages/reportPropTypes'; -import {policyPropTypes} from '@pages/workspace/withPolicy'; -import variables from '@styles/variables'; import * as IOU from '@userActions/IOU'; import * as MapboxToken from '@userActions/MapboxToken'; import * as TransactionAction from '@userActions/Transaction'; @@ -47,7 +39,6 @@ import StepScreenWrapper from './StepScreenWrapper'; import withFullTransactionOrNotFound from './withFullTransactionOrNotFound'; import type {WithWritableReportOrNotFoundProps} from './withWritableReportOrNotFound'; import withWritableReportOrNotFound from './withWritableReportOrNotFound'; -import IOURequestStepAmountWithFullTransactionOrNotFound from "@pages/iou/request/step/IOURequestStepAmount"; type IOURequestStepDistanceOnyxProps = { /** backup version of the original transaction */ @@ -115,11 +106,13 @@ function IOURequestStepDistance({ // For quick button actions, we'll skip the confirmation page unless the report is archived or this is a workspace // request and the workspace requires a category or a tag - const shouldSkipConfirmation = - skipConfirmation && - report.reportID && - !ReportUtils.isArchivedRoom(report) && - !(ReportUtils.isPolicyExpenseChat(reportID) && (lodashGet(policy, 'requiresCategory', false) || lodashGet(policy, 'requiresTag', false))); + const shouldSkipConfirmation: boolean = useMemo(() => { + if (!skipConfirmation || !report?.reportID) { + return false; + } + + return (!ReportUtils.isArchivedRoom(report) && !ReportUtils.isPolicyExpenseChat(report) && !policy?.requiresCategory && !policy?.requiresTag); + }, [report, skipConfirmation, policy]); let buttonText = !isCreatingNewRequest ? translate('common.save') : translate('common.next'); if (shouldSkipConfirmation) { buttonText = iouType === CONST.IOU.TYPE.SPLIT ? translate('iou.split') : translate('iou.request'); @@ -202,7 +195,7 @@ function IOURequestStepDistance({ // to the confirm step. if (report?.reportID && !ReportUtils.isArchivedRoom(report)) { const selectedParticipants = IOU.setMoneyRequestParticipantsFromReport(transactionID, report); - const participants = _.map(selectedParticipants, (participant) => { + const participants = selectedParticipants.map((participant) => { const participantAccountID = lodashGet(participant, 'accountID', 0); return participantAccountID ? OptionsListUtils.getParticipantsOption(participant, personalDetails) : OptionsListUtils.getReportOption(participant); }); @@ -210,12 +203,13 @@ function IOURequestStepDistance({ if (iouType === CONST.IOU.TYPE.SPLIT) { IOU.splitBillAndOpenReport({ participants, - currentUserLogin: currentUserPersonalDetails.login, - currentUserAccountID: currentUserPersonalDetails.accountID, - aamount: 0, - currency: transaction.currency || 'USD', + currentUserLogin: currentUserPersonalDetails.login ?? '', + currentUserAccountID: currentUserPersonalDetails.accountID ?? 0, + amount: 0, + comment: '', + currency: transaction?.currency ?? 'USD', merchant: translate('iou.routePending'), - created: transaction.created, + created: transaction?.created ?? '', category: '', tag: '', billable: false, @@ -229,11 +223,11 @@ function IOURequestStepDistance({ report, participants[0], '', - transaction.created, + transaction?.created ?? '', '', '', 0, - transaction.currency, + transaction?.currency ?? 'USD', translate('iou.routePending'), false, TransactionUtils.getValidWaypoints(waypoints, true), @@ -410,7 +404,7 @@ const IOURequestStepDistanceWithOnyx = withOnyx<IOURequestStepDistanceProps, IOU }, }, policy: { - key: ({report}) => `${ONYXKEYS.COLLECTION.POLICY}${report ? report.policyID : '0'}`, + key: ({report}) => `${ONYXKEYS.COLLECTION.POLICY}${report ? report?.policyID : '0'}`, }, personalDetails: { key: ONYXKEYS.PERSONAL_DETAILS_LIST, From b77d5748e55cac2f070c9d139f838c57c311bac7 Mon Sep 17 00:00:00 2001 From: brunovjk <brunovjk@gmail.com> Date: Mon, 15 Apr 2024 12:03:54 -0300 Subject: [PATCH 111/206] canModifyParticipantsProp --- .../MoneyRequestConfirmationList.tsx | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) diff --git a/src/components/MoneyRequestConfirmationList.tsx b/src/components/MoneyRequestConfirmationList.tsx index fcccfcf2e1f1..99f20acde27d 100755 --- a/src/components/MoneyRequestConfirmationList.tsx +++ b/src/components/MoneyRequestConfirmationList.tsx @@ -197,7 +197,7 @@ function MoneyRequestConfirmationList({ hasMultipleParticipants, selectedParticipants: selectedParticipantsProp, payeePersonalDetails: payeePersonalDetailsProp, - canModifyParticipants = false, + canModifyParticipants: canModifyParticipantsProp = false, session, isReadOnly = false, bankAccountRoute = '', @@ -390,12 +390,9 @@ function MoneyRequestConfirmationList({ [selectedParticipantsProp], ); const payeePersonalDetails = useMemo(() => payeePersonalDetailsProp ?? currentUserPersonalDetails, [payeePersonalDetailsProp, currentUserPersonalDetails]); - const userCanModifyParticipants = useRef(!isReadOnly && canModifyParticipants && hasMultipleParticipants); - useEffect(() => { - userCanModifyParticipants.current = !isReadOnly && canModifyParticipants && hasMultipleParticipants; - }, [isReadOnly, canModifyParticipants, hasMultipleParticipants]); - const shouldDisablePaidBySection = userCanModifyParticipants.current; - + const canModifyParticipants = !isReadOnly && canModifyParticipantsProp && hasMultipleParticipants; + const shouldDisablePaidBySection = canModifyParticipants; + const optionSelectorSections: OptionsListUtils.CategorySection[] = useMemo(() => { const sections = []; const unselectedParticipants = selectedParticipantsProp.filter((participant) => !participant.selected); @@ -974,18 +971,18 @@ function MoneyRequestConfirmationList({ // @ts-expect-error This component is deprecated and will not be migrated to TypeScript (context: https://expensify.slack.com/archives/C01GTK53T8Q/p1709232289899589?thread_ts=1709156803.359359&cid=C01GTK53T8Q) <OptionsSelector sections={optionSelectorSections} - onSelectRow={userCanModifyParticipants.current ? selectParticipant : navigateToReportOrUserDetail} + onSelectRow={canModifyParticipants ? selectParticipant : navigateToReportOrUserDetail} onAddToSelection={selectParticipant} onConfirmSelection={confirm} selectedOptions={selectedOptions} - canSelectMultipleOptions={userCanModifyParticipants.current} - disableArrowKeysActions={!userCanModifyParticipants.current} + canSelectMultipleOptions={canModifyParticipants} + disableArrowKeysActions={!canModifyParticipants} boldStyle showTitleTooltip shouldTextInputAppearBelowOptions shouldShowTextInput={false} shouldUseStyleForChildren={false} - optionHoveredStyle={userCanModifyParticipants.current ? styles.hoveredComponentBG : {}} + optionHoveredStyle={canModifyParticipants ? styles.hoveredComponentBG : {}} footerContent={!isEditingSplitBill && footerContent} listStyles={listStyles} shouldAllowScrollingChildren From 860600c6ad6bc74ea2d97a2a60a7460cccc6b8e6 Mon Sep 17 00:00:00 2001 From: Alberto <alberto@expensify.com> Date: Mon, 15 Apr 2024 17:24:04 +0200 Subject: [PATCH 112/206] prettier --- src/pages/iou/request/step/IOURequestStepAmount.tsx | 8 ++++---- src/pages/iou/request/step/IOURequestStepDistance.tsx | 10 ++++------ .../request/step/IOURequestStepScan/index.native.tsx | 4 ++-- .../iou/request/step/IOURequestStepScan/index.tsx | 4 ++-- src/pages/iou/request/step/IOURequestStepScan/types.ts | 2 +- 5 files changed, 13 insertions(+), 15 deletions(-) diff --git a/src/pages/iou/request/step/IOURequestStepAmount.tsx b/src/pages/iou/request/step/IOURequestStepAmount.tsx index 3b4736efc456..b435db4d24e2 100644 --- a/src/pages/iou/request/step/IOURequestStepAmount.tsx +++ b/src/pages/iou/request/step/IOURequestStepAmount.tsx @@ -5,6 +5,7 @@ import type {OnyxEntry} from 'react-native-onyx'; import {withOnyx} from 'react-native-onyx'; import _ from 'underscore'; import type {BaseTextInputRef} from '@components/TextInput/BaseTextInput/types'; +import withCurrentUserPersonalDetails, {WithCurrentUserPersonalDetailsProps} from '@components/withCurrentUserPersonalDetails'; import useLocalize from '@hooks/useLocalize'; import * as TransactionEdit from '@libs/actions/TransactionEdit'; import * as CurrencyUtils from '@libs/CurrencyUtils'; @@ -20,13 +21,13 @@ import ONYXKEYS from '@src/ONYXKEYS'; import ROUTES from '@src/ROUTES'; import type SCREENS from '@src/SCREENS'; import type {Transaction} from '@src/types/onyx'; +import * as OnyxTypes from '@src/types/onyx'; +import type {PaymentMethodType} from '@src/types/onyx/OriginalMessage'; import {isEmptyObject} from '@src/types/utils/EmptyObject'; import StepScreenWrapper from './StepScreenWrapper'; import withFullTransactionOrNotFound from './withFullTransactionOrNotFound'; import type {WithWritableReportOrNotFoundProps} from './withWritableReportOrNotFound'; import withWritableReportOrNotFound from './withWritableReportOrNotFound'; -import * as OnyxTypes from "@src/types/onyx"; -import type {PaymentMethodType} from '@src/types/onyx/OriginalMessage'; type AmountParams = { amount: string; @@ -90,7 +91,7 @@ function IOURequestStepAmount({ return false; } - return (!(ReportUtils.isArchivedRoom(report) || ReportUtils.isPolicyExpenseChat(report))); + return !(ReportUtils.isArchivedRoom(report) || ReportUtils.isPolicyExpenseChat(report)); }, [report, skipConfirmation]); useFocusEffect( @@ -295,7 +296,6 @@ const IOURequestStepAmountWithOnyx = withOnyx<IOURequestStepAmountProps, IOURequ }, })(IOURequestStepAmount); - // eslint-disable-next-line rulesdir/no-negated-variables const IOURequestStepAmountWithCurrentUserPersonalDetails = withCurrentUserPersonalDetails(IOURequestStepAmountWithOnyx); // eslint-disable-next-line rulesdir/no-negated-variables diff --git a/src/pages/iou/request/step/IOURequestStepDistance.tsx b/src/pages/iou/request/step/IOURequestStepDistance.tsx index f87ca4726ef8..875b749cbe0d 100644 --- a/src/pages/iou/request/step/IOURequestStepDistance.tsx +++ b/src/pages/iou/request/step/IOURequestStepDistance.tsx @@ -1,5 +1,5 @@ -import lodashGet from 'lodash/get'; import {isEmpty, isEqual} from 'lodash'; +import lodashGet from 'lodash/get'; import React, {useCallback, useEffect, useMemo, useRef, useState} from 'react'; import {View} from 'react-native'; // eslint-disable-next-line no-restricted-imports @@ -12,9 +12,7 @@ import DistanceRequestFooter from '@components/DistanceRequest/DistanceRequestFo import DistanceRequestRenderItem from '@components/DistanceRequest/DistanceRequestRenderItem'; import DotIndicatorMessage from '@components/DotIndicatorMessage'; import DraggableList from '@components/DraggableList'; -import withCurrentUserPersonalDetails, { - WithCurrentUserPersonalDetailsProps, -} from '@components/withCurrentUserPersonalDetails'; +import withCurrentUserPersonalDetails, {WithCurrentUserPersonalDetailsProps} from '@components/withCurrentUserPersonalDetails'; import useLocalize from '@hooks/useLocalize'; import useNetwork from '@hooks/useNetwork'; import usePrevious from '@hooks/usePrevious'; @@ -111,7 +109,7 @@ function IOURequestStepDistance({ return false; } - return (!ReportUtils.isArchivedRoom(report) && !ReportUtils.isPolicyExpenseChat(report) && !policy?.requiresCategory && !policy?.requiresTag); + return !ReportUtils.isArchivedRoom(report) && !ReportUtils.isPolicyExpenseChat(report) && !policy?.requiresCategory && !policy?.requiresTag; }, [report, skipConfirmation, policy]); let buttonText = !isCreatingNewRequest ? translate('common.save') : translate('common.next'); if (shouldSkipConfirmation) { @@ -424,4 +422,4 @@ const IOURequestStepDistanceWithWritableReportOrNotFound = withWritableReportOrN // eslint-disable-next-line rulesdir/no-negated-variables const IOURequestStepDistanceWithFullTransactionOrNotFound = withFullTransactionOrNotFound(IOURequestStepDistanceWithWritableReportOrNotFound); -export default IOURequestStepDistanceWithFullTransactionOrNotFound; \ No newline at end of file +export default IOURequestStepDistanceWithFullTransactionOrNotFound; diff --git a/src/pages/iou/request/step/IOURequestStepScan/index.native.tsx b/src/pages/iou/request/step/IOURequestStepScan/index.native.tsx index 62bf388a7ab8..e18586185f6a 100644 --- a/src/pages/iou/request/step/IOURequestStepScan/index.native.tsx +++ b/src/pages/iou/request/step/IOURequestStepScan/index.native.tsx @@ -36,7 +36,7 @@ import ROUTES from '@src/ROUTES'; import type {Receipt} from '@src/types/onyx/Transaction'; import CameraPermission from './CameraPermission'; import NavigationAwareCamera from './NavigationAwareCamera'; -import type {IOURequestStepScanProps} from './types'; +import type {IOURequestStepOnyxProps, IOURequestStepScanProps} from './types'; function IOURequestStepScan({ report, @@ -427,7 +427,7 @@ function IOURequestStepScan({ IOURequestStepScan.displayName = 'IOURequestStepScan'; -const IOURequestStepScanWithOnyx = withOnyx<IOURequestStepScanProps, IOURequestStepScanOnyxProps>({ +const IOURequestStepScanWithOnyx = withOnyx<IOURequestStepScanProps, IOURequestStepOnyxProps>({ policy: { key: ({report}) => `${ONYXKEYS.COLLECTION.POLICY}${report ? report.policyID : '0'}`, }, diff --git a/src/pages/iou/request/step/IOURequestStepScan/index.tsx b/src/pages/iou/request/step/IOURequestStepScan/index.tsx index 63eb38ada856..eab7c7870a35 100644 --- a/src/pages/iou/request/step/IOURequestStepScan/index.tsx +++ b/src/pages/iou/request/step/IOURequestStepScan/index.tsx @@ -38,7 +38,7 @@ import ROUTES from '@src/ROUTES'; import type {Receipt} from '@src/types/onyx/Transaction'; import {isEmptyObject} from '@src/types/utils/EmptyObject'; import NavigationAwareCamera from './NavigationAwareCamera'; -import type {IOURequestStepScanProps} from './types'; +import type {IOURequestStepOnyxProps, IOURequestStepScanProps} from './types'; function IOURequestStepScan({ report, @@ -548,7 +548,7 @@ function IOURequestStepScan({ IOURequestStepScan.displayName = 'IOURequestStepScan'; -const IOURequestStepScanWithOnyx = withOnyx<IOURequestStepScanProps, IOURequestStepScanOnyxProps>({ +const IOURequestStepScanWithOnyx = withOnyx<Omit<IOURequestStepScanProps, 'user'>, Omit<IOURequestStepOnyxProps, 'user'>>({ policy: { key: ({report}) => `${ONYXKEYS.COLLECTION.POLICY}${report ? report.policyID : '0'}`, }, diff --git a/src/pages/iou/request/step/IOURequestStepScan/types.ts b/src/pages/iou/request/step/IOURequestStepScan/types.ts index 73caac5f6656..7a8d99ac6e23 100644 --- a/src/pages/iou/request/step/IOURequestStepScan/types.ts +++ b/src/pages/iou/request/step/IOURequestStepScan/types.ts @@ -1,8 +1,8 @@ import type {OnyxEntry} from 'react-native-onyx'; +import {WithCurrentUserPersonalDetailsProps} from '@components/withCurrentUserPersonalDetails'; import type {WithWritableReportOrNotFoundProps} from '@pages/iou/request/step/withWritableReportOrNotFound'; import type SCREENS from '@src/SCREENS'; import type * as OnyxTypes from '@src/types/onyx'; -import {WithCurrentUserPersonalDetailsProps} from "@components/withCurrentUserPersonalDetails"; type IOURequestStepOnyxProps = { user: OnyxEntry<OnyxTypes.User>; From d6e40900c6dcdf59c7ec9fd17e35e204b8347a15 Mon Sep 17 00:00:00 2001 From: Alberto <alberto@expensify.com> Date: Mon, 15 Apr 2024 17:37:42 +0200 Subject: [PATCH 113/206] lint --- .../iou/request/step/IOURequestStepAmount.tsx | 15 +++++++-------- .../iou/request/step/IOURequestStepDistance.tsx | 8 ++++---- 2 files changed, 11 insertions(+), 12 deletions(-) diff --git a/src/pages/iou/request/step/IOURequestStepAmount.tsx b/src/pages/iou/request/step/IOURequestStepAmount.tsx index b435db4d24e2..331a3265be8a 100644 --- a/src/pages/iou/request/step/IOURequestStepAmount.tsx +++ b/src/pages/iou/request/step/IOURequestStepAmount.tsx @@ -1,11 +1,10 @@ import {useFocusEffect} from '@react-navigation/native'; -import lodashGet from 'lodash/get'; import React, {useCallback, useEffect, useMemo, useRef} from 'react'; import type {OnyxEntry} from 'react-native-onyx'; import {withOnyx} from 'react-native-onyx'; -import _ from 'underscore'; import type {BaseTextInputRef} from '@components/TextInput/BaseTextInput/types'; -import withCurrentUserPersonalDetails, {WithCurrentUserPersonalDetailsProps} from '@components/withCurrentUserPersonalDetails'; +import withCurrentUserPersonalDetails from '@components/withCurrentUserPersonalDetails'; +import type {WithCurrentUserPersonalDetailsProps} from '@components/withCurrentUserPersonalDetails'; import useLocalize from '@hooks/useLocalize'; import * as TransactionEdit from '@libs/actions/TransactionEdit'; import * as CurrencyUtils from '@libs/CurrencyUtils'; @@ -21,7 +20,7 @@ import ONYXKEYS from '@src/ONYXKEYS'; import ROUTES from '@src/ROUTES'; import type SCREENS from '@src/SCREENS'; import type {Transaction} from '@src/types/onyx'; -import * as OnyxTypes from '@src/types/onyx'; +import type * as OnyxTypes from '@src/types/onyx'; import type {PaymentMethodType} from '@src/types/onyx/OriginalMessage'; import {isEmptyObject} from '@src/types/utils/EmptyObject'; import StepScreenWrapper from './StepScreenWrapper'; @@ -159,8 +158,8 @@ function IOURequestStepAmount({ // to the confirm step. if (report?.reportID && !ReportUtils.isArchivedRoom(report)) { const selectedParticipants = IOU.setMoneyRequestParticipantsFromReport(transactionID, report); - const participants = _.map(selectedParticipants, (participant) => { - const participantAccountID = lodashGet(participant, 'accountID', 0); + const participants = selectedParticipants.map((participant) => { + const participantAccountID = participant?.accountID ?? 0; return participantAccountID ? OptionsListUtils.getParticipantsOption(participant, personalDetails) : OptionsListUtils.getReportOption(participant); }); const backendAmount = CurrencyUtils.convertToBackendAmount(Number.parseFloat(amount)); @@ -256,7 +255,7 @@ function IOURequestStepAmount({ amount={Math.abs(transactionAmount)} skipConfirmation={shouldSkipConfirmation ?? false} iouType={iouType} - policyID={policy?.policyID ?? 0} + policyID={policy?.id ?? ''} bankAccountRoute={ReportUtils.getBankAccountRoute(report)} ref={(e) => (textInput.current = e)} onCurrencyButtonPress={navigateToCurrencySelectionPage} @@ -284,7 +283,7 @@ const IOURequestStepAmountWithOnyx = withOnyx<IOURequestStepAmountProps, IOURequ }, skipConfirmation: { key: ({route}) => { - const transactionID = lodashGet(route, 'params.transactionID', 0); + const transactionID = route.params.transactionID ?? 0; return `${ONYXKEYS.COLLECTION.SKIP_CONFIRMATION}${transactionID}`; }, }, diff --git a/src/pages/iou/request/step/IOURequestStepDistance.tsx b/src/pages/iou/request/step/IOURequestStepDistance.tsx index 875b749cbe0d..9ef432677b6f 100644 --- a/src/pages/iou/request/step/IOURequestStepDistance.tsx +++ b/src/pages/iou/request/step/IOURequestStepDistance.tsx @@ -1,5 +1,4 @@ import {isEmpty, isEqual} from 'lodash'; -import lodashGet from 'lodash/get'; import React, {useCallback, useEffect, useMemo, useRef, useState} from 'react'; import {View} from 'react-native'; // eslint-disable-next-line no-restricted-imports @@ -12,7 +11,8 @@ import DistanceRequestFooter from '@components/DistanceRequest/DistanceRequestFo import DistanceRequestRenderItem from '@components/DistanceRequest/DistanceRequestRenderItem'; import DotIndicatorMessage from '@components/DotIndicatorMessage'; import DraggableList from '@components/DraggableList'; -import withCurrentUserPersonalDetails, {WithCurrentUserPersonalDetailsProps} from '@components/withCurrentUserPersonalDetails'; +import withCurrentUserPersonalDetails from '@components/withCurrentUserPersonalDetails'; +import type {WithCurrentUserPersonalDetailsProps} from '@components/withCurrentUserPersonalDetails'; import useLocalize from '@hooks/useLocalize'; import useNetwork from '@hooks/useNetwork'; import usePrevious from '@hooks/usePrevious'; @@ -194,7 +194,7 @@ function IOURequestStepDistance({ if (report?.reportID && !ReportUtils.isArchivedRoom(report)) { const selectedParticipants = IOU.setMoneyRequestParticipantsFromReport(transactionID, report); const participants = selectedParticipants.map((participant) => { - const participantAccountID = lodashGet(participant, 'accountID', 0); + const participantAccountID = participant?.accountID ?? 0; return participantAccountID ? OptionsListUtils.getParticipantsOption(participant, personalDetails) : OptionsListUtils.getReportOption(participant); }); if (shouldSkipConfirmation) { @@ -409,7 +409,7 @@ const IOURequestStepDistanceWithOnyx = withOnyx<IOURequestStepDistanceProps, IOU }, skipConfirmation: { key: ({route}) => { - const transactionID = lodashGet(route, 'params.transactionID', 0); + const transactionID = route.params.transactionID ?? 0; return `${ONYXKEYS.COLLECTION.SKIP_CONFIRMATION}${transactionID}`; }, }, From 6a3fd51d172d54de724f14b041a34531d4c75662 Mon Sep 17 00:00:00 2001 From: Kevin Brian Bader <kevin.bader96@gmail.com> Date: Mon, 15 Apr 2024 18:41:58 +0300 Subject: [PATCH 114/206] resolved comments --- src/libs/WorkspacesSettingsUtils.ts | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/src/libs/WorkspacesSettingsUtils.ts b/src/libs/WorkspacesSettingsUtils.ts index 17a7d65bd19c..c01a2150e34b 100644 --- a/src/libs/WorkspacesSettingsUtils.ts +++ b/src/libs/WorkspacesSettingsUtils.ts @@ -68,7 +68,8 @@ Onyx.connect({ /** * @param report - * @returns BrickRoad for the policy passed as a param + * @param actionsByReport (optional) - similar to (local) reportActionsByReport, coming from (local) function getWorkspacesBrickRoads + * @returns BrickRoad for the policy passed as a param and optionally actionsByReport (if passed) */ const getBrickRoadForPolicy = (report: Report, actionsByReport?: OnyxCollection<ReportActions>): BrickRoad => { const reportActions = (isEmptyObject(actionsByReport) ? reportActionsByReport : actionsByReport)?.[report.reportID] ?? {}; @@ -156,6 +157,9 @@ function checkIfWorkspaceSettingsTabHasRBR(policyID?: string) { } /** + * @param reports + * @param policies + * @param reportActions (optional) * @returns a map where the keys are policyIDs and the values are BrickRoads for each policy */ function getWorkspacesBrickRoads(reports: OnyxCollection<Report>, policies: OnyxCollection<Policy>, reportActions?: OnyxCollection<ReportActions>): Record<string, BrickRoad> { @@ -178,12 +182,8 @@ function getWorkspacesBrickRoads(reports: OnyxCollection<Report>, policies: Onyx const actionsByReport: OnyxCollection<ReportActions> = {}; Object.keys(reportActions ?? {}).forEach((key) => { - if (!reportActions) { - return; - } - const reportID = CollectionUtils.extractCollectionItemID(key as typeof ONYXKEYS.COLLECTION.REPORT_ACTIONS); - actionsByReport[reportID] = reportActions[key]; + actionsByReport[reportID] = reportActions?.[key] ?? {}; }); Object.values(reports).forEach((report) => { @@ -204,6 +204,7 @@ function getWorkspacesBrickRoads(reports: OnyxCollection<Report>, policies: Onyx } /** + * @param reports * @returns a map where the keys are policyIDs and the values are truthy booleans if policy has unread content */ function getWorkspacesUnreadStatuses(reports: OnyxCollection<Report>): Record<string, boolean> { From 4b29f3774fde8d92c8c3c616c30318a9fb98035b Mon Sep 17 00:00:00 2001 From: Alberto <alberto@expensify.com> Date: Mon, 15 Apr 2024 17:45:57 +0200 Subject: [PATCH 115/206] hopefully final cleanup --- src/pages/iou/request/step/IOURequestStepAmount.tsx | 7 +++---- src/pages/iou/request/step/IOURequestStepScan/types.ts | 2 +- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/src/pages/iou/request/step/IOURequestStepAmount.tsx b/src/pages/iou/request/step/IOURequestStepAmount.tsx index 331a3265be8a..6bdc8c307d51 100644 --- a/src/pages/iou/request/step/IOURequestStepAmount.tsx +++ b/src/pages/iou/request/step/IOURequestStepAmount.tsx @@ -19,7 +19,6 @@ import CONST from '@src/CONST'; import ONYXKEYS from '@src/ONYXKEYS'; import ROUTES from '@src/ROUTES'; import type SCREENS from '@src/SCREENS'; -import type {Transaction} from '@src/types/onyx'; import type * as OnyxTypes from '@src/types/onyx'; import type {PaymentMethodType} from '@src/types/onyx/OriginalMessage'; import {isEmptyObject} from '@src/types/utils/EmptyObject'; @@ -35,13 +34,13 @@ type AmountParams = { type IOURequestStepAmountOnyxProps = { /** The draft transaction that holds data to be persisted on the current transaction */ - splitDraftTransaction: OnyxEntry<Transaction>; + splitDraftTransaction: OnyxEntry<OnyxTypes.Transaction>; /** Whether the confirmation step should be skipped */ skipConfirmation: OnyxEntry<boolean>; /** The draft transaction object being modified in Onyx */ - draftTransaction: OnyxEntry<Transaction>; + draftTransaction: OnyxEntry<OnyxTypes.Transaction>; /** Personal details of all users */ personalDetails: OnyxEntry<OnyxTypes.PersonalDetailsList>; @@ -54,7 +53,7 @@ type IOURequestStepAmountProps = IOURequestStepAmountOnyxProps & WithCurrentUserPersonalDetailsProps & WithWritableReportOrNotFoundProps<typeof SCREENS.MONEY_REQUEST.STEP_AMOUNT | typeof SCREENS.MONEY_REQUEST.CREATE> & { /** The transaction object being modified in Onyx */ - transaction: OnyxEntry<Transaction>; + transaction: OnyxEntry<OnyxTypes.Transaction>; }; function IOURequestStepAmount({ diff --git a/src/pages/iou/request/step/IOURequestStepScan/types.ts b/src/pages/iou/request/step/IOURequestStepScan/types.ts index 7a8d99ac6e23..0b130a795073 100644 --- a/src/pages/iou/request/step/IOURequestStepScan/types.ts +++ b/src/pages/iou/request/step/IOURequestStepScan/types.ts @@ -1,5 +1,5 @@ import type {OnyxEntry} from 'react-native-onyx'; -import {WithCurrentUserPersonalDetailsProps} from '@components/withCurrentUserPersonalDetails'; +import type {WithCurrentUserPersonalDetailsProps} from '@components/withCurrentUserPersonalDetails'; import type {WithWritableReportOrNotFoundProps} from '@pages/iou/request/step/withWritableReportOrNotFound'; import type SCREENS from '@src/SCREENS'; import type * as OnyxTypes from '@src/types/onyx'; From 35c378129767a2130625c661127c1b8a67bafbd2 Mon Sep 17 00:00:00 2001 From: brunovjk <brunovjk@gmail.com> Date: Mon, 15 Apr 2024 14:36:49 -0300 Subject: [PATCH 116/206] fix lint --- src/components/MoneyRequestConfirmationList.tsx | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/src/components/MoneyRequestConfirmationList.tsx b/src/components/MoneyRequestConfirmationList.tsx index 99f20acde27d..72c0bb662172 100755 --- a/src/components/MoneyRequestConfirmationList.tsx +++ b/src/components/MoneyRequestConfirmationList.tsx @@ -1,7 +1,7 @@ import {useIsFocused} from '@react-navigation/native'; import {format} from 'date-fns'; import Str from 'expensify-common/lib/str'; -import React, {useCallback, useEffect, useMemo, useReducer, useRef, useState} from 'react'; +import React, {useCallback, useEffect, useMemo, useReducer, useState} from 'react'; import {View} from 'react-native'; import type {StyleProp, ViewStyle} from 'react-native'; import {withOnyx} from 'react-native-onyx'; @@ -51,8 +51,6 @@ import ShowMoreButton from './ShowMoreButton'; import Switch from './Switch'; import Text from './Text'; -type IouType = ValueOf<typeof CONST.IOU.TYPE>; - type MoneyRequestConfirmationListOnyxProps = { /** Collection of categories attached to a policy */ policyCategories: OnyxEntry<OnyxTypes.PolicyCategories>; @@ -75,7 +73,7 @@ type MoneyRequestConfirmationListProps = MoneyRequestConfirmationListOnyxProps & onConfirm?: (selectedParticipants: Array<Participant | ReportUtils.OptionData>) => void; /** Callback to parent modal to send money */ - onSendMoney?: (paymentMethod: IouType | PaymentMethodType | undefined) => void; + onSendMoney?: (paymentMethod: PaymentMethodType | undefined) => void; /** Callback to inform a participant is selected */ onSelectParticipant?: (option: Participant) => void; @@ -93,7 +91,7 @@ type MoneyRequestConfirmationListProps = MoneyRequestConfirmationListOnyxProps & iouCurrencyCode?: string; /** IOU type */ - iouType?: IouType; + iouType?: ValueOf<typeof CONST.IOU.TYPE>; /** IOU date */ iouCreated?: string; @@ -362,7 +360,7 @@ function MoneyRequestConfirmationList({ setDidConfirm(false); } - const splitOrRequestOptions: Array<DropdownOption<IouType>> = useMemo(() => { + const splitOrRequestOptions: Array<DropdownOption<string>> = useMemo(() => { let text; if (isTypeTrackExpense) { text = translate('iou.trackExpense'); @@ -392,7 +390,7 @@ function MoneyRequestConfirmationList({ const payeePersonalDetails = useMemo(() => payeePersonalDetailsProp ?? currentUserPersonalDetails, [payeePersonalDetailsProp, currentUserPersonalDetails]); const canModifyParticipants = !isReadOnly && canModifyParticipantsProp && hasMultipleParticipants; const shouldDisablePaidBySection = canModifyParticipants; - + const optionSelectorSections: OptionsListUtils.CategorySection[] = useMemo(() => { const sections = []; const unselectedParticipants = selectedParticipantsProp.filter((participant) => !participant.selected); @@ -534,7 +532,7 @@ function MoneyRequestConfirmationList({ * @param {String} paymentMethod */ const confirm = useCallback( - (paymentMethod: IouType | PaymentMethodType | undefined) => { + (paymentMethod: PaymentMethodType | undefined) => { if (selectedParticipants.length === 0) { return; } @@ -627,7 +625,7 @@ function MoneyRequestConfirmationList({ success pressOnEnter isDisabled={shouldDisableButton} - onPress={(_event, value) => confirm(value)} + onPress={(event, value) => confirm(value as PaymentMethodType)} options={splitOrRequestOptions} buttonSize={CONST.DROPDOWN_BUTTON_SIZE.LARGE} enterKeyEventListenerPriority={1} From 8c509e3a085aeab7b3399dd7717b518e4a6151c7 Mon Sep 17 00:00:00 2001 From: Bruno Rocha <95647348+brunovjk@users.noreply.github.com> Date: Mon, 15 Apr 2024 14:45:51 -0300 Subject: [PATCH 117/206] Update src/components/MoneyRequestConfirmationList.tsx Co-authored-by: Eric Han <117511920+eh2077@users.noreply.github.com> --- src/components/MoneyRequestConfirmationList.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/MoneyRequestConfirmationList.tsx b/src/components/MoneyRequestConfirmationList.tsx index 72c0bb662172..d8169fae1cb8 100755 --- a/src/components/MoneyRequestConfirmationList.tsx +++ b/src/components/MoneyRequestConfirmationList.tsx @@ -238,7 +238,7 @@ function MoneyRequestConfirmationList({ const [shouldExpandFields, toggleShouldExpandFields] = useReducer((state) => !state, false); // Do not hide fields in case of send money request - const shouldShowAllFields = isDistanceRequest || shouldExpandFields || !shouldShowSmartScanFields || isTypeSend || isEditingSplitBill; + const shouldShowAllFields = !!isDistanceRequest || shouldExpandFields || !shouldShowSmartScanFields || isTypeSend || !!isEditingSplitBill; const shouldShowDate = (shouldShowSmartScanFields || isDistanceRequest) && !isTypeSend; const shouldShowMerchant = shouldShowSmartScanFields && !isDistanceRequest && !isTypeSend; From 566b057101ebf50939a83de78e982f1e2b641b99 Mon Sep 17 00:00:00 2001 From: Alberto <alberto@expensify.com> Date: Mon, 15 Apr 2024 19:54:32 +0200 Subject: [PATCH 118/206] fix skip distance --- src/pages/iou/request/step/IOURequestStepDistance.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pages/iou/request/step/IOURequestStepDistance.tsx b/src/pages/iou/request/step/IOURequestStepDistance.tsx index 9ef432677b6f..3f93c2a88b77 100644 --- a/src/pages/iou/request/step/IOURequestStepDistance.tsx +++ b/src/pages/iou/request/step/IOURequestStepDistance.tsx @@ -109,7 +109,7 @@ function IOURequestStepDistance({ return false; } - return !ReportUtils.isArchivedRoom(report) && !ReportUtils.isPolicyExpenseChat(report) && !policy?.requiresCategory && !policy?.requiresTag; + return !ReportUtils.isArchivedRoom(report) && !(ReportUtils.isPolicyExpenseChat(report) && ((policy?.requiresCategory ?? false) || (policy?.requiresTag ?? false))); }, [report, skipConfirmation, policy]); let buttonText = !isCreatingNewRequest ? translate('common.save') : translate('common.next'); if (shouldSkipConfirmation) { From 4877ce3ebed678b519615e1c9e0d63edd6196d4f Mon Sep 17 00:00:00 2001 From: brunovjk <brunovjk@gmail.com> Date: Mon, 15 Apr 2024 15:12:34 -0300 Subject: [PATCH 119/206] return with comment --- src/components/MoneyRequestConfirmationList.tsx | 1 + 1 file changed, 1 insertion(+) diff --git a/src/components/MoneyRequestConfirmationList.tsx b/src/components/MoneyRequestConfirmationList.tsx index d8169fae1cb8..4e68122bc40b 100755 --- a/src/components/MoneyRequestConfirmationList.tsx +++ b/src/components/MoneyRequestConfirmationList.tsx @@ -240,6 +240,7 @@ function MoneyRequestConfirmationList({ // Do not hide fields in case of send money request const shouldShowAllFields = !!isDistanceRequest || shouldExpandFields || !shouldShowSmartScanFields || isTypeSend || !!isEditingSplitBill; + // In Send Money and Split Bill with Scan flow, we don't allow the Merchant or Date to be edited. For distance requests, don't show the merchant as there's already another "Distance" menu item const shouldShowDate = (shouldShowSmartScanFields || isDistanceRequest) && !isTypeSend; const shouldShowMerchant = shouldShowSmartScanFields && !isDistanceRequest && !isTypeSend; From 9f668186eaaf4cdde866ee363ed3e96b96cefc87 Mon Sep 17 00:00:00 2001 From: brunovjk <brunovjk@gmail.com> Date: Mon, 15 Apr 2024 15:28:09 -0300 Subject: [PATCH 120/206] Put 'transaction?.transactionID ?? ''' is a single variable --- .../MoneyRequestConfirmationList.tsx | 35 ++++++++++--------- 1 file changed, 18 insertions(+), 17 deletions(-) diff --git a/src/components/MoneyRequestConfirmationList.tsx b/src/components/MoneyRequestConfirmationList.tsx index 4e68122bc40b..436b175d5750 100755 --- a/src/components/MoneyRequestConfirmationList.tsx +++ b/src/components/MoneyRequestConfirmationList.tsx @@ -230,6 +230,7 @@ function MoneyRequestConfirmationList({ const distance = transaction?.routes?.route0.distance ?? 0; const shouldCalculateDistanceAmount = isDistanceRequest && iouAmount === 0; const taxRates = policy?.taxRates; + const transactionID = transaction?.transactionID ?? ''; // A flag for showing the categories field const shouldShowCategories = isPolicyExpenseChat && (!!iouCategory || OptionsListUtils.hasEnabledOptions(Object.values(policyCategories ?? {}))); @@ -279,7 +280,7 @@ function MoneyRequestConfirmationList({ const [isAttachmentInvalid, setIsAttachmentInvalid] = useState(false); const navigateBack = () => { - Navigation.goBack(ROUTES.MONEY_REQUEST_CREATE_TAB_SCAN.getRoute(CONST.IOU.ACTION.CREATE, iouType, transaction?.transactionID ?? '', reportID)); + Navigation.goBack(ROUTES.MONEY_REQUEST_CREATE_TAB_SCAN.getRoute(CONST.IOU.ACTION.CREATE, iouType, transactionID, reportID)); }; const shouldDisplayFieldError: boolean = useMemo(() => { @@ -330,7 +331,7 @@ function MoneyRequestConfirmationList({ } const amount = DistanceRequestUtils.getDistanceRequestAmount(distance, unit, rate ?? 0); - IOU.setMoneyRequestAmount_temporaryForRefactor(transaction?.transactionID ?? '', amount, currency ?? ''); + IOU.setMoneyRequestAmount_temporaryForRefactor(transactionID, amount, currency ?? ''); }, [shouldCalculateDistanceAmount, distance, rate, unit, transaction, currency]); // Calculate and set tax amount in transaction draft @@ -342,7 +343,7 @@ function MoneyRequestConfirmationList({ return IOU.setMoneyRequestTaxAmount(transaction?.transactionID, transaction?.taxAmount, true); } - IOU.setMoneyRequestTaxAmount(transaction?.transactionID ?? '', amountInSmallestCurrencyUnits, true); + IOU.setMoneyRequestTaxAmount(transactionID, amountInSmallestCurrencyUnits, true); }, [taxRates?.defaultValue, transaction, previousTransactionAmount]); /** @@ -467,10 +468,10 @@ function MoneyRequestConfirmationList({ When the user completes the initial steps of the IOU flow offline and then goes online on the confirmation page. In this scenario, the route will be fetched from the server, and the waypoints will no longer be pending. */ - IOU.setMoneyRequestPendingFields(transaction?.transactionID ?? '', {waypoints: isDistanceRequestWithPendingRoute ? CONST.RED_BRICK_ROAD_PENDING_ACTION.ADD : null}); + IOU.setMoneyRequestPendingFields(transactionID, {waypoints: isDistanceRequestWithPendingRoute ? CONST.RED_BRICK_ROAD_PENDING_ACTION.ADD : null}); const distanceMerchant = DistanceRequestUtils.getDistanceMerchant(hasRoute, distance, unit, rate ?? 0, currency ?? CONST.CURRENCY.USD, translate, toLocaleDigit); - IOU.setMoneyRequestMerchant(transaction?.transactionID ?? '', distanceMerchant, true); + IOU.setMoneyRequestMerchant(transactionID, distanceMerchant, true); }, [isDistanceRequestWithPendingRoute, hasRoute, distance, unit, rate, currency, translate, toLocaleDigit, isDistanceRequest, transaction]); // Auto select the category if there is only one enabled category and it is required @@ -479,7 +480,7 @@ function MoneyRequestConfirmationList({ if (iouCategory || !shouldShowCategories || enabledCategories.length !== 1 || !isCategoryRequired) { return; } - IOU.setMoneyRequestCategory(transaction?.transactionID ?? '', enabledCategories[0].name); + IOU.setMoneyRequestCategory(transactionID, enabledCategories[0].name); }, [iouCategory, shouldShowCategories, policyCategories, transaction, isCategoryRequired]); // Auto select the tag if there is only one enabled tag and it is required @@ -494,7 +495,7 @@ function MoneyRequestConfirmationList({ updatedTagsString = IOUUtils.insertTagIntoTransactionTagsString(updatedTagsString, enabledTags[0] ? enabledTags[0].name : '', index); }); if (updatedTagsString !== TransactionUtils.getTag(transaction) && updatedTagsString) { - IOU.setMoneyRequestTag(transaction?.transactionID ?? '', updatedTagsString); + IOU.setMoneyRequestTag(transactionID, updatedTagsString); } }, [policyTagLists, transaction, policyTags, canUseViolations]); @@ -668,7 +669,7 @@ function MoneyRequestConfirmationList({ return; } Navigation.navigate( - ROUTES.MONEY_REQUEST_STEP_AMOUNT.getRoute(CONST.IOU.ACTION.CREATE, iouType, transaction?.transactionID ?? '', reportID, Navigation.getActiveRouteWithoutParams()), + ROUTES.MONEY_REQUEST_STEP_AMOUNT.getRoute(CONST.IOU.ACTION.CREATE, iouType, transactionID, reportID, Navigation.getActiveRouteWithoutParams()), ); }} style={[styles.moneyRequestMenuItem, styles.mt2]} @@ -694,7 +695,7 @@ function MoneyRequestConfirmationList({ ROUTES.MONEY_REQUEST_STEP_DESCRIPTION.getRoute( CONST.IOU.ACTION.CREATE, iouType, - transaction?.transactionID ?? '', + transactionID, reportID, Navigation.getActiveRouteWithoutParams(), reportActionID, @@ -725,7 +726,7 @@ function MoneyRequestConfirmationList({ ROUTES.MONEY_REQUEST_STEP_DISTANCE.getRoute( CONST.IOU.ACTION.CREATE, iouType, - transaction?.transactionID ?? '', + transactionID, reportID, Navigation.getActiveRouteWithoutParams(), ), @@ -753,7 +754,7 @@ function MoneyRequestConfirmationList({ ROUTES.MONEY_REQUEST_STEP_MERCHANT.getRoute( CONST.IOU.ACTION.CREATE, iouType, - transaction?.transactionID ?? '', + transactionID, reportID, Navigation.getActiveRouteWithoutParams(), ), @@ -781,7 +782,7 @@ function MoneyRequestConfirmationList({ titleStyle={styles.flex1} onPress={() => { Navigation.navigate( - ROUTES.MONEY_REQUEST_STEP_DATE.getRoute(CONST.IOU.ACTION.CREATE, iouType, transaction?.transactionID ?? '', reportID, Navigation.getActiveRouteWithoutParams()), + ROUTES.MONEY_REQUEST_STEP_DATE.getRoute(CONST.IOU.ACTION.CREATE, iouType, transactionID, reportID, Navigation.getActiveRouteWithoutParams()), ); }} disabled={didConfirm} @@ -806,7 +807,7 @@ function MoneyRequestConfirmationList({ ROUTES.MONEY_REQUEST_STEP_CATEGORY.getRoute( CONST.IOU.ACTION.CREATE, iouType, - transaction?.transactionID ?? '', + transactionID, reportID, Navigation.getActiveRouteWithoutParams(), reportActionID, @@ -839,7 +840,7 @@ function MoneyRequestConfirmationList({ CONST.IOU.ACTION.CREATE, iouType, index, - transaction?.transactionID ?? '', + transactionID, reportID, Navigation.getActiveRouteWithoutParams(), reportActionID, @@ -870,7 +871,7 @@ function MoneyRequestConfirmationList({ ROUTES.MONEY_REQUEST_STEP_TAX_RATE.getRoute( CONST.IOU.ACTION.CREATE, iouType, - transaction?.transactionID ?? '', + transactionID, reportID, Navigation.getActiveRouteWithoutParams(), ), @@ -897,7 +898,7 @@ function MoneyRequestConfirmationList({ ROUTES.MONEY_REQUEST_STEP_TAX_AMOUNT.getRoute( CONST.IOU.ACTION.CREATE, iouType, - transaction?.transactionID ?? '', + transactionID, reportID, Navigation.getActiveRouteWithoutParams(), ), @@ -1005,7 +1006,7 @@ function MoneyRequestConfirmationList({ ROUTES.MONEY_REQUEST_STEP_SCAN.getRoute( CONST.IOU.ACTION.CREATE, iouType, - transaction?.transactionID ?? '', + transactionID, reportID, Navigation.getActiveRouteWithoutParams(), ), From 402fa4f1be15a43122d13f0778e71d8e6b1905a1 Mon Sep 17 00:00:00 2001 From: brunovjk <brunovjk@gmail.com> Date: Mon, 15 Apr 2024 15:37:49 -0300 Subject: [PATCH 121/206] fix lint --- src/components/MoneyRequestConfirmationList.tsx | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/components/MoneyRequestConfirmationList.tsx b/src/components/MoneyRequestConfirmationList.tsx index 436b175d5750..5e30581a23ec 100755 --- a/src/components/MoneyRequestConfirmationList.tsx +++ b/src/components/MoneyRequestConfirmationList.tsx @@ -332,7 +332,7 @@ function MoneyRequestConfirmationList({ const amount = DistanceRequestUtils.getDistanceRequestAmount(distance, unit, rate ?? 0); IOU.setMoneyRequestAmount_temporaryForRefactor(transactionID, amount, currency ?? ''); - }, [shouldCalculateDistanceAmount, distance, rate, unit, transaction, currency]); + }, [shouldCalculateDistanceAmount, distance, rate, unit, transactionID, currency]); // Calculate and set tax amount in transaction draft useEffect(() => { @@ -344,7 +344,7 @@ function MoneyRequestConfirmationList({ } IOU.setMoneyRequestTaxAmount(transactionID, amountInSmallestCurrencyUnits, true); - }, [taxRates?.defaultValue, transaction, previousTransactionAmount]); + }, [taxRates?.defaultValue, transaction, transactionID, previousTransactionAmount]); /** * Returns the participants with amount @@ -472,7 +472,7 @@ function MoneyRequestConfirmationList({ const distanceMerchant = DistanceRequestUtils.getDistanceMerchant(hasRoute, distance, unit, rate ?? 0, currency ?? CONST.CURRENCY.USD, translate, toLocaleDigit); IOU.setMoneyRequestMerchant(transactionID, distanceMerchant, true); - }, [isDistanceRequestWithPendingRoute, hasRoute, distance, unit, rate, currency, translate, toLocaleDigit, isDistanceRequest, transaction]); + }, [isDistanceRequestWithPendingRoute, hasRoute, distance, unit, rate, currency, translate, toLocaleDigit, isDistanceRequest, transactionID]); // Auto select the category if there is only one enabled category and it is required useEffect(() => { @@ -481,7 +481,7 @@ function MoneyRequestConfirmationList({ return; } IOU.setMoneyRequestCategory(transactionID, enabledCategories[0].name); - }, [iouCategory, shouldShowCategories, policyCategories, transaction, isCategoryRequired]); + }, [iouCategory, shouldShowCategories, policyCategories, transactionID, isCategoryRequired]); // Auto select the tag if there is only one enabled tag and it is required useEffect(() => { @@ -497,7 +497,7 @@ function MoneyRequestConfirmationList({ if (updatedTagsString !== TransactionUtils.getTag(transaction) && updatedTagsString) { IOU.setMoneyRequestTag(transactionID, updatedTagsString); } - }, [policyTagLists, transaction, policyTags, canUseViolations]); + }, [policyTagLists, transaction, transactionID, policyTags, canUseViolations]); /** */ From c11bc0a8e050e8e29ec4bc586fa4647c95a36bea Mon Sep 17 00:00:00 2001 From: brunovjk <brunovjk@gmail.com> Date: Mon, 15 Apr 2024 16:46:56 -0300 Subject: [PATCH 122/206] run prettier --- .../MoneyRequestConfirmationList.tsx | 63 +++---------------- 1 file changed, 8 insertions(+), 55 deletions(-) diff --git a/src/components/MoneyRequestConfirmationList.tsx b/src/components/MoneyRequestConfirmationList.tsx index 5e30581a23ec..eec2ee3388d3 100755 --- a/src/components/MoneyRequestConfirmationList.tsx +++ b/src/components/MoneyRequestConfirmationList.tsx @@ -668,9 +668,7 @@ function MoneyRequestConfirmationList({ Navigation.navigate(ROUTES.EDIT_SPLIT_BILL.getRoute(reportID, reportActionID ?? '', CONST.EDIT_REQUEST_FIELD.AMOUNT)); return; } - Navigation.navigate( - ROUTES.MONEY_REQUEST_STEP_AMOUNT.getRoute(CONST.IOU.ACTION.CREATE, iouType, transactionID, reportID, Navigation.getActiveRouteWithoutParams()), - ); + Navigation.navigate(ROUTES.MONEY_REQUEST_STEP_AMOUNT.getRoute(CONST.IOU.ACTION.CREATE, iouType, transactionID, reportID, Navigation.getActiveRouteWithoutParams())); }} style={[styles.moneyRequestMenuItem, styles.mt2]} titleStyle={styles.moneyRequestConfirmationAmount} @@ -722,15 +720,7 @@ function MoneyRequestConfirmationList({ style={[styles.moneyRequestMenuItem]} titleStyle={styles.flex1} onPress={() => - Navigation.navigate( - ROUTES.MONEY_REQUEST_STEP_DISTANCE.getRoute( - CONST.IOU.ACTION.CREATE, - iouType, - transactionID, - reportID, - Navigation.getActiveRouteWithoutParams(), - ), - ) + Navigation.navigate(ROUTES.MONEY_REQUEST_STEP_DISTANCE.getRoute(CONST.IOU.ACTION.CREATE, iouType, transactionID, reportID, Navigation.getActiveRouteWithoutParams())) } // eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing disabled={didConfirm} @@ -750,15 +740,7 @@ function MoneyRequestConfirmationList({ style={[styles.moneyRequestMenuItem]} titleStyle={styles.flex1} onPress={() => { - Navigation.navigate( - ROUTES.MONEY_REQUEST_STEP_MERCHANT.getRoute( - CONST.IOU.ACTION.CREATE, - iouType, - transactionID, - reportID, - Navigation.getActiveRouteWithoutParams(), - ), - ); + Navigation.navigate(ROUTES.MONEY_REQUEST_STEP_MERCHANT.getRoute(CONST.IOU.ACTION.CREATE, iouType, transactionID, reportID, Navigation.getActiveRouteWithoutParams())); }} disabled={didConfirm} interactive={!isReadOnly} @@ -781,9 +763,7 @@ function MoneyRequestConfirmationList({ style={[styles.moneyRequestMenuItem]} titleStyle={styles.flex1} onPress={() => { - Navigation.navigate( - ROUTES.MONEY_REQUEST_STEP_DATE.getRoute(CONST.IOU.ACTION.CREATE, iouType, transactionID, reportID, Navigation.getActiveRouteWithoutParams()), - ); + Navigation.navigate(ROUTES.MONEY_REQUEST_STEP_DATE.getRoute(CONST.IOU.ACTION.CREATE, iouType, transactionID, reportID, Navigation.getActiveRouteWithoutParams())); }} disabled={didConfirm} interactive={!isReadOnly} @@ -804,14 +784,7 @@ function MoneyRequestConfirmationList({ numberOfLinesTitle={2} onPress={() => Navigation.navigate( - ROUTES.MONEY_REQUEST_STEP_CATEGORY.getRoute( - CONST.IOU.ACTION.CREATE, - iouType, - transactionID, - reportID, - Navigation.getActiveRouteWithoutParams(), - reportActionID, - ), + ROUTES.MONEY_REQUEST_STEP_CATEGORY.getRoute(CONST.IOU.ACTION.CREATE, iouType, transactionID, reportID, Navigation.getActiveRouteWithoutParams(), reportActionID), ) } style={[styles.moneyRequestMenuItem]} @@ -867,15 +840,7 @@ function MoneyRequestConfirmationList({ style={[styles.moneyRequestMenuItem]} titleStyle={styles.flex1} onPress={() => - Navigation.navigate( - ROUTES.MONEY_REQUEST_STEP_TAX_RATE.getRoute( - CONST.IOU.ACTION.CREATE, - iouType, - transactionID, - reportID, - Navigation.getActiveRouteWithoutParams(), - ), - ) + Navigation.navigate(ROUTES.MONEY_REQUEST_STEP_TAX_RATE.getRoute(CONST.IOU.ACTION.CREATE, iouType, transactionID, reportID, Navigation.getActiveRouteWithoutParams())) } disabled={didConfirm} interactive={!isReadOnly} @@ -895,13 +860,7 @@ function MoneyRequestConfirmationList({ titleStyle={styles.flex1} onPress={() => Navigation.navigate( - ROUTES.MONEY_REQUEST_STEP_TAX_AMOUNT.getRoute( - CONST.IOU.ACTION.CREATE, - iouType, - transactionID, - reportID, - Navigation.getActiveRouteWithoutParams(), - ), + ROUTES.MONEY_REQUEST_STEP_TAX_AMOUNT.getRoute(CONST.IOU.ACTION.CREATE, iouType, transactionID, reportID, Navigation.getActiveRouteWithoutParams()), ) } disabled={didConfirm} @@ -1003,13 +962,7 @@ function MoneyRequestConfirmationList({ <ReceiptEmptyState onPress={() => Navigation.navigate( - ROUTES.MONEY_REQUEST_STEP_SCAN.getRoute( - CONST.IOU.ACTION.CREATE, - iouType, - transactionID, - reportID, - Navigation.getActiveRouteWithoutParams(), - ), + ROUTES.MONEY_REQUEST_STEP_SCAN.getRoute(CONST.IOU.ACTION.CREATE, iouType, transactionID, reportID, Navigation.getActiveRouteWithoutParams()), ) } /> From 6e0a24b0fb0f0633ae5ac725646e4c2c44089880 Mon Sep 17 00:00:00 2001 From: brunovjk <brunovjk@gmail.com> Date: Mon, 15 Apr 2024 19:56:26 -0300 Subject: [PATCH 123/206] use 'MoneyRequestConfirmationList' to Create/Edit a Send/Request/Split --- .../MoneyRequestConfirmationList.tsx | 20 +++++++++---------- src/libs/actions/IOU.ts | 7 +------ .../iou/request/step/IOURequestStepAmount.tsx | 2 +- 3 files changed, 11 insertions(+), 18 deletions(-) diff --git a/src/components/MoneyRequestConfirmationList.tsx b/src/components/MoneyRequestConfirmationList.tsx index eec2ee3388d3..7b6c86f91543 100755 --- a/src/components/MoneyRequestConfirmationList.tsx +++ b/src/components/MoneyRequestConfirmationList.tsx @@ -217,6 +217,8 @@ function MoneyRequestConfirmationList({ const currentUserPersonalDetails = useCurrentUserPersonalDetails(); const {canUseViolations} = usePermissions(); + const actionClassifiedFields: ValueOf<typeof CONST.IOU.ACTION> = isEditingSplitBill ? CONST.IOU.ACTION.EDIT : CONST.IOU.ACTION.CREATE; + const isTypeRequest = iouType === CONST.IOU.TYPE.REQUEST; const isTypeSplit = iouType === CONST.IOU.TYPE.SPLIT; const isTypeSend = iouType === CONST.IOU.TYPE.SEND; @@ -331,7 +333,7 @@ function MoneyRequestConfirmationList({ } const amount = DistanceRequestUtils.getDistanceRequestAmount(distance, unit, rate ?? 0); - IOU.setMoneyRequestAmount_temporaryForRefactor(transactionID, amount, currency ?? ''); + IOU.setMoneyRequestAmount(transactionID, amount, currency ?? ''); }, [shouldCalculateDistanceAmount, distance, rate, unit, transactionID, currency]); // Calculate and set tax amount in transaction draft @@ -664,11 +666,7 @@ function MoneyRequestConfirmationList({ if (isDistanceRequest) { return; } - if (isEditingSplitBill) { - Navigation.navigate(ROUTES.EDIT_SPLIT_BILL.getRoute(reportID, reportActionID ?? '', CONST.EDIT_REQUEST_FIELD.AMOUNT)); - return; - } - Navigation.navigate(ROUTES.MONEY_REQUEST_STEP_AMOUNT.getRoute(CONST.IOU.ACTION.CREATE, iouType, transactionID, reportID, Navigation.getActiveRouteWithoutParams())); + Navigation.navigate(ROUTES.MONEY_REQUEST_STEP_AMOUNT.getRoute(actionClassifiedFields, iouType, transactionID, reportID, Navigation.getActiveRouteWithoutParams())); }} style={[styles.moneyRequestMenuItem, styles.mt2]} titleStyle={styles.moneyRequestConfirmationAmount} @@ -691,7 +689,7 @@ function MoneyRequestConfirmationList({ onPress={() => { Navigation.navigate( ROUTES.MONEY_REQUEST_STEP_DESCRIPTION.getRoute( - CONST.IOU.ACTION.CREATE, + actionClassifiedFields, iouType, transactionID, reportID, @@ -720,7 +718,7 @@ function MoneyRequestConfirmationList({ style={[styles.moneyRequestMenuItem]} titleStyle={styles.flex1} onPress={() => - Navigation.navigate(ROUTES.MONEY_REQUEST_STEP_DISTANCE.getRoute(CONST.IOU.ACTION.CREATE, iouType, transactionID, reportID, Navigation.getActiveRouteWithoutParams())) + Navigation.navigate(ROUTES.MONEY_REQUEST_STEP_DISTANCE.getRoute(actionClassifiedFields, iouType, transactionID, reportID, Navigation.getActiveRouteWithoutParams())) } // eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing disabled={didConfirm} @@ -740,7 +738,7 @@ function MoneyRequestConfirmationList({ style={[styles.moneyRequestMenuItem]} titleStyle={styles.flex1} onPress={() => { - Navigation.navigate(ROUTES.MONEY_REQUEST_STEP_MERCHANT.getRoute(CONST.IOU.ACTION.CREATE, iouType, transactionID, reportID, Navigation.getActiveRouteWithoutParams())); + Navigation.navigate(ROUTES.MONEY_REQUEST_STEP_MERCHANT.getRoute(actionClassifiedFields, iouType, transactionID, reportID, Navigation.getActiveRouteWithoutParams())); }} disabled={didConfirm} interactive={!isReadOnly} @@ -763,7 +761,7 @@ function MoneyRequestConfirmationList({ style={[styles.moneyRequestMenuItem]} titleStyle={styles.flex1} onPress={() => { - Navigation.navigate(ROUTES.MONEY_REQUEST_STEP_DATE.getRoute(CONST.IOU.ACTION.CREATE, iouType, transactionID, reportID, Navigation.getActiveRouteWithoutParams())); + Navigation.navigate(ROUTES.MONEY_REQUEST_STEP_DATE.getRoute(actionClassifiedFields, iouType, transactionID, reportID, Navigation.getActiveRouteWithoutParams())); }} disabled={didConfirm} interactive={!isReadOnly} @@ -784,7 +782,7 @@ function MoneyRequestConfirmationList({ numberOfLinesTitle={2} onPress={() => Navigation.navigate( - ROUTES.MONEY_REQUEST_STEP_CATEGORY.getRoute(CONST.IOU.ACTION.CREATE, iouType, transactionID, reportID, Navigation.getActiveRouteWithoutParams(), reportActionID), + ROUTES.MONEY_REQUEST_STEP_CATEGORY.getRoute(actionClassifiedFields, iouType, transactionID, reportID, Navigation.getActiveRouteWithoutParams(), reportActionID), ) } style={[styles.moneyRequestMenuItem]} diff --git a/src/libs/actions/IOU.ts b/src/libs/actions/IOU.ts index cd0264ddb6ea..1249ea2c02c9 100644 --- a/src/libs/actions/IOU.ts +++ b/src/libs/actions/IOU.ts @@ -371,7 +371,7 @@ function startMoneyRequest(iouType: ValueOf<typeof CONST.IOU.TYPE>, reportID: st } // eslint-disable-next-line @typescript-eslint/naming-convention -function setMoneyRequestAmount_temporaryForRefactor(transactionID: string, amount: number, currency: string, removeOriginalCurrency = false) { +function setMoneyRequestAmount(transactionID: string, amount: number, currency: string, removeOriginalCurrency = false) { if (removeOriginalCurrency) { Onyx.merge(`${ONYXKEYS.COLLECTION.TRANSACTION_DRAFT}${transactionID}`, {amount, currency, originalCurrency: null}); return; @@ -5360,10 +5360,6 @@ function setMoneyRequestId(id: string) { Onyx.merge(ONYXKEYS.IOU, {id}); } -function setMoneyRequestAmount(amount: number) { - Onyx.merge(ONYXKEYS.IOU, {amount}); -} - function setMoneyRequestCurrency(currency: string) { Onyx.merge(ONYXKEYS.IOU, {currency}); } @@ -5562,7 +5558,6 @@ export { resetMoneyRequestInfo, clearMoneyRequest, updateMoneyRequestTypeParams, - setMoneyRequestAmount_temporaryForRefactor, setMoneyRequestBillable_temporaryForRefactor, setMoneyRequestCreated, setMoneyRequestCurrency_temporaryForRefactor, diff --git a/src/pages/iou/request/step/IOURequestStepAmount.tsx b/src/pages/iou/request/step/IOURequestStepAmount.tsx index 1936a132c665..e54dd8138ccd 100644 --- a/src/pages/iou/request/step/IOURequestStepAmount.tsx +++ b/src/pages/iou/request/step/IOURequestStepAmount.tsx @@ -115,7 +115,7 @@ function IOURequestStepAmount({ isSaveButtonPressed.current = true; const amountInSmallestCurrencyUnits = CurrencyUtils.convertToBackendAmount(Number.parseFloat(amount)); - IOU.setMoneyRequestAmount_temporaryForRefactor(transactionID, amountInSmallestCurrencyUnits, currency || CONST.CURRENCY.USD, true); + IOU.setMoneyRequestAmount(transactionID, amountInSmallestCurrencyUnits, currency || CONST.CURRENCY.USD, true); if (backTo) { Navigation.goBack(backTo); From 89fd65ff7d333fd2799057ee99342bcef0c64e93 Mon Sep 17 00:00:00 2001 From: Shahe Shahinyan <shahe.shahinyan@gmail.com> Date: Tue, 16 Apr 2024 12:24:30 +0400 Subject: [PATCH 124/206] Comments addressed --- src/CONST.ts | 78 ++++++++++++++++++++++++++-------------------------- 1 file changed, 39 insertions(+), 39 deletions(-) diff --git a/src/CONST.ts b/src/CONST.ts index 5688b6c68a64..122783df4944 100755 --- a/src/CONST.ts +++ b/src/CONST.ts @@ -633,57 +633,57 @@ const CONST = { LIMIT: 50, // OldDot Actions render getMessage from Web-Expensify/lib/Report/Action PHP files via getMessageOfOldDotReportAction in ReportActionsUtils.ts TYPE: { - ACTIONABLE_MENTION_WHISPER: 'ACTIONABLE_MENTION_WHISPER', - ADD_COMMENT: 'ADD_COMMENT', - ACTIONABLE_JOIN_REQUEST: 'ACTIONABLE_JOIN_REQUEST', + ACTIONABLE_MENTION_WHISPER: 'ACTIONABLEMENTIONWHISPER', + ADD_COMMENT: 'ADDCOMMENT', + ACTIONABLE_JOIN_REQUEST: 'ACTIONABLEJOINREQUEST', APPROVED: 'APPROVED', - CHANGE_FIELD: 'CHANGE_FIELD', // OldDot Action - CHANGE_POLICY: 'CHANGE_POLICY', // OldDot Action - CHANGE_TYPE: 'CHANGE_TYPE', // OldDot Action - CHRONOSOOLIST: 'CHRONOSOOLIST', + CHANGE_FIELD: 'CHANGEFIELD', // OldDot Action + CHANGE_POLICY: 'CHANGEPOLICY', // OldDot Action + CHANGE_TYPE: 'CHANGETYPE', // OldDot Action + CHRONOS_OO_LIST: 'CHRONOSOOLIST', CLOSED: 'CLOSED', CREATED: 'CREATED', - DELEGATE_SUBMIT: 'DELEGATE_SUBMIT', // OldDot Action - DELETED_ACCOUNT: 'DELETED_ACCOUNT', // OldDot Action + DELEGATE_SUBMIT: 'DELEGATESUBMIT', // OldDot Action + DELETED_ACCOUNT: 'DELETEDACCOUNT', // OldDot Action DONATION: 'DONATION', // OldDot Action - EXPORTED_TO_CSV: 'EXPORTED_TO_CSV', // OldDot Action - EXPORTED_TO_INTEGRATION: 'EXPORTED_TO_INTEGRATION', // OldDot Action - EXPORTED_TO_QUICK_BOOKS: 'EXPORTED_TO_QUICK_BOOKS', // OldDot Action + EXPORTED_TO_CSV: 'EXPORTEDTOCSV', // OldDot Action + EXPORTED_TO_INTEGRATION: 'EXPORTEDTOINTEGRATION', // OldDot Action + EXPORTED_TO_QUICK_BOOKS: 'EXPORTEDTOQUICKBOOKS', // OldDot Action FORWARDED: 'FORWARDED', // OldDot Action HOLD: 'HOLD', - HOLD_COMMENT: 'HOLD_COMMENT', + HOLD_COMMENT: 'HOLDCOMMENT', IOU: 'IOU', - INTEGRATIONS_MESSAGE: 'INTEGRATIONS_MESSAGE', // OldDot Action - MANAGER_ATTACH_RECEIPT: 'MANAGER_ATTACH_RECEIPT', // OldDot Action - MANAGER_DETACH_RECEIPT: 'MANAGER_DETACH_RECEIPT', // OldDot Action - MARKED_REIMBURSED: 'MARKED_REIMBURSED', // OldDot Action - MARK_REIMBURSED_FROM_INTEGRATION: 'MARK_REIMBURSED_FROM_INTEGRATION', // OldDot Action + INTEGRATIONS_MESSAGE: 'INTEGRATIONSMESSAGE', // OldDot Action + MANAGER_ATTACH_RECEIPT: 'MANAGERATTACHRECEIPT', // OldDot Action + MANAGER_DETACH_RECEIPT: 'MANAGERDETACHRECEIPT', // OldDot Action + MARKED_REIMBURSED: 'MARKEDREIMBURSED', // OldDot Action + MARK_REIMBURSED_FROM_INTEGRATION: 'MARKREIMBURSEDFROMINTEGRATION', // OldDot Action MODIFIED_EXPENSE: 'MODIFIED_EXPENSE', MOVED: 'MOVED', - OUTDATED_BANK_ACCOUNT: 'OUTDATED_BANK_ACCOUNT', // OldDot Action - REIMBURSEMENTACH_BOUNCE: 'REIMBURSEMENTACH_BOUNCE', // OldDot Action - REIMBURSEMENTACH_CANCELLED: 'REIMBURSEMENTACH_CANCELLED', // OldDot Action - REIMBURSEMENT_ACCOUNT_CHANGED: 'REIMBURSEMENT_ACCOUNT_CHANGED', // OldDot Action - REIMBURSEMENT_DELAYED: 'REIMBURSEMENT_DELAYED', // OldDot Action - REIMBURSEMENT_QUEUED: 'REIMBURSEMENT_QUEUED', - REIMBURSEMENT_DEQUEUED: 'REIMBURSEMENT_DEQUEUED', - REIMBURSEMENT_REQUESTED: 'REIMBURSEMENT_REQUESTED', // OldDot Action - REIMBURSEMENT_SETUP: 'REIMBURSEMENT_SETUP', // OldDot Action + OUTDATED_BANK_ACCOUNT: 'OUTDATEDBANKACCOUNT', // OldDot Action + REIMBURSEMENT_ACH_BOUNCE: 'REIMBURSEMENTACHBOUNCE', // OldDot Action + REIMBURSEMENT_ACH_CANCELLED: 'REIMBURSEMENTACHCANCELLED', // OldDot Action + REIMBURSEMENT_ACCOUNT_CHANGED: 'REIMBURSEMENTACCOUNTCHANGED', // OldDot Action + REIMBURSEMENT_DELAYED: 'REIMBURSEMENTDELAYED', // OldDot Action + REIMBURSEMENT_QUEUED: 'REIMBURSEMENTQUEUED', + REIMBURSEMENT_DEQUEUED: 'REIMBURSEMENTDEQUEUED', + REIMBURSEMENT_REQUESTED: 'REIMBURSEMENTREQUESTED', // OldDot Action + REIMBURSEMENT_SETUP: 'REIMBURSEMENTSETUP', // OldDot Action RENAMED: 'RENAMED', - REPORT_PREVIEW: 'REPORT_PREVIEW', - SELECTED_FOR_RANDOM_AUDIT: 'SELECTED_FOR_RANDOM_AUDIT', // OldDot Action + REPORT_PREVIEW: 'REPORTPREVIEW', + SELECTED_FOR_RANDOM_AUDIT: 'SELECTEDFORRANDOMAUDIT', // OldDot Action SHARE: 'SHARE', // OldDot Action - STRIPE_PAID: 'STRIPE_PAID', // OldDot Action + STRIPE_PAID: 'STRIPEPAID', // OldDot Action SUBMITTED: 'SUBMITTED', TAKE_CONTROL: 'TAKE_CONTROL', // OldDot Action - TASK_CANCELLED: 'TASK_CANCELLED', - TASK_COMPLETED: 'TASK_COMPLETED', - TASK_EDITED: 'TASK_EDITED', - TASK_REOPENED: 'TASK_REOPENED', + TASK_CANCELLED: 'TASKCANCELLED', + TASK_COMPLETED: 'TASKCOMPLETED', + TASK_EDITED: 'TASKEDITED', + TASK_REOPENED: 'TASKREOPENED', UNAPPROVED: 'UNAPPROVED', // OldDot Action UNHOLD: 'UNHOLD', UNSHARE: 'UNSHARE', // OldDot Action - UPDATE_GROUP_CHAT_MEMBER_ROLE: 'UPDATE_GROUP_CHAT_MEMBER_ROLE', + UPDATE_GROUP_CHAT_MEMBER_ROLE: 'UPDATEGROUPCHATMEMBERROLE', POLICY_CHANGE_LOG: { ADD_APPROVER_RULE: 'POLICYCHANGELOG_ADD_APPROVER_RULE', ADD_BUDGET: 'POLICYCHANGELOG_ADD_BUDGET', @@ -712,16 +712,16 @@ const CONST = { REMOVE_FROM_ROOM: 'POLICYCHANGELOG_REMOVEFROMROOM', LEAVE_ROOM: 'POLICYCHANGELOG_LEAVEROOM', REPLACE_CATEGORIES: 'POLICYCHANGELOG_REPLACE_CATEGORIES', - SET_AUTOREIMBURSEMENT: 'POLICYCHANGELOG_SET_AUTOREIMBURSEMENT', + SET_AUTO_REIMBURSEMENT: 'POLICYCHANGELOG_SET_AUTOREIMBURSEMENT', SET_AUTO_JOIN: 'POLICYCHANGELOG_SET_AUTO_JOIN', SET_CATEGORY_NAME: 'POLICYCHANGELOG_SET_CATEGORY_NAME', SHARED_BUDGET_NOTIFICATION: 'POLICYCHANGELOG_SHARED_BUDGET_NOTIFICATION', UPDATE_ACH_ACCOUNT: 'POLICYCHANGELOG_UPDATE_ACH_ACCOUNT', UPDATE_APPROVER_RULE: 'POLICYCHANGELOG_UPDATE_APPROVER_RULE', UPDATE_AUDIT_RATE: 'POLICYCHANGELOG_UPDATE_AUDIT_RATE', - UPDATE_AUTOHARVESTING: 'POLICYCHANGELOG_UPDATE_AUTOHARVESTING', - UPDATE_AUTOREIMBURSEMENT: 'POLICYCHANGELOG_UPDATE_AUTOREIMBURSEMENT', - UPDATE_AUTOREPORTING_FREQUENCY: 'POLICYCHANGELOG_UPDATE_AUTOREPORTING_FREQUENCY', + UPDATE_AUTO_HARVESTING: 'POLICYCHANGELOG_UPDATE_AUTOHARVESTING', + UPDATE_AUTO_REIMBURSEMENT: 'POLICYCHANGELOG_UPDATE_AUTOREIMBURSEMENT', + UPDATE_AUTO_REPORTING_FREQUENCY: 'POLICYCHANGELOG_UPDATE_AUTOREPORTING_FREQUENCY', UPDATE_BUDGET: 'POLICYCHANGELOG_UPDATE_BUDGET', UPDATE_CATEGORY: 'POLICYCHANGELOG_UPDATE_CATEGORY', UPDATE_CURRENCY: 'POLICYCHANGELOG_UPDATE_CURRENCY', From a35401f46c1652fcb1c365a1fca029ddff9d7fb7 Mon Sep 17 00:00:00 2001 From: Shahe Shahinyan <shahe.shahinyan@gmail.com> Date: Tue, 16 Apr 2024 12:28:26 +0400 Subject: [PATCH 125/206] Correction of omissions --- src/CONST.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/CONST.ts b/src/CONST.ts index 122783df4944..88f6bc86d4a3 100755 --- a/src/CONST.ts +++ b/src/CONST.ts @@ -640,7 +640,7 @@ const CONST = { CHANGE_FIELD: 'CHANGEFIELD', // OldDot Action CHANGE_POLICY: 'CHANGEPOLICY', // OldDot Action CHANGE_TYPE: 'CHANGETYPE', // OldDot Action - CHRONOS_OO_LIST: 'CHRONOSOOLIST', + CHRONOSOOLIST: 'CHRONOSOOLIST', CLOSED: 'CLOSED', CREATED: 'CREATED', DELEGATE_SUBMIT: 'DELEGATESUBMIT', // OldDot Action @@ -658,7 +658,7 @@ const CONST = { MANAGER_DETACH_RECEIPT: 'MANAGERDETACHRECEIPT', // OldDot Action MARKED_REIMBURSED: 'MARKEDREIMBURSED', // OldDot Action MARK_REIMBURSED_FROM_INTEGRATION: 'MARKREIMBURSEDFROMINTEGRATION', // OldDot Action - MODIFIED_EXPENSE: 'MODIFIED_EXPENSE', + MODIFIED_EXPENSE: 'MODIFIEDEXPENSE', MOVED: 'MOVED', OUTDATED_BANK_ACCOUNT: 'OUTDATEDBANKACCOUNT', // OldDot Action REIMBURSEMENT_ACH_BOUNCE: 'REIMBURSEMENTACHBOUNCE', // OldDot Action @@ -675,7 +675,7 @@ const CONST = { SHARE: 'SHARE', // OldDot Action STRIPE_PAID: 'STRIPEPAID', // OldDot Action SUBMITTED: 'SUBMITTED', - TAKE_CONTROL: 'TAKE_CONTROL', // OldDot Action + TAKE_CONTROL: 'TAKECONTROL', // OldDot Action TASK_CANCELLED: 'TASKCANCELLED', TASK_COMPLETED: 'TASKCOMPLETED', TASK_EDITED: 'TASKEDITED', From f9df247b80963ebabdacac60ce4d0af759ce4da5 Mon Sep 17 00:00:00 2001 From: nkdengineer <nkdengineer@outlook.com> Date: Tue, 16 Apr 2024 15:46:26 +0700 Subject: [PATCH 126/206] fix: Transaction thread opens in skeleton after replying to system message thread --- src/pages/home/report/ContextMenu/ContextMenuActions.tsx | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/pages/home/report/ContextMenu/ContextMenuActions.tsx b/src/pages/home/report/ContextMenu/ContextMenuActions.tsx index b5cb9d911ef5..fb988cc2bb96 100644 --- a/src/pages/home/report/ContextMenu/ContextMenuActions.tsx +++ b/src/pages/home/report/ContextMenu/ContextMenuActions.tsx @@ -200,6 +200,7 @@ const ContextMenuActions: ContextMenuAction[] = [ return !ReportUtils.shouldDisableThread(reportAction, reportID); }, onPress: (closePopover, {reportAction, reportID}) => { + const originalReportID = ReportUtils.getOriginalReportID(reportID, reportAction); if (closePopover) { hideContextMenu(false, () => { InteractionManager.runAfterInteractions(() => { @@ -207,12 +208,11 @@ const ContextMenuActions: ContextMenuAction[] = [ // is false, so we need to pass true here to override this condition. ReportActionComposeFocusManager.focus(true); }); - Report.navigateToAndOpenChildReport(reportAction?.childReportID ?? '0', reportAction, reportID); + Report.navigateToAndOpenChildReport(reportAction?.childReportID ?? '0', reportAction, originalReportID); }); return; } - - Report.navigateToAndOpenChildReport(reportAction?.childReportID ?? '0', reportAction, reportID); + Report.navigateToAndOpenChildReport(reportAction?.childReportID ?? '0', reportAction, originalReportID); }, getDescription: () => {}, }, From 707fd2c8d54e080e9fed50500622ade7549807ef Mon Sep 17 00:00:00 2001 From: Shahe Shahinyan <shahe.shahinyan@gmail.com> Date: Tue, 16 Apr 2024 12:47:47 +0400 Subject: [PATCH 127/206] Correction of omissions --- src/CONST.ts | 2 +- src/libs/ReportUtils.ts | 2 +- src/pages/home/report/ReportActionItem.tsx | 2 +- src/types/onyx/OriginalMessage.ts | 4 ++-- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/CONST.ts b/src/CONST.ts index 5d937f295a8d..4713cee889ed 100755 --- a/src/CONST.ts +++ b/src/CONST.ts @@ -640,7 +640,7 @@ const CONST = { CHANGE_FIELD: 'CHANGEFIELD', // OldDot Action CHANGE_POLICY: 'CHANGEPOLICY', // OldDot Action CHANGE_TYPE: 'CHANGETYPE', // OldDot Action - CHRONOSOOLIST: 'CHRONOSOOLIST', + CHRONOS_OO_LIST: 'CHRONOSOOLIST', CLOSED: 'CLOSED', CREATED: 'CREATED', DELEGATE_SUBMIT: 'DELEGATESUBMIT', // OldDot Action diff --git a/src/libs/ReportUtils.ts b/src/libs/ReportUtils.ts index ac2a53290ad6..e8d860209ada 100644 --- a/src/libs/ReportUtils.ts +++ b/src/libs/ReportUtils.ts @@ -4736,7 +4736,7 @@ function canFlagReportAction(reportAction: OnyxEntry<ReportAction>, reportID: st const isOriginalMessageHaveHtml = reportAction?.actionName === CONST.REPORT.ACTIONS.TYPE.ADD_COMMENT || reportAction?.actionName === CONST.REPORT.ACTIONS.TYPE.RENAMED || - reportAction?.actionName === CONST.REPORT.ACTIONS.TYPE.CHRONOSOOLIST; + reportAction?.actionName === CONST.REPORT.ACTIONS.TYPE.CHRONOS_OO_LIST; if (ReportActionsUtils.isWhisperAction(reportAction)) { // Allow flagging welcome message whispers as they can be set by any room creator if (report?.description && !isCurrentUserAction && isOriginalMessageHaveHtml && reportAction?.originalMessage?.html === report.description) { diff --git a/src/pages/home/report/ReportActionItem.tsx b/src/pages/home/report/ReportActionItem.tsx index 53183f172659..8fd0b885791c 100644 --- a/src/pages/home/report/ReportActionItem.tsx +++ b/src/pages/home/report/ReportActionItem.tsx @@ -793,7 +793,7 @@ function ReportActionItem({ if (action.actionName === CONST.REPORT.ACTIONS.TYPE.RENAMED) { return <RenameAction action={action} />; } - if (action.actionName === CONST.REPORT.ACTIONS.TYPE.CHRONOSOOLIST) { + if (action.actionName === CONST.REPORT.ACTIONS.TYPE.CHRONOS_OO_LIST) { return ( <ChronosOOOListActions action={action} diff --git a/src/types/onyx/OriginalMessage.ts b/src/types/onyx/OriginalMessage.ts index f935ca5b4607..721e4ffae0ae 100644 --- a/src/types/onyx/OriginalMessage.ts +++ b/src/types/onyx/OriginalMessage.ts @@ -8,7 +8,7 @@ type ActionName = DeepValueOf<typeof CONST.REPORT.ACTIONS.TYPE>; type OriginalMessageActionName = | 'ADD_COMMENT' | 'APPROVED' - | 'CHRONOSOOLIST' + | 'CHRONOS_OO_LIST' | 'CLOSED' | 'CREATED' | 'HOLD' @@ -203,7 +203,7 @@ type ChronosOOOEvent = { }; type OriginalMessageChronosOOOList = { - actionName: typeof CONST.REPORT.ACTIONS.TYPE.CHRONOSOOLIST; + actionName: typeof CONST.REPORT.ACTIONS.TYPE.CHRONOS_OO_LIST; originalMessage: { edits: string[]; events: ChronosOOOEvent[]; From 0d320e7bbe9fc89ef0bfe21b95fb958922ef1795 Mon Sep 17 00:00:00 2001 From: Shahe Shahinyan <shahe.shahinyan@gmail.com> Date: Tue, 16 Apr 2024 13:00:05 +0400 Subject: [PATCH 128/206] Fix Ts errors --- src/libs/actions/User.ts | 2 +- src/types/onyx/OriginalMessage.ts | 22 +++++++++++----------- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/src/libs/actions/User.ts b/src/libs/actions/User.ts index c8347a0140ed..dcd6e025e23b 100644 --- a/src/libs/actions/User.ts +++ b/src/libs/actions/User.ts @@ -517,7 +517,7 @@ function playSoundForMessageType(pushJSON: OnyxServerUpdate[]) { for (const data of flatten) { // Someone completes a task - if (data.actionName === 'TASK_COMPLETED') { + if (data.actionName === 'TASKCOMPLETED') { return playSound(SOUNDS.SUCCESS); } } diff --git a/src/types/onyx/OriginalMessage.ts b/src/types/onyx/OriginalMessage.ts index 721e4ffae0ae..a7d7c06f1bdb 100644 --- a/src/types/onyx/OriginalMessage.ts +++ b/src/types/onyx/OriginalMessage.ts @@ -6,25 +6,25 @@ type PaymentMethodType = DeepValueOf<typeof CONST.IOU.PAYMENT_TYPE | typeof CONS type ActionName = DeepValueOf<typeof CONST.REPORT.ACTIONS.TYPE>; type OriginalMessageActionName = - | 'ADD_COMMENT' + | 'ADDCOMMENT' | 'APPROVED' - | 'CHRONOS_OO_LIST' + | 'CHRONOSOOLIST' | 'CLOSED' | 'CREATED' | 'HOLD' | 'UNHOLD' | 'IOU' - | 'MODIFIED_EXPENSE' - | 'REIMBURSEMENT_QUEUED' + | 'MODIFIEDEXPENSE' + | 'REIMBURSEMENTQUEUED' | 'RENAMED' - | 'REPORT_PREVIEW' + | 'REPORTPREVIEW' | 'SUBMITTED' - | 'TASK_CANCELLED' - | 'TASK_COMPLETED' - | 'TASK_EDITED' - | 'TASK_REOPENED' - | 'ACTIONABLE_JOIN_REQUEST' - | 'ACTIONABLE_MENTION_WHISPER' + | 'TASKCANCELLED' + | 'TASKCOMPLETED' + | 'TASKEDITED' + | 'TASKREOPENED' + | 'ACTIONABLEJOINREQUEST' + | 'ACTIONABLEMENTIONWHISPER' | ValueOf<typeof CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG>; type OriginalMessageApproved = { actionName: typeof CONST.REPORT.ACTIONS.TYPE.APPROVED; From 22d942c8b12b3ed79eda1cf333b5a01648311586 Mon Sep 17 00:00:00 2001 From: Shahe Shahinyan <shahe.shahinyan@gmail.com> Date: Tue, 16 Apr 2024 13:11:24 +0400 Subject: [PATCH 129/206] Fix actoins in teats --- tests/actions/IOUTest.ts | 4 ++-- tests/unit/ReportActionsUtilsTest.ts | 4 ++-- tests/unit/ReportUtilsTest.ts | 8 ++++---- tests/utils/ReportTestUtils.ts | 4 ++-- 4 files changed, 10 insertions(+), 10 deletions(-) diff --git a/tests/actions/IOUTest.ts b/tests/actions/IOUTest.ts index 22fb1741bb41..0edd5aafbc57 100644 --- a/tests/actions/IOUTest.ts +++ b/tests/actions/IOUTest.ts @@ -1717,7 +1717,7 @@ describe('actions/IOU', () => { callback: (allActions) => { Onyx.disconnect(connectionID); const updatedAction = Object.values(allActions ?? {}).find((reportAction) => !isEmptyObject(reportAction)); - expect(updatedAction?.actionName).toEqual('MODIFIED_EXPENSE'); + expect(updatedAction?.actionName).toEqual('MODIFIEDEXPENSE'); expect(updatedAction?.originalMessage).toEqual( expect.objectContaining({amount: 20000, newComment: 'Double the amount!', oldAmount: amount, oldComment: comment}), ); @@ -1873,7 +1873,7 @@ describe('actions/IOU', () => { callback: (allActions) => { Onyx.disconnect(connectionID); const updatedAction = Object.values(allActions ?? {}).find((reportAction) => !isEmptyObject(reportAction)); - expect(updatedAction?.actionName).toEqual('MODIFIED_EXPENSE'); + expect(updatedAction?.actionName).toEqual('MODIFIEDEXPENSE'); expect(Object.values(updatedAction?.errors ?? {})).toEqual(expect.arrayContaining([['iou.error.genericEditFailureMessage', {isTranslated: false}]])); resolve(); }, diff --git a/tests/unit/ReportActionsUtilsTest.ts b/tests/unit/ReportActionsUtilsTest.ts index 3fd464f938f4..05fe50fe78b7 100644 --- a/tests/unit/ReportActionsUtilsTest.ts +++ b/tests/unit/ReportActionsUtilsTest.ts @@ -1932,7 +1932,7 @@ describe('ReportActionsUtils', () => { ...LHNTestUtils.getFakeReportAction('email1@test.com', 3), created: '2023-08-01 16:00:00', reportActionID: 'action1', - actionName: 'ADD_COMMENT', + actionName: 'ADDCOMMENT', originalMessage: { html: 'Hello world', whisperedTo: [], @@ -1942,7 +1942,7 @@ describe('ReportActionsUtils', () => { ...LHNTestUtils.getFakeReportAction('email2@test.com', 3), created: '2023-08-01 18:00:00', reportActionID: 'action2', - actionName: 'ADD_COMMENT', + actionName: 'ADDCOMMENT', originalMessage: { html: 'Hello world', whisperedTo: [], diff --git a/tests/unit/ReportUtilsTest.ts b/tests/unit/ReportUtilsTest.ts index 1a886591c2ef..2c20c6db0923 100644 --- a/tests/unit/ReportUtilsTest.ts +++ b/tests/unit/ReportUtilsTest.ts @@ -794,10 +794,10 @@ describe('ReportUtils', () => { ]; const reportActions: ReportAction[] = [ - {reportActionID: '1', created: '2024-02-01 04:42:22.965', actionName: 'MARKED_REIMBURSED'}, - {reportActionID: '2', created: '2024-02-01 04:42:28.003', actionName: 'MARKED_REIMBURSED'}, - {reportActionID: '3', created: '2024-02-01 04:42:31.742', actionName: 'MARKED_REIMBURSED'}, - {reportActionID: '4', created: '2024-02-01 04:42:35.619', actionName: 'MARKED_REIMBURSED'}, + {reportActionID: '1', created: '2024-02-01 04:42:22.965', actionName: 'MARKEDREIMBURSED'}, + {reportActionID: '2', created: '2024-02-01 04:42:28.003', actionName: 'MARKEDREIMBURSED'}, + {reportActionID: '3', created: '2024-02-01 04:42:31.742', actionName: 'MARKEDREIMBURSED'}, + {reportActionID: '4', created: '2024-02-01 04:42:35.619', actionName: 'MARKEDREIMBURSED'}, ]; beforeAll(() => { diff --git a/tests/utils/ReportTestUtils.ts b/tests/utils/ReportTestUtils.ts index 2a737bc16a91..3948baca3113 100644 --- a/tests/utils/ReportTestUtils.ts +++ b/tests/utils/ReportTestUtils.ts @@ -2,7 +2,7 @@ import type {ReportAction, ReportActions} from '@src/types/onyx'; import type {ActionName} from '@src/types/onyx/OriginalMessage'; import createRandomReportAction from './collections/reportActions'; -const actionNames: ActionName[] = ['ADD_COMMENT', 'IOU', 'REPORT_PREVIEW', 'CLOSED']; +const actionNames: ActionName[] = ['ADDCOMMENT', 'IOU', 'REPORTPREVIEW', 'CLOSED']; const getFakeReportAction = (index: number, actionName?: ActionName): ReportAction => ({ @@ -50,7 +50,7 @@ const getFakeReportAction = (index: number, actionName?: ActionName): ReportActi const getMockedSortedReportActions = (length = 100): ReportAction[] => Array.from({length}, (element, index): ReportAction => { - const actionName: ActionName = index === 0 ? 'CREATED' : 'ADD_COMMENT'; + const actionName: ActionName = index === 0 ? 'CREATED' : 'ADDCOMMENT'; return getFakeReportAction(index + 1, actionName); }).reverse(); From 8d6a4a9ad0cbe1cfd263af5cc76cfd94d85551ba Mon Sep 17 00:00:00 2001 From: nkdengineer <nkdengineer@outlook.com> Date: Tue, 16 Apr 2024 16:39:07 +0700 Subject: [PATCH 130/206] revert unnecessary change --- ios/Podfile.lock | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/ios/Podfile.lock b/ios/Podfile.lock index 5f0d1e356c89..1ebfc6bb1b62 100644 --- a/ios/Podfile.lock +++ b/ios/Podfile.lock @@ -1944,7 +1944,7 @@ PODS: - ReactCommon/turbomodule/bridging - ReactCommon/turbomodule/core - Yoga - - RNScreens (3.29.0): + - RNScreens (3.30.1): - glog - hermes-engine - RCT-Folly (= 2022.05.16.00) @@ -1962,9 +1962,9 @@ PODS: - React-utils - ReactCommon/turbomodule/bridging - ReactCommon/turbomodule/core - - RNScreens/common (= 3.29.0) + - RNScreens/common (= 3.30.1) - Yoga - - RNScreens/common (3.29.0): + - RNScreens/common (3.30.1): - glog - hermes-engine - RCT-Folly (= 2022.05.16.00) @@ -2570,7 +2570,7 @@ SPEC CHECKSUMS: RNPermissions: 8990fc2c10da3640938e6db1647cb6416095b729 RNReactNativeHapticFeedback: 616c35bdec7d20d4c524a7949ca9829c09e35f37 RNReanimated: 605409e0d0ced6f2e194ae585fedc2f8a1935bf2 - RNScreens: f7b8bb892b4957f6f91e5dfd9a191e7f13ce8baa + RNScreens: 65a936f4e227b91e4a8e2a7d4c4607355bfefda0 RNShare: 2a4cdfc0626ad56b0ef583d424f2038f772afe58 RNSound: 6c156f925295bdc83e8e422e7d8b38d33bc71852 RNSVG: db32cfcad0a221fd175e0882eff7bcba7690380a @@ -2581,7 +2581,7 @@ SPEC CHECKSUMS: SocketRocket: f32cd54efbe0f095c4d7594881e52619cfe80b17 Turf: 13d1a92d969ca0311bbc26e8356cca178ce95da2 VisionCamera: 3033e0dd5272d46e97bcb406adea4ae0e6907abf - Yoga: 1b901a6d6eeba4e8a2e8f308f708691cdb5db312 + Yoga: 64cd2a583ead952b0315d5135bf39e053ae9be70 PODFILE CHECKSUM: a25a81f2b50270f0c0bd0aff2e2ebe4d0b4ec06d From cf99ea3afd461b5f6b1de1dce9d6a5b61d6aa83c Mon Sep 17 00:00:00 2001 From: Alberto <alberto@expensify.com> Date: Tue, 16 Apr 2024 12:36:48 +0200 Subject: [PATCH 131/206] do not skip for track expenses (for now) --- src/pages/iou/request/step/IOURequestStepAmount.tsx | 4 ++-- src/pages/iou/request/step/IOURequestStepDistance.tsx | 4 ++-- .../request/step/IOURequestStepScan/index.native.tsx | 11 ++++++++--- .../iou/request/step/IOURequestStepScan/index.tsx | 11 ++++++++--- 4 files changed, 20 insertions(+), 10 deletions(-) diff --git a/src/pages/iou/request/step/IOURequestStepAmount.tsx b/src/pages/iou/request/step/IOURequestStepAmount.tsx index 65dfa4c771d3..6cc63af2e89b 100644 --- a/src/pages/iou/request/step/IOURequestStepAmount.tsx +++ b/src/pages/iou/request/step/IOURequestStepAmount.tsx @@ -85,12 +85,12 @@ function IOURequestStepAmount({ // For quick button actions, we'll skip the confirmation page unless the report is archived or this is a workspace request, as // the user will have to add a merchant. const shouldSkipConfirmation: boolean = useMemo(() => { - if (!skipConfirmation || !report?.reportID) { + if (!skipConfirmation || !report?.reportID || iouType === CONST.IOU.TYPE.TRACK_EXPENSE) { return false; } return !(ReportUtils.isArchivedRoom(report) || ReportUtils.isPolicyExpenseChat(report)); - }, [report, skipConfirmation]); + }, [report, skipConfirmation, iouType]); useFocusEffect( useCallback(() => { diff --git a/src/pages/iou/request/step/IOURequestStepDistance.tsx b/src/pages/iou/request/step/IOURequestStepDistance.tsx index 3f93c2a88b77..a11533d38770 100644 --- a/src/pages/iou/request/step/IOURequestStepDistance.tsx +++ b/src/pages/iou/request/step/IOURequestStepDistance.tsx @@ -105,12 +105,12 @@ function IOURequestStepDistance({ // For quick button actions, we'll skip the confirmation page unless the report is archived or this is a workspace // request and the workspace requires a category or a tag const shouldSkipConfirmation: boolean = useMemo(() => { - if (!skipConfirmation || !report?.reportID) { + if (!skipConfirmation || !report?.reportID || iouType === CONST.IOU.TYPE.TRACK_EXPENSE) { return false; } return !ReportUtils.isArchivedRoom(report) && !(ReportUtils.isPolicyExpenseChat(report) && ((policy?.requiresCategory ?? false) || (policy?.requiresTag ?? false))); - }, [report, skipConfirmation, policy]); + }, [report, skipConfirmation, policy, iouType]); let buttonText = !isCreatingNewRequest ? translate('common.save') : translate('common.next'); if (shouldSkipConfirmation) { buttonText = iouType === CONST.IOU.TYPE.SPLIT ? translate('iou.split') : translate('iou.request'); diff --git a/src/pages/iou/request/step/IOURequestStepScan/index.native.tsx b/src/pages/iou/request/step/IOURequestStepScan/index.native.tsx index e18586185f6a..58d0dc4d145b 100644 --- a/src/pages/iou/request/step/IOURequestStepScan/index.native.tsx +++ b/src/pages/iou/request/step/IOURequestStepScan/index.native.tsx @@ -1,5 +1,5 @@ import {useFocusEffect} from '@react-navigation/core'; -import React, {useCallback, useRef, useState} from 'react'; +import React, {useCallback, useMemo, useRef, useState} from 'react'; import {ActivityIndicator, Alert, AppState, InteractionManager, View} from 'react-native'; import {Gesture, GestureDetector} from 'react-native-gesture-handler'; import {withOnyx} from 'react-native-onyx'; @@ -64,8 +64,13 @@ function IOURequestStepScan({ // For quick button actions, we'll skip the confirmation page unless the report is archived or this is a workspace // request and the workspace requires a category or a tag - const shouldSkipConfirmation = - skipConfirmation && !ReportUtils.isArchivedRoom(report) && !(ReportUtils.isPolicyExpenseChat(report) && ((policy?.requiresCategory ?? false) || (policy?.requiresTag ?? false))); + const shouldSkipConfirmation: boolean = useMemo(() => { + if (!skipConfirmation || !report?.reportID || iouType === CONST.IOU.TYPE.TRACK_EXPENSE) { + return false; + } + + return !ReportUtils.isArchivedRoom(report) && !(ReportUtils.isPolicyExpenseChat(report) && ((policy?.requiresCategory ?? false) || (policy?.requiresTag ?? false))); + }, [report, skipConfirmation, policy, iouType]); const {translate} = useLocalize(); diff --git a/src/pages/iou/request/step/IOURequestStepScan/index.tsx b/src/pages/iou/request/step/IOURequestStepScan/index.tsx index 7c938ab5df3c..f8370d98d75e 100644 --- a/src/pages/iou/request/step/IOURequestStepScan/index.tsx +++ b/src/pages/iou/request/step/IOURequestStepScan/index.tsx @@ -1,4 +1,4 @@ -import React, {useCallback, useContext, useEffect, useReducer, useRef, useState} from 'react'; +import React, {useCallback, useContext, useEffect, useMemo, useReducer, useRef, useState} from 'react'; import {ActivityIndicator, PanResponder, PixelRatio, View} from 'react-native'; import {withOnyx} from 'react-native-onyx'; import type Webcam from 'react-webcam'; @@ -79,8 +79,13 @@ function IOURequestStepScan({ // For quick button actions, we'll skip the confirmation page unless the report is archived or this is a workspace // request and the workspace requires a category or a tag - const shouldSkipConfirmation = - skipConfirmation && !ReportUtils.isArchivedRoom(report) && !(ReportUtils.isPolicyExpenseChat(report) && ((policy?.requiresCategory ?? false) || (policy?.requiresTag ?? false))); + const shouldSkipConfirmation: boolean = useMemo(() => { + if (!skipConfirmation || !report?.reportID || iouType === CONST.IOU.TYPE.TRACK_EXPENSE) { + return false; + } + + return !ReportUtils.isArchivedRoom(report) && !(ReportUtils.isPolicyExpenseChat(report) && ((policy?.requiresCategory ?? false) || (policy?.requiresTag ?? false))); + }, [report, skipConfirmation, policy, iouType]); /** * On phones that have ultra-wide lens, react-webcam uses ultra-wide by default. From 1de5ce37cdb66f679ac98f6a49b2f1d0256ca85c Mon Sep 17 00:00:00 2001 From: Wojciech Boman <wojciechboman@gmail.com> Date: Tue, 16 Apr 2024 13:05:57 +0200 Subject: [PATCH 132/206] Add a tooltip for the search icon in the bottom tab --- .../createCustomBottomTabNavigator/BottomTabBar.tsx | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/libs/Navigation/AppNavigator/createCustomBottomTabNavigator/BottomTabBar.tsx b/src/libs/Navigation/AppNavigator/createCustomBottomTabNavigator/BottomTabBar.tsx index f6e058242b7f..41d6f25f3353 100644 --- a/src/libs/Navigation/AppNavigator/createCustomBottomTabNavigator/BottomTabBar.tsx +++ b/src/libs/Navigation/AppNavigator/createCustomBottomTabNavigator/BottomTabBar.tsx @@ -101,6 +101,8 @@ function BottomTabBar({isLoadingApp = false}: PurposeForUsingExpensifyModalProps )} </View> </PressableWithFeedback> + </Tooltip> + <Tooltip text={translate('common.search')}> <PressableWithFeedback onPress={() => { Navigation.navigate(ROUTES.SEARCH.getRoute('all')); @@ -120,7 +122,6 @@ function BottomTabBar({isLoadingApp = false}: PurposeForUsingExpensifyModalProps </View> </PressableWithFeedback> </Tooltip> - <BottomTabAvatar isSelected={currentTabName === SCREENS.SETTINGS.ROOT} /> <BottomTabBarFloatingActionButton /> </View> From 3eb8e34ab838fb1ef9f0816d85b30d3632b372e4 Mon Sep 17 00:00:00 2001 From: Alberto <alberto@expensify.com> Date: Tue, 16 Apr 2024 15:05:19 +0200 Subject: [PATCH 133/206] remove uneeded param --- src/components/transactionPropTypes.js | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/components/transactionPropTypes.js b/src/components/transactionPropTypes.js index db0842e0c83a..7eb1b776358c 100644 --- a/src/components/transactionPropTypes.js +++ b/src/components/transactionPropTypes.js @@ -93,6 +93,4 @@ export default PropTypes.shape({ /** Server side errors keyed by microtime */ errorFields: PropTypes.objectOf(PropTypes.objectOf(translatableTextPropTypes)), - - skipConfirmation: PropTypes.bool, }); From 84f897427d1f600991cf4aec0e5e3641a7ea7a0c Mon Sep 17 00:00:00 2001 From: Alberto <alberto@expensify.com> Date: Tue, 16 Apr 2024 15:13:27 +0200 Subject: [PATCH 134/206] remove lint exceptions --- src/pages/iou/request/step/IOURequestStepAmount.tsx | 3 --- src/pages/iou/request/step/IOURequestStepDistance.tsx | 3 --- src/pages/iou/request/step/IOURequestStepScan/index.native.tsx | 3 --- src/pages/iou/request/step/IOURequestStepScan/index.tsx | 3 --- 4 files changed, 12 deletions(-) diff --git a/src/pages/iou/request/step/IOURequestStepAmount.tsx b/src/pages/iou/request/step/IOURequestStepAmount.tsx index 6cc63af2e89b..d74866534321 100644 --- a/src/pages/iou/request/step/IOURequestStepAmount.tsx +++ b/src/pages/iou/request/step/IOURequestStepAmount.tsx @@ -286,11 +286,8 @@ const IOURequestStepAmountWithOnyx = withOnyx<IOURequestStepAmountProps, IOURequ }, })(IOURequestStepAmount); -// eslint-disable-next-line rulesdir/no-negated-variables const IOURequestStepAmountWithCurrentUserPersonalDetails = withCurrentUserPersonalDetails(IOURequestStepAmountWithOnyx); -// eslint-disable-next-line rulesdir/no-negated-variables const IOURequestStepAmountWithWritableReportOrNotFound = withWritableReportOrNotFound(IOURequestStepAmountWithCurrentUserPersonalDetails); -// eslint-disable-next-line rulesdir/no-negated-variables const IOURequestStepAmountWithFullTransactionOrNotFound = withFullTransactionOrNotFound(IOURequestStepAmountWithWritableReportOrNotFound); export default IOURequestStepAmountWithFullTransactionOrNotFound; diff --git a/src/pages/iou/request/step/IOURequestStepDistance.tsx b/src/pages/iou/request/step/IOURequestStepDistance.tsx index a11533d38770..dd6bf90a07a2 100644 --- a/src/pages/iou/request/step/IOURequestStepDistance.tsx +++ b/src/pages/iou/request/step/IOURequestStepDistance.tsx @@ -415,11 +415,8 @@ const IOURequestStepDistanceWithOnyx = withOnyx<IOURequestStepDistanceProps, IOU }, })(IOURequestStepDistance); -// eslint-disable-next-line rulesdir/no-negated-variables const IOURequestStepDistanceWithCurrentUserPersonalDetails = withCurrentUserPersonalDetails(IOURequestStepDistanceWithOnyx); -// eslint-disable-next-line rulesdir/no-negated-variables const IOURequestStepDistanceWithWritableReportOrNotFound = withWritableReportOrNotFound(IOURequestStepDistanceWithCurrentUserPersonalDetails); -// eslint-disable-next-line rulesdir/no-negated-variables const IOURequestStepDistanceWithFullTransactionOrNotFound = withFullTransactionOrNotFound(IOURequestStepDistanceWithWritableReportOrNotFound); export default IOURequestStepDistanceWithFullTransactionOrNotFound; diff --git a/src/pages/iou/request/step/IOURequestStepScan/index.native.tsx b/src/pages/iou/request/step/IOURequestStepScan/index.native.tsx index 58d0dc4d145b..8640afc0178a 100644 --- a/src/pages/iou/request/step/IOURequestStepScan/index.native.tsx +++ b/src/pages/iou/request/step/IOURequestStepScan/index.native.tsx @@ -450,11 +450,8 @@ const IOURequestStepScanWithOnyx = withOnyx<IOURequestStepScanProps, IOURequestS }, })(IOURequestStepScan); -// eslint-disable-next-line rulesdir/no-negated-variables const IOURequestStepScanWithCurrentUserPersonalDetails = withCurrentUserPersonalDetails(IOURequestStepScanWithOnyx); -// eslint-disable-next-line rulesdir/no-negated-variables const IOURequestStepScanWithWritableReportOrNotFound = withWritableReportOrNotFound(IOURequestStepScanWithCurrentUserPersonalDetails); -// eslint-disable-next-line rulesdir/no-negated-variables const IOURequestStepScanWithFullTransactionOrNotFound = withFullTransactionOrNotFound(IOURequestStepScanWithWritableReportOrNotFound); export default IOURequestStepScanWithFullTransactionOrNotFound; diff --git a/src/pages/iou/request/step/IOURequestStepScan/index.tsx b/src/pages/iou/request/step/IOURequestStepScan/index.tsx index f8370d98d75e..1e4b41e980c7 100644 --- a/src/pages/iou/request/step/IOURequestStepScan/index.tsx +++ b/src/pages/iou/request/step/IOURequestStepScan/index.tsx @@ -577,11 +577,8 @@ const IOURequestStepScanWithOnyx = withOnyx<Omit<IOURequestStepScanProps, 'user' }, })(IOURequestStepScan); -// eslint-disable-next-line rulesdir/no-negated-variables const IOURequestStepScanWithCurrentUserPersonalDetails = withCurrentUserPersonalDetails(IOURequestStepScanWithOnyx); -// eslint-disable-next-line rulesdir/no-negated-variables const IOURequestStepScanWithWritableReportOrNotFound = withWritableReportOrNotFound(IOURequestStepScanWithCurrentUserPersonalDetails); -// eslint-disable-next-line rulesdir/no-negated-variables const IOURequestStepScanWithFullTransactionOrNotFound = withFullTransactionOrNotFound(IOURequestStepScanWithWritableReportOrNotFound); export default IOURequestStepScanWithFullTransactionOrNotFound; From d4905aa11e47ca096717b7361749ccf5d31bbc2b Mon Sep 17 00:00:00 2001 From: Alberto <alberto@expensify.com> Date: Tue, 16 Apr 2024 15:24:01 +0200 Subject: [PATCH 135/206] readd them --- src/pages/iou/request/step/IOURequestStepAmount.tsx | 2 ++ src/pages/iou/request/step/IOURequestStepDistance.tsx | 2 ++ src/pages/iou/request/step/IOURequestStepScan/index.native.tsx | 2 ++ src/pages/iou/request/step/IOURequestStepScan/index.tsx | 2 ++ 4 files changed, 8 insertions(+) diff --git a/src/pages/iou/request/step/IOURequestStepAmount.tsx b/src/pages/iou/request/step/IOURequestStepAmount.tsx index d74866534321..9001ff5d6600 100644 --- a/src/pages/iou/request/step/IOURequestStepAmount.tsx +++ b/src/pages/iou/request/step/IOURequestStepAmount.tsx @@ -287,7 +287,9 @@ const IOURequestStepAmountWithOnyx = withOnyx<IOURequestStepAmountProps, IOURequ })(IOURequestStepAmount); const IOURequestStepAmountWithCurrentUserPersonalDetails = withCurrentUserPersonalDetails(IOURequestStepAmountWithOnyx); +// eslint-disable-next-line rulesdir/no-negated-variables const IOURequestStepAmountWithWritableReportOrNotFound = withWritableReportOrNotFound(IOURequestStepAmountWithCurrentUserPersonalDetails); +// eslint-disable-next-line rulesdir/no-negated-variables const IOURequestStepAmountWithFullTransactionOrNotFound = withFullTransactionOrNotFound(IOURequestStepAmountWithWritableReportOrNotFound); export default IOURequestStepAmountWithFullTransactionOrNotFound; diff --git a/src/pages/iou/request/step/IOURequestStepDistance.tsx b/src/pages/iou/request/step/IOURequestStepDistance.tsx index dd6bf90a07a2..0e482c35b38a 100644 --- a/src/pages/iou/request/step/IOURequestStepDistance.tsx +++ b/src/pages/iou/request/step/IOURequestStepDistance.tsx @@ -416,7 +416,9 @@ const IOURequestStepDistanceWithOnyx = withOnyx<IOURequestStepDistanceProps, IOU })(IOURequestStepDistance); const IOURequestStepDistanceWithCurrentUserPersonalDetails = withCurrentUserPersonalDetails(IOURequestStepDistanceWithOnyx); +// eslint-disable-next-line rulesdir/no-negated-variables const IOURequestStepDistanceWithWritableReportOrNotFound = withWritableReportOrNotFound(IOURequestStepDistanceWithCurrentUserPersonalDetails); +// eslint-disable-next-line rulesdir/no-negated-variables const IOURequestStepDistanceWithFullTransactionOrNotFound = withFullTransactionOrNotFound(IOURequestStepDistanceWithWritableReportOrNotFound); export default IOURequestStepDistanceWithFullTransactionOrNotFound; diff --git a/src/pages/iou/request/step/IOURequestStepScan/index.native.tsx b/src/pages/iou/request/step/IOURequestStepScan/index.native.tsx index 8640afc0178a..84c2137dafda 100644 --- a/src/pages/iou/request/step/IOURequestStepScan/index.native.tsx +++ b/src/pages/iou/request/step/IOURequestStepScan/index.native.tsx @@ -451,7 +451,9 @@ const IOURequestStepScanWithOnyx = withOnyx<IOURequestStepScanProps, IOURequestS })(IOURequestStepScan); const IOURequestStepScanWithCurrentUserPersonalDetails = withCurrentUserPersonalDetails(IOURequestStepScanWithOnyx); +// eslint-disable-next-line rulesdir/no-negated-variables const IOURequestStepScanWithWritableReportOrNotFound = withWritableReportOrNotFound(IOURequestStepScanWithCurrentUserPersonalDetails); +// eslint-disable-next-line rulesdir/no-negated-variables const IOURequestStepScanWithFullTransactionOrNotFound = withFullTransactionOrNotFound(IOURequestStepScanWithWritableReportOrNotFound); export default IOURequestStepScanWithFullTransactionOrNotFound; diff --git a/src/pages/iou/request/step/IOURequestStepScan/index.tsx b/src/pages/iou/request/step/IOURequestStepScan/index.tsx index 1e4b41e980c7..8bca59b11580 100644 --- a/src/pages/iou/request/step/IOURequestStepScan/index.tsx +++ b/src/pages/iou/request/step/IOURequestStepScan/index.tsx @@ -578,7 +578,9 @@ const IOURequestStepScanWithOnyx = withOnyx<Omit<IOURequestStepScanProps, 'user' })(IOURequestStepScan); const IOURequestStepScanWithCurrentUserPersonalDetails = withCurrentUserPersonalDetails(IOURequestStepScanWithOnyx); +// eslint-disable-next-line rulesdir/no-negated-variables const IOURequestStepScanWithWritableReportOrNotFound = withWritableReportOrNotFound(IOURequestStepScanWithCurrentUserPersonalDetails); +// eslint-disable-next-line rulesdir/no-negated-variables const IOURequestStepScanWithFullTransactionOrNotFound = withFullTransactionOrNotFound(IOURequestStepScanWithWritableReportOrNotFound); export default IOURequestStepScanWithFullTransactionOrNotFound; From f84911bf10eb9ab604ca11e1e87ab7c85c4d9531 Mon Sep 17 00:00:00 2001 From: Wojciech Boman <wojciechboman@gmail.com> Date: Tue, 16 Apr 2024 15:38:00 +0200 Subject: [PATCH 136/206] Add SEARCH_QUERIES consts, hide new features --- src/CONST.ts | 6 ++++++ src/components/TestToolMenu.tsx | 11 +++++++++++ .../createCustomBottomTabNavigator/BottomTabBar.tsx | 9 +++++---- src/pages/Search/SearchPage.tsx | 2 +- src/pages/Search/SearchPageBottomTab.tsx | 9 +++++---- src/pages/Search/SearchResults.tsx | 9 ++++++--- 6 files changed, 34 insertions(+), 12 deletions(-) diff --git a/src/CONST.ts b/src/CONST.ts index d23a7f695ddc..10c1b5679a8f 100755 --- a/src/CONST.ts +++ b/src/CONST.ts @@ -4345,6 +4345,12 @@ const CONST = { MAX_TAX_RATE_INTEGER_PLACES: 4, MAX_TAX_RATE_DECIMAL_PLACES: 4, + + SEARCH_QUERIES: { + ALL: 'all', + SENT: 'sent', + DRAFTS: 'drafts' + } } as const; type Country = keyof typeof CONST.ALL_COUNTRIES; diff --git a/src/components/TestToolMenu.tsx b/src/components/TestToolMenu.tsx index 5efa9592034f..3299b7e4f0c4 100644 --- a/src/components/TestToolMenu.tsx +++ b/src/components/TestToolMenu.tsx @@ -10,6 +10,7 @@ import * as Network from '@userActions/Network'; import * as Session from '@userActions/Session'; import * as User from '@userActions/User'; import CONFIG from '@src/CONFIG'; +import CONST from '@src/CONST'; import ONYXKEYS from '@src/ONYXKEYS'; import ROUTES from '@src/ROUTES'; import type {Network as NetworkOnyx, User as UserOnyx} from '@src/types/onyx'; @@ -103,6 +104,16 @@ function TestToolMenu({user = USER_DEFAULT, network}: TestToolMenuProps) { }} /> </TestToolRow> + {/* Navigate to the new Search Page. This button is temporary and should be removed after passing QA tests. */} + <TestToolRow title="New Search Page"> + <Button + small + text="Navigate" + onPress={() => { + Navigation.navigate(ROUTES.SEARCH.getRoute(CONST.SEARCH_QUERIES.ALL)); + }} + /> + </TestToolRow> </> ); } diff --git a/src/libs/Navigation/AppNavigator/createCustomBottomTabNavigator/BottomTabBar.tsx b/src/libs/Navigation/AppNavigator/createCustomBottomTabNavigator/BottomTabBar.tsx index 41d6f25f3353..404b3ba68d92 100644 --- a/src/libs/Navigation/AppNavigator/createCustomBottomTabNavigator/BottomTabBar.tsx +++ b/src/libs/Navigation/AppNavigator/createCustomBottomTabNavigator/BottomTabBar.tsx @@ -102,10 +102,11 @@ function BottomTabBar({isLoadingApp = false}: PurposeForUsingExpensifyModalProps </View> </PressableWithFeedback> </Tooltip> - <Tooltip text={translate('common.search')}> + {/** @TODO: Uncomment this code and change order of the items according to the designs once the new search tab is ready */} + {/* <Tooltip text={translate('common.search')}> <PressableWithFeedback onPress={() => { - Navigation.navigate(ROUTES.SEARCH.getRoute('all')); + Navigation.navigate(ROUTES.SEARCH.getRoute(CONST.SEARCH_QUERIES.ALL)); }} role={CONST.ROLE.BUTTON} accessibilityLabel={translate('common.search')} @@ -121,9 +122,9 @@ function BottomTabBar({isLoadingApp = false}: PurposeForUsingExpensifyModalProps /> </View> </PressableWithFeedback> - </Tooltip> - <BottomTabAvatar isSelected={currentTabName === SCREENS.SETTINGS.ROOT} /> + </Tooltip> */} <BottomTabBarFloatingActionButton /> + <BottomTabAvatar isSelected={currentTabName === SCREENS.SETTINGS.ROOT} /> </View> ); } diff --git a/src/pages/Search/SearchPage.tsx b/src/pages/Search/SearchPage.tsx index 135ab66276a2..971705351cd2 100644 --- a/src/pages/Search/SearchPage.tsx +++ b/src/pages/Search/SearchPage.tsx @@ -13,7 +13,7 @@ function SearchPage({route}: SearchPageProps) { return ( <ScreenWrapper testID="testPage"> - <SearchResults filter={route.params.query} /> + <SearchResults query={route.params.query} /> </ScreenWrapper> ); } diff --git a/src/pages/Search/SearchPageBottomTab.tsx b/src/pages/Search/SearchPageBottomTab.tsx index 96b6aaf191fd..39d74a514bcc 100644 --- a/src/pages/Search/SearchPageBottomTab.tsx +++ b/src/pages/Search/SearchPageBottomTab.tsx @@ -7,6 +7,7 @@ import useSingleExecution from '@hooks/useSingleExecution'; import useThemeStyles from '@hooks/useThemeStyles'; import Navigation from '@libs/Navigation/Navigation'; import * as Expensicons from '@src/components/Icon/Expensicons'; +import CONST from '@src/CONST'; import ROUTES from '@src/ROUTES'; import type IconAsset from '@src/types/utils/IconAsset'; @@ -20,23 +21,23 @@ function SearchPageBottomTab() { const styles = useThemeStyles(); const {singleExecution} = useSingleExecution(); const activeRoute = useActiveRoute(); - const currentQuery = activeRoute?.params?.query; + const currentQuery = activeRoute?.params && 'query' in activeRoute.params ? activeRoute?.params?.query : ''; const searchMenuItems: SearchMenuItem[] = [ { title: 'All', icon: Expensicons.ExpensifyLogoNew, - action: singleExecution(() => Navigation.navigate(ROUTES.SEARCH.getRoute('all'))), + action: singleExecution(() => Navigation.navigate(ROUTES.SEARCH.getRoute(CONST.SEARCH_QUERIES.ALL))), }, { title: 'Sent', icon: Expensicons.ExpensifyLogoNew, - action: singleExecution(() => Navigation.navigate(ROUTES.SEARCH.getRoute('sent'))), + action: singleExecution(() => Navigation.navigate(ROUTES.SEARCH.getRoute(CONST.SEARCH_QUERIES.SENT))), }, { title: 'Drafts', icon: Expensicons.ExpensifyLogoNew, - action: singleExecution(() => Navigation.navigate(ROUTES.SEARCH.getRoute('drafts'))), + action: singleExecution(() => Navigation.navigate(ROUTES.SEARCH.getRoute(CONST.SEARCH_QUERIES.DRAFTS))), }, ]; diff --git a/src/pages/Search/SearchResults.tsx b/src/pages/Search/SearchResults.tsx index b0d4c3bede39..261484bc13ec 100644 --- a/src/pages/Search/SearchResults.tsx +++ b/src/pages/Search/SearchResults.tsx @@ -1,12 +1,15 @@ import React from 'react'; import Text from '@components/Text'; +import useThemeStyles from '@hooks/useThemeStyles'; type SearchResultsProps = { - filter: string; + query: string; }; -function SearchResults({filter}: SearchResultsProps) { - return <Text style={{color: 'white', fontSize: 30}}>Search results for: |{filter}| filter</Text>; +function SearchResults({query}: SearchResultsProps) { + const styles = useThemeStyles(); + + return <Text style={styles.textHeadlineH1}>Search results for: |{query}| filter</Text>; } SearchResults.displayName = 'SearchResults'; From 8ea25e3bb589a45ba85884018c4405b7f3abc92a Mon Sep 17 00:00:00 2001 From: Wojciech Boman <wojciechboman@gmail.com> Date: Tue, 16 Apr 2024 15:48:09 +0200 Subject: [PATCH 137/206] Remove SEARCH_QUERIES const --- src/CONST.ts | 6 ------ src/components/TestToolMenu.tsx | 2 +- .../createCustomBottomTabNavigator/BottomTabBar.tsx | 2 +- src/pages/Search/SearchPageBottomTab.tsx | 6 +++--- 4 files changed, 5 insertions(+), 11 deletions(-) diff --git a/src/CONST.ts b/src/CONST.ts index 10c1b5679a8f..d23a7f695ddc 100755 --- a/src/CONST.ts +++ b/src/CONST.ts @@ -4345,12 +4345,6 @@ const CONST = { MAX_TAX_RATE_INTEGER_PLACES: 4, MAX_TAX_RATE_DECIMAL_PLACES: 4, - - SEARCH_QUERIES: { - ALL: 'all', - SENT: 'sent', - DRAFTS: 'drafts' - } } as const; type Country = keyof typeof CONST.ALL_COUNTRIES; diff --git a/src/components/TestToolMenu.tsx b/src/components/TestToolMenu.tsx index 3299b7e4f0c4..6827dee44141 100644 --- a/src/components/TestToolMenu.tsx +++ b/src/components/TestToolMenu.tsx @@ -110,7 +110,7 @@ function TestToolMenu({user = USER_DEFAULT, network}: TestToolMenuProps) { small text="Navigate" onPress={() => { - Navigation.navigate(ROUTES.SEARCH.getRoute(CONST.SEARCH_QUERIES.ALL)); + Navigation.navigate(ROUTES.SEARCH.getRoute(CONST.TAB_SEARCH.ALL)); }} /> </TestToolRow> diff --git a/src/libs/Navigation/AppNavigator/createCustomBottomTabNavigator/BottomTabBar.tsx b/src/libs/Navigation/AppNavigator/createCustomBottomTabNavigator/BottomTabBar.tsx index 404b3ba68d92..0f2f3d2b0ce6 100644 --- a/src/libs/Navigation/AppNavigator/createCustomBottomTabNavigator/BottomTabBar.tsx +++ b/src/libs/Navigation/AppNavigator/createCustomBottomTabNavigator/BottomTabBar.tsx @@ -106,7 +106,7 @@ function BottomTabBar({isLoadingApp = false}: PurposeForUsingExpensifyModalProps {/* <Tooltip text={translate('common.search')}> <PressableWithFeedback onPress={() => { - Navigation.navigate(ROUTES.SEARCH.getRoute(CONST.SEARCH_QUERIES.ALL)); + Navigation.navigate(ROUTES.SEARCH.getRoute(CONST.TAB_SEARCH.ALL)); }} role={CONST.ROLE.BUTTON} accessibilityLabel={translate('common.search')} diff --git a/src/pages/Search/SearchPageBottomTab.tsx b/src/pages/Search/SearchPageBottomTab.tsx index 39d74a514bcc..797add51b4b5 100644 --- a/src/pages/Search/SearchPageBottomTab.tsx +++ b/src/pages/Search/SearchPageBottomTab.tsx @@ -27,17 +27,17 @@ function SearchPageBottomTab() { { title: 'All', icon: Expensicons.ExpensifyLogoNew, - action: singleExecution(() => Navigation.navigate(ROUTES.SEARCH.getRoute(CONST.SEARCH_QUERIES.ALL))), + action: singleExecution(() => Navigation.navigate(ROUTES.SEARCH.getRoute(CONST.TAB_SEARCH.ALL))), }, { title: 'Sent', icon: Expensicons.ExpensifyLogoNew, - action: singleExecution(() => Navigation.navigate(ROUTES.SEARCH.getRoute(CONST.SEARCH_QUERIES.SENT))), + action: singleExecution(() => Navigation.navigate(ROUTES.SEARCH.getRoute(CONST.TAB_SEARCH.SENT))), }, { title: 'Drafts', icon: Expensicons.ExpensifyLogoNew, - action: singleExecution(() => Navigation.navigate(ROUTES.SEARCH.getRoute(CONST.SEARCH_QUERIES.DRAFTS))), + action: singleExecution(() => Navigation.navigate(ROUTES.SEARCH.getRoute(CONST.TAB_SEARCH.DRAFTS))), }, ]; From 5ea4a9f1069424b9f793ee0ed7781c2ffd92efcc Mon Sep 17 00:00:00 2001 From: Wojciech Boman <wojciechboman@gmail.com> Date: Tue, 16 Apr 2024 16:09:07 +0200 Subject: [PATCH 138/206] Remove test page --- src/pages/SearchPage.tsx | 16 ---------------- tests/perf-test/SearchPage.perf-test.tsx | 2 +- 2 files changed, 1 insertion(+), 17 deletions(-) delete mode 100644 src/pages/SearchPage.tsx diff --git a/src/pages/SearchPage.tsx b/src/pages/SearchPage.tsx deleted file mode 100644 index 76f81697d190..000000000000 --- a/src/pages/SearchPage.tsx +++ /dev/null @@ -1,16 +0,0 @@ -import React from 'react'; -// eslint-disable-next-line no-restricted-imports -import {Text} from 'react-native'; -import ScreenWrapper from '@components/ScreenWrapper'; - -function TestPage() { - return ( - <ScreenWrapper testID="testPage"> - <Text style={{color: 'white', fontSize: 30}}>TEST PAGE</Text> - </ScreenWrapper> - ); -} - -TestPage.displayName = 'TestPage'; - -export default TestPage; diff --git a/tests/perf-test/SearchPage.perf-test.tsx b/tests/perf-test/SearchPage.perf-test.tsx index 8a4596810808..60eab9d76e59 100644 --- a/tests/perf-test/SearchPage.perf-test.tsx +++ b/tests/perf-test/SearchPage.perf-test.tsx @@ -13,7 +13,7 @@ import {KeyboardStateProvider} from '@components/withKeyboardState'; import type {WithNavigationFocusProps} from '@components/withNavigationFocus'; import type {RootStackParamList} from '@libs/Navigation/types'; import {createOptionList} from '@libs/OptionsListUtils'; -import SearchPage from '@pages/SearchPage'; +import SearchPage from '@pages/Search/SearchPage'; import ComposeProviders from '@src/components/ComposeProviders'; import OnyxProvider from '@src/components/OnyxProvider'; import CONST from '@src/CONST'; From d8f364a6e766a6f52994afae072b9c9135b3e076 Mon Sep 17 00:00:00 2001 From: Alberto <alberto@expensify.com> Date: Tue, 16 Apr 2024 16:12:34 +0200 Subject: [PATCH 139/206] add param type --- src/libs/actions/IOU.ts | 4 ++-- src/libs/actions/Task.ts | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/libs/actions/IOU.ts b/src/libs/actions/IOU.ts index 9d4e37beaaad..3aba9e77aaae 100644 --- a/src/libs/actions/IOU.ts +++ b/src/libs/actions/IOU.ts @@ -327,7 +327,7 @@ function initMoneyRequest(reportID: string, policy: OnyxEntry<OnyxTypes.Policy>, }); } -function clearMoneyRequest(transactionID: string, skipConfirmation = false) { +function clearMoneyRequest(transactionID: string, skipConfirmation: boolean = false) { Onyx.set(`${ONYXKEYS.COLLECTION.SKIP_CONFIRMATION}${transactionID}`, skipConfirmation); Onyx.set(`${ONYXKEYS.COLLECTION.TRANSACTION_DRAFT}${transactionID}`, null); } @@ -355,7 +355,7 @@ function updateMoneyRequestTypeParams(routes: StackNavigationState<ParamListBase } // eslint-disable-next-line @typescript-eslint/naming-convention -function startMoneyRequest(iouType: ValueOf<typeof CONST.IOU.TYPE>, reportID: string, requestType?: IOURequestType, skipConfirmation = false) { +function startMoneyRequest(iouType: ValueOf<typeof CONST.IOU.TYPE>, reportID: string, requestType?: IOURequestType, skipConfirmation: boolean = false) { clearMoneyRequest(CONST.IOU.OPTIMISTIC_TRANSACTION_ID, skipConfirmation); switch (requestType) { case CONST.IOU.REQUEST_TYPE.MANUAL: diff --git a/src/libs/actions/Task.ts b/src/libs/actions/Task.ts index b12a7ef0d796..9b1d808fe923 100644 --- a/src/libs/actions/Task.ts +++ b/src/libs/actions/Task.ts @@ -90,7 +90,7 @@ Onyx.connect({ /** * Clears out the task info from the store */ -function clearOutTaskInfo(skipConfirmation = false) { +function clearOutTaskInfo(skipConfirmation: boolean = false) { if (skipConfirmation) { Onyx.set(ONYXKEYS.TASK, {skipConfirmation: true}); } else { @@ -729,7 +729,7 @@ function setParentReportID(parentReportID: string) { /** * Clears out the task info from the store and navigates to the NewTaskDetails page */ -function clearOutTaskInfoAndNavigate(reportID?: string, chatReport?: OnyxEntry<OnyxTypes.Report>, accountID = 0, skipConfirmation = false) { +function clearOutTaskInfoAndNavigate(reportID?: string, chatReport?: OnyxEntry<OnyxTypes.Report>, accountID = 0, skipConfirmation: boolean = false) { clearOutTaskInfo(skipConfirmation); if (reportID && reportID !== '0') { setParentReportID(reportID); From 2e38d66215fd2418c21d5788b7dcd61dc0b164ca Mon Sep 17 00:00:00 2001 From: Adam Grzybowski <adam.grzybowski@swmansion.com> Date: Tue, 16 Apr 2024 16:22:29 +0200 Subject: [PATCH 140/206] add comment for useCustomBackHandler --- src/pages/Search/useCustomBackHandler/index.android.ts | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/pages/Search/useCustomBackHandler/index.android.ts b/src/pages/Search/useCustomBackHandler/index.android.ts index cc9d5d3ca198..f168cb0b9008 100644 --- a/src/pages/Search/useCustomBackHandler/index.android.ts +++ b/src/pages/Search/useCustomBackHandler/index.android.ts @@ -7,6 +7,8 @@ import type {RootStackParamList, State} from '@libs/Navigation/types'; import NAVIGATORS from '@src/NAVIGATORS'; import SCREENS from '@src/SCREENS'; +// We need to make sure that the central pane screen and bottom tab won't be desynchronized after using the physical back button on Android. +// To achieve that we will call additional POP on the bottom tab navigator if the search page would disappear from the central pane. function useCustomBackHandler() { useFocusEffect( useCallback(() => { From 575cdf7f6db03c61bd9e0b90d634ac80c004e046 Mon Sep 17 00:00:00 2001 From: Alberto <alberto@expensify.com> Date: Tue, 16 Apr 2024 16:31:54 +0200 Subject: [PATCH 141/206] removing last change --- src/libs/actions/IOU.ts | 4 ++-- src/libs/actions/Task.ts | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/libs/actions/IOU.ts b/src/libs/actions/IOU.ts index 3aba9e77aaae..9d4e37beaaad 100644 --- a/src/libs/actions/IOU.ts +++ b/src/libs/actions/IOU.ts @@ -327,7 +327,7 @@ function initMoneyRequest(reportID: string, policy: OnyxEntry<OnyxTypes.Policy>, }); } -function clearMoneyRequest(transactionID: string, skipConfirmation: boolean = false) { +function clearMoneyRequest(transactionID: string, skipConfirmation = false) { Onyx.set(`${ONYXKEYS.COLLECTION.SKIP_CONFIRMATION}${transactionID}`, skipConfirmation); Onyx.set(`${ONYXKEYS.COLLECTION.TRANSACTION_DRAFT}${transactionID}`, null); } @@ -355,7 +355,7 @@ function updateMoneyRequestTypeParams(routes: StackNavigationState<ParamListBase } // eslint-disable-next-line @typescript-eslint/naming-convention -function startMoneyRequest(iouType: ValueOf<typeof CONST.IOU.TYPE>, reportID: string, requestType?: IOURequestType, skipConfirmation: boolean = false) { +function startMoneyRequest(iouType: ValueOf<typeof CONST.IOU.TYPE>, reportID: string, requestType?: IOURequestType, skipConfirmation = false) { clearMoneyRequest(CONST.IOU.OPTIMISTIC_TRANSACTION_ID, skipConfirmation); switch (requestType) { case CONST.IOU.REQUEST_TYPE.MANUAL: diff --git a/src/libs/actions/Task.ts b/src/libs/actions/Task.ts index 9b1d808fe923..b12a7ef0d796 100644 --- a/src/libs/actions/Task.ts +++ b/src/libs/actions/Task.ts @@ -90,7 +90,7 @@ Onyx.connect({ /** * Clears out the task info from the store */ -function clearOutTaskInfo(skipConfirmation: boolean = false) { +function clearOutTaskInfo(skipConfirmation = false) { if (skipConfirmation) { Onyx.set(ONYXKEYS.TASK, {skipConfirmation: true}); } else { @@ -729,7 +729,7 @@ function setParentReportID(parentReportID: string) { /** * Clears out the task info from the store and navigates to the NewTaskDetails page */ -function clearOutTaskInfoAndNavigate(reportID?: string, chatReport?: OnyxEntry<OnyxTypes.Report>, accountID = 0, skipConfirmation: boolean = false) { +function clearOutTaskInfoAndNavigate(reportID?: string, chatReport?: OnyxEntry<OnyxTypes.Report>, accountID = 0, skipConfirmation = false) { clearOutTaskInfo(skipConfirmation); if (reportID && reportID !== '0') { setParentReportID(reportID); From f72476165080a7de814c13c84247bbe7a3ae5ad2 Mon Sep 17 00:00:00 2001 From: Wojciech Boman <wojciechboman@gmail.com> Date: Tue, 16 Apr 2024 16:38:18 +0200 Subject: [PATCH 142/206] Exclude shallowCompare function --- .../Navigation/AppNavigator/getPartialStateDiff.ts | 13 +------------ src/libs/Navigation/linkTo.ts | 13 +------------ src/libs/ObjectUtils.ts | 13 +++++++++++++ 3 files changed, 15 insertions(+), 24 deletions(-) create mode 100644 src/libs/ObjectUtils.ts diff --git a/src/libs/Navigation/AppNavigator/getPartialStateDiff.ts b/src/libs/Navigation/AppNavigator/getPartialStateDiff.ts index 5732cb93f19c..4c18e161c9a9 100644 --- a/src/libs/Navigation/AppNavigator/getPartialStateDiff.ts +++ b/src/libs/Navigation/AppNavigator/getPartialStateDiff.ts @@ -3,20 +3,9 @@ import getTopmostCentralPaneRoute from '@libs/Navigation/getTopmostCentralPaneRo import getTopmostFullScreenRoute from '@libs/Navigation/getTopmostFullScreenRoute'; import type {Metainfo} from '@libs/Navigation/linkingConfig/getAdaptedStateFromPath'; import type {NavigationPartialRoute, RootStackParamList, State} from '@libs/Navigation/types'; +import shallowCompare from '@libs/ObjectUtils'; import NAVIGATORS from '@src/NAVIGATORS'; -// eslint-disable-next-line @typescript-eslint/ban-types -const shallowCompare = (obj1?: object, obj2?: object) => { - if (!obj1 && !obj2) { - return true; - } - if (obj1 && obj2) { - // @ts-expect-error we know that obj1 and obj2 are params of a route. - return Object.keys(obj1).length === Object.keys(obj2).length && Object.keys(obj1).every((key) => obj1[key] === obj2[key]); - } - return false; -}; - type GetPartialStateDiffReturnType = { [NAVIGATORS.BOTTOM_TAB_NAVIGATOR]?: NavigationPartialRoute; [NAVIGATORS.CENTRAL_PANE_NAVIGATOR]?: NavigationPartialRoute; diff --git a/src/libs/Navigation/linkTo.ts b/src/libs/Navigation/linkTo.ts index 630a44fe1d3b..863cb102add4 100644 --- a/src/libs/Navigation/linkTo.ts +++ b/src/libs/Navigation/linkTo.ts @@ -2,6 +2,7 @@ import {getActionFromState} from '@react-navigation/core'; import type {NavigationAction, NavigationContainerRef, NavigationState, PartialState} from '@react-navigation/native'; import type {Writable} from 'type-fest'; import getIsNarrowLayout from '@libs/getIsNarrowLayout'; +import shallowCompare from '@libs/ObjectUtils'; import {extractPolicyIDFromPath, getPathWithoutPolicyID} from '@libs/PolicyUtils'; import CONST from '@src/CONST'; import NAVIGATORS from '@src/NAVIGATORS'; @@ -30,18 +31,6 @@ type ActionPayload = { params?: ActionPayloadParams; }; -// eslint-disable-next-line @typescript-eslint/ban-types -const shallowCompare = (obj1?: object, obj2?: object) => { - if (!obj1 && !obj2) { - return true; - } - if (obj1 && obj2) { - // @ts-expect-error we know that obj1 and obj2 are params of a route. - return Object.keys(obj1).length === Object.keys(obj2).length && Object.keys(obj1).every((key) => obj1[key] === obj2[key]); - } - return false; -}; - /** * Motivation for this function is described in NAVIGATION.md * diff --git a/src/libs/ObjectUtils.ts b/src/libs/ObjectUtils.ts new file mode 100644 index 000000000000..9ffa461506c8 --- /dev/null +++ b/src/libs/ObjectUtils.ts @@ -0,0 +1,13 @@ +// eslint-disable-next-line @typescript-eslint/ban-types +const shallowCompare = (obj1?: object, obj2?: object) => { + if (!obj1 && !obj2) { + return true; + } + if (obj1 && obj2) { + // @ts-expect-error we know that obj1 and obj2 are params of a route. + return Object.keys(obj1).length === Object.keys(obj2).length && Object.keys(obj1).every((key) => obj1[key] === obj2[key]); + } + return false; +}; + +export default shallowCompare; From b5933b7e622ce083468efb8f90ddaab07126320f Mon Sep 17 00:00:00 2001 From: Shridhar Goel <35566748+ShridharGoel@users.noreply.github.com> Date: Tue, 16 Apr 2024 21:01:53 +0530 Subject: [PATCH 143/206] Exclude domain rooms check from canSeeDefaultRooms --- src/libs/ReportUtils.ts | 5 ----- 1 file changed, 5 deletions(-) diff --git a/src/libs/ReportUtils.ts b/src/libs/ReportUtils.ts index f7b160bd67e2..e1ed1c0cca57 100644 --- a/src/libs/ReportUtils.ts +++ b/src/libs/ReportUtils.ts @@ -4450,11 +4450,6 @@ function canSeeDefaultRoom(report: OnyxEntry<Report>, policies: OnyxCollection<P return true; } - // Include domain rooms with Partner Managers (Expensify accounts) in them for accounts that are on a domain with an Approved Accountant - if (isDomainRoom(report) && doesDomainHaveApprovedAccountant && hasExpensifyEmails(report?.participantAccountIDs ?? [])) { - return true; - } - // If the room has an assigned guide, it can be seen. if (hasExpensifyGuidesEmails(report?.participantAccountIDs ?? [])) { return true; From 12b2256e5b5cd6a9121c10351b4d7cf2584e49e4 Mon Sep 17 00:00:00 2001 From: Krishna <belivethatkg@gmail.com> Date: Wed, 17 Apr 2024 00:00:58 +0530 Subject: [PATCH 144/206] Update InitialSettingsPage.tsx --- src/pages/settings/InitialSettingsPage.tsx | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/pages/settings/InitialSettingsPage.tsx b/src/pages/settings/InitialSettingsPage.tsx index c3e816b633d7..96259ba9ab77 100755 --- a/src/pages/settings/InitialSettingsPage.tsx +++ b/src/pages/settings/InitialSettingsPage.tsx @@ -485,8 +485,7 @@ function InitialSettingsPage({session, userWallet, bankAccountList, fundList, wa ref={scrollViewRef} onScroll={onScroll} scrollEventThrottle={16} - // We use marginTop to prevent glitching on the initial frame that renders before scrollTo. - contentContainerStyle={[!isAfterOnLayout && !!scrollOffset && {marginTop: -scrollOffset}, styles.w100, styles.pt4]} + contentContainerStyle={[styles.w100, styles.pt4]} > {headerContent} {accountMenuItems} From 476f0f71bcf710c7ac628fd60b095e555d20f9d0 Mon Sep 17 00:00:00 2001 From: Kevin Brian Bader <kevin.bader96@gmail.com> Date: Tue, 16 Apr 2024 21:45:57 +0300 Subject: [PATCH 145/206] removed redundant JSDoc --- src/libs/WorkspacesSettingsUtils.ts | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/src/libs/WorkspacesSettingsUtils.ts b/src/libs/WorkspacesSettingsUtils.ts index c01a2150e34b..e55df2d4c7c9 100644 --- a/src/libs/WorkspacesSettingsUtils.ts +++ b/src/libs/WorkspacesSettingsUtils.ts @@ -67,8 +67,7 @@ Onyx.connect({ }); /** - * @param report - * @param actionsByReport (optional) - similar to (local) reportActionsByReport, coming from (local) function getWorkspacesBrickRoads + * @param actionsByReport Replaces (local) reportActionsByReport used within (local) function getWorkspacesBrickRoads * @returns BrickRoad for the policy passed as a param and optionally actionsByReport (if passed) */ const getBrickRoadForPolicy = (report: Report, actionsByReport?: OnyxCollection<ReportActions>): BrickRoad => { @@ -157,9 +156,6 @@ function checkIfWorkspaceSettingsTabHasRBR(policyID?: string) { } /** - * @param reports - * @param policies - * @param reportActions (optional) * @returns a map where the keys are policyIDs and the values are BrickRoads for each policy */ function getWorkspacesBrickRoads(reports: OnyxCollection<Report>, policies: OnyxCollection<Policy>, reportActions?: OnyxCollection<ReportActions>): Record<string, BrickRoad> { @@ -204,7 +200,6 @@ function getWorkspacesBrickRoads(reports: OnyxCollection<Report>, policies: Onyx } /** - * @param reports * @returns a map where the keys are policyIDs and the values are truthy booleans if policy has unread content */ function getWorkspacesUnreadStatuses(reports: OnyxCollection<Report>): Record<string, boolean> { From 5d8c0c521bc54cf3fbe0d78b75194813f893afb0 Mon Sep 17 00:00:00 2001 From: brunovjk <brunovjk@gmail.com> Date: Tue, 16 Apr 2024 16:11:28 -0300 Subject: [PATCH 146/206] fix lint --- .../MoneyRequestConfirmationList.tsx | 36 +++++++++++++++++-- 1 file changed, 33 insertions(+), 3 deletions(-) diff --git a/src/components/MoneyRequestConfirmationList.tsx b/src/components/MoneyRequestConfirmationList.tsx index a5749f20121e..4992d2cfefa3 100755 --- a/src/components/MoneyRequestConfirmationList.tsx +++ b/src/components/MoneyRequestConfirmationList.tsx @@ -477,7 +477,21 @@ function MoneyRequestConfirmationList({ const distanceMerchant = DistanceRequestUtils.getDistanceMerchant(hasRoute, distance, unit, rate ?? 0, currency ?? CONST.CURRENCY.USD, translate, toLocaleDigit); IOU.setMoneyRequestMerchant(transactionID, distanceMerchant, true); - }, [isDistanceRequestWithPendingRoute, hasRoute, distance, unit, rate, currency, translate, toLocaleDigit, isDistanceRequest, transaction, action, isMovingTransactionFromTrackExpense]); + }, [ + isDistanceRequestWithPendingRoute, + hasRoute, + distance, + unit, + rate, + currency, + translate, + toLocaleDigit, + isDistanceRequest, + transaction, + transactionID, + action, + isMovingTransactionFromTrackExpense, + ]); // Auto select the category if there is only one enabled category and it is required useEffect(() => { @@ -784,7 +798,14 @@ function MoneyRequestConfirmationList({ numberOfLinesTitle={2} onPress={() => Navigation.navigate( - ROUTES.MONEY_REQUEST_STEP_CATEGORY.getRoute(action, iouType, transaction?.transactionID ?? '', reportID, Navigation.getActiveRouteWithoutParams()), + ROUTES.MONEY_REQUEST_STEP_CATEGORY.getRoute( + action, + iouType, + transaction?.transactionID ?? '', + reportID, + Navigation.getActiveRouteWithoutParams(), + reportActionID, + ), ) } style={[styles.moneyRequestMenuItem]} @@ -809,7 +830,15 @@ function MoneyRequestConfirmationList({ numberOfLinesTitle={2} onPress={() => Navigation.navigate( - ROUTES.MONEY_REQUEST_STEP_TAG.getRoute(action, iouType, index, transaction?.transactionID ?? '', reportID, Navigation.getActiveRouteWithoutParams()), + ROUTES.MONEY_REQUEST_STEP_TAG.getRoute( + action, + iouType, + index, + transaction?.transactionID ?? '', + reportID, + Navigation.getActiveRouteWithoutParams(), + reportActionID, + ), ) } style={[styles.moneyRequestMenuItem]} @@ -912,6 +941,7 @@ function MoneyRequestConfirmationList({ <ReceiptImage style={styles.moneyRequestImage} isThumbnail={isThumbnail} + // eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing source={resolvedThumbnail || resolvedReceiptImage || ''} // AuthToken is required when retrieving the image from the server // but we don't need it to load the blob:// or file:// image when starting a money request / split bill From 49b77e4ad8ab6b984e97c70b242bcf03ad6e27fa Mon Sep 17 00:00:00 2001 From: Shridhar Goel <35566748+ShridharGoel@users.noreply.github.com> Date: Wed, 17 Apr 2024 01:46:52 +0530 Subject: [PATCH 147/206] Lint fixes --- src/libs/ReportUtils.ts | 14 -------------- 1 file changed, 14 deletions(-) diff --git a/src/libs/ReportUtils.ts b/src/libs/ReportUtils.ts index e1ed1c0cca57..a166b83068cd 100644 --- a/src/libs/ReportUtils.ts +++ b/src/libs/ReportUtils.ts @@ -503,12 +503,6 @@ Onyx.connect({ callback: (value) => (allReports = value), }); -let doesDomainHaveApprovedAccountant = false; -Onyx.connect({ - key: ONYXKEYS.ACCOUNT, - callback: (value) => (doesDomainHaveApprovedAccountant = value?.doesDomainHaveApprovedAccountant ?? false), -}); - let allPolicies: OnyxCollection<Policy>; Onyx.connect({ key: ONYXKEYS.COLLECTION.POLICY, @@ -1072,14 +1066,6 @@ function canCreateTaskInReport(report: OnyxEntry<Report>): boolean { return true; } -/** - * Returns true if there are any Expensify accounts (i.e. with domain 'expensify.com') in the set of accountIDs - * by cross-referencing the accountIDs with personalDetails. - */ -function hasExpensifyEmails(accountIDs: number[]): boolean { - return accountIDs.some((accountID) => Str.extractEmailDomain(allPersonalDetails?.[accountID]?.login ?? '') === CONST.EXPENSIFY_PARTNER_NAME); -} - /** * Returns true if there are any guides accounts (team.expensify.com) in a list of accountIDs * by cross-referencing the accountIDs with personalDetails since guides that are participants From 450e43d4cd46efb91b3d1f5b82f4c8572d560aa2 Mon Sep 17 00:00:00 2001 From: brunovjk <brunovjk@gmail.com> Date: Tue, 16 Apr 2024 17:48:49 -0300 Subject: [PATCH 148/206] fix Edit Split Bill --- .../MoneyRequestConfirmationList.tsx | 49 ++++--------------- src/pages/iou/SplitBillDetailsPage.tsx | 2 +- 2 files changed, 10 insertions(+), 41 deletions(-) diff --git a/src/components/MoneyRequestConfirmationList.tsx b/src/components/MoneyRequestConfirmationList.tsx index 4992d2cfefa3..44c9df5ad560 100755 --- a/src/components/MoneyRequestConfirmationList.tsx +++ b/src/components/MoneyRequestConfirmationList.tsx @@ -684,7 +684,7 @@ function MoneyRequestConfirmationList({ return; } - Navigation.navigate(ROUTES.MONEY_REQUEST_STEP_AMOUNT.getRoute(action, iouType, transaction?.transactionID ?? '', reportID, Navigation.getActiveRouteWithoutParams())); + Navigation.navigate(ROUTES.MONEY_REQUEST_STEP_AMOUNT.getRoute(action, iouType, transactionID, reportID, Navigation.getActiveRouteWithoutParams())); }} style={[styles.moneyRequestMenuItem, styles.mt2]} titleStyle={styles.moneyRequestConfirmationAmount} @@ -706,7 +706,7 @@ function MoneyRequestConfirmationList({ description={translate('common.description')} onPress={() => { Navigation.navigate( - ROUTES.MONEY_REQUEST_STEP_DESCRIPTION.getRoute(action, iouType, transaction?.transactionID ?? '', reportID, Navigation.getActiveRouteWithoutParams()), + ROUTES.MONEY_REQUEST_STEP_DESCRIPTION.getRoute(action, iouType, transactionID, reportID, Navigation.getActiveRouteWithoutParams(), reportActionID), ); }} style={[styles.moneyRequestMenuItem]} @@ -728,11 +728,7 @@ function MoneyRequestConfirmationList({ description={translate('common.distance')} style={[styles.moneyRequestMenuItem]} titleStyle={styles.flex1} - onPress={() => - Navigation.navigate( - ROUTES.MONEY_REQUEST_STEP_DISTANCE.getRoute(action, iouType, transaction?.transactionID ?? '', reportID, Navigation.getActiveRouteWithoutParams()), - ) - } + onPress={() => Navigation.navigate(ROUTES.MONEY_REQUEST_STEP_DISTANCE.getRoute(action, iouType, transactionID, reportID, Navigation.getActiveRouteWithoutParams()))} // eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing disabled={didConfirm} // todo: handle edit for transaction while moving from track expense @@ -752,9 +748,7 @@ function MoneyRequestConfirmationList({ style={[styles.moneyRequestMenuItem]} titleStyle={styles.flex1} onPress={() => { - Navigation.navigate( - ROUTES.MONEY_REQUEST_STEP_MERCHANT.getRoute(action, iouType, transaction?.transactionID ?? '', reportID, Navigation.getActiveRouteWithoutParams()), - ); + Navigation.navigate(ROUTES.MONEY_REQUEST_STEP_MERCHANT.getRoute(action, iouType, transactionID, reportID, Navigation.getActiveRouteWithoutParams())); }} disabled={didConfirm} interactive={!isReadOnly} @@ -777,7 +771,7 @@ function MoneyRequestConfirmationList({ style={[styles.moneyRequestMenuItem]} titleStyle={styles.flex1} onPress={() => { - Navigation.navigate(ROUTES.MONEY_REQUEST_STEP_DATE.getRoute(action, iouType, transaction?.transactionID ?? '', reportID, Navigation.getActiveRouteWithoutParams())); + Navigation.navigate(ROUTES.MONEY_REQUEST_STEP_DATE.getRoute(action, iouType, transactionID, reportID, Navigation.getActiveRouteWithoutParams())); }} disabled={didConfirm} interactive={!isReadOnly} @@ -797,16 +791,7 @@ function MoneyRequestConfirmationList({ description={translate('common.category')} numberOfLinesTitle={2} onPress={() => - Navigation.navigate( - ROUTES.MONEY_REQUEST_STEP_CATEGORY.getRoute( - action, - iouType, - transaction?.transactionID ?? '', - reportID, - Navigation.getActiveRouteWithoutParams(), - reportActionID, - ), - ) + Navigation.navigate(ROUTES.MONEY_REQUEST_STEP_CATEGORY.getRoute(action, iouType, transactionID, reportID, Navigation.getActiveRouteWithoutParams(), reportActionID)) } style={[styles.moneyRequestMenuItem]} titleStyle={styles.flex1} @@ -830,15 +815,7 @@ function MoneyRequestConfirmationList({ numberOfLinesTitle={2} onPress={() => Navigation.navigate( - ROUTES.MONEY_REQUEST_STEP_TAG.getRoute( - action, - iouType, - index, - transaction?.transactionID ?? '', - reportID, - Navigation.getActiveRouteWithoutParams(), - reportActionID, - ), + ROUTES.MONEY_REQUEST_STEP_TAG.getRoute(action, iouType, index, transactionID, reportID, Navigation.getActiveRouteWithoutParams(), reportActionID), ) } style={[styles.moneyRequestMenuItem]} @@ -860,11 +837,7 @@ function MoneyRequestConfirmationList({ description={taxRates?.name} style={[styles.moneyRequestMenuItem]} titleStyle={styles.flex1} - onPress={() => - Navigation.navigate( - ROUTES.MONEY_REQUEST_STEP_TAX_RATE.getRoute(action, iouType, transaction?.transactionID ?? '', reportID, Navigation.getActiveRouteWithoutParams()), - ) - } + onPress={() => Navigation.navigate(ROUTES.MONEY_REQUEST_STEP_TAX_RATE.getRoute(action, iouType, transactionID, reportID, Navigation.getActiveRouteWithoutParams()))} disabled={didConfirm} interactive={!isReadOnly} /> @@ -881,11 +854,7 @@ function MoneyRequestConfirmationList({ description={translate('iou.taxAmount')} style={[styles.moneyRequestMenuItem]} titleStyle={styles.flex1} - onPress={() => - Navigation.navigate( - ROUTES.MONEY_REQUEST_STEP_TAX_AMOUNT.getRoute(action, iouType, transaction?.transactionID ?? '', reportID, Navigation.getActiveRouteWithoutParams()), - ) - } + onPress={() => Navigation.navigate(ROUTES.MONEY_REQUEST_STEP_TAX_AMOUNT.getRoute(action, iouType, transactionID, reportID, Navigation.getActiveRouteWithoutParams()))} disabled={didConfirm} interactive={!isReadOnly} /> diff --git a/src/pages/iou/SplitBillDetailsPage.tsx b/src/pages/iou/SplitBillDetailsPage.tsx index 91aa37dd01c2..b17eb1b615ba 100644 --- a/src/pages/iou/SplitBillDetailsPage.tsx +++ b/src/pages/iou/SplitBillDetailsPage.tsx @@ -59,7 +59,6 @@ function SplitBillDetailsPage({personalDetails, report, route, reportActions, tr const {translate} = useLocalize(); const reportAction = useMemo(() => reportActions?.[route.params.reportActionID] ?? ({} as ReportAction), [reportActions, route.params.reportActionID]); const participantAccountIDs = reportAction?.actionName === CONST.REPORT.ACTIONS.TYPE.IOU ? reportAction?.originalMessage.participantAccountIDs ?? [] : []; - // In case this is workspace split bill, we manually add the workspace as the second participant of the split bill // because we don't save any accountID in the report action's originalMessage other than the payee's accountID let participants: Array<Participant | ReportUtils.OptionData>; @@ -132,6 +131,7 @@ function SplitBillDetailsPage({personalDetails, report, route, reportActions, tr onConfirm={onConfirm} isPolicyExpenseChat={ReportUtils.isPolicyExpenseChat(report)} policyID={ReportUtils.isPolicyExpenseChat(report) ? report?.policyID : undefined} + action={isEditingSplitBill ? CONST.IOU.ACTION.EDIT : CONST.IOU.ACTION.CREATE} /> )} </View> From 6976dafde82668a32d3815d19cecfdcc2d5c3920 Mon Sep 17 00:00:00 2001 From: Bernhard Owen Josephus <bernhard.josephus@gmail.com> Date: Wed, 17 Apr 2024 14:19:43 +0800 Subject: [PATCH 149/206] remove unnecessary null safety --- src/pages/ReimbursementAccount/ReimbursementAccountPage.tsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/pages/ReimbursementAccount/ReimbursementAccountPage.tsx b/src/pages/ReimbursementAccount/ReimbursementAccountPage.tsx index 548a3de1967f..5950cc796e48 100644 --- a/src/pages/ReimbursementAccount/ReimbursementAccountPage.tsx +++ b/src/pages/ReimbursementAccount/ReimbursementAccountPage.tsx @@ -243,10 +243,10 @@ function ReimbursementAccountPage({ }, []); // The empty dependency array ensures this runs only once after the component mounts. useEffect(() => { - if (typeof reimbursementAccount?.isLoading !== 'boolean' || reimbursementAccount?.isLoading === prevIsReimbursementAccountLoading) { + if (typeof reimbursementAccount?.isLoading !== 'boolean' || reimbursementAccount.isLoading === prevIsReimbursementAccountLoading) { return; } - setIsReimbursementAccountLoading(reimbursementAccount?.isLoading); + setIsReimbursementAccountLoading(reimbursementAccount.isLoading); }, [prevIsReimbursementAccountLoading, reimbursementAccount?.isLoading]); useEffect( From 782ca78af04d32553e69af55ecf18b716f255c2c Mon Sep 17 00:00:00 2001 From: Shahe Shahinyan <shahe.shahinyan@gmail.com> Date: Wed, 17 Apr 2024 15:31:04 +0400 Subject: [PATCH 150/206] Comments addresed --- src/CONST.ts | 10 +++++----- src/libs/ReportUtils.ts | 2 +- src/pages/home/report/ReportActionItem.tsx | 2 +- src/types/onyx/OriginalMessage.ts | 4 ++-- 4 files changed, 9 insertions(+), 9 deletions(-) diff --git a/src/CONST.ts b/src/CONST.ts index 4713cee889ed..34006e22270c 100755 --- a/src/CONST.ts +++ b/src/CONST.ts @@ -640,7 +640,7 @@ const CONST = { CHANGE_FIELD: 'CHANGEFIELD', // OldDot Action CHANGE_POLICY: 'CHANGEPOLICY', // OldDot Action CHANGE_TYPE: 'CHANGETYPE', // OldDot Action - CHRONOS_OO_LIST: 'CHRONOSOOLIST', + CHRONOS_OOO_LIST: 'CHRONOSOOOLIST', CLOSED: 'CLOSED', CREATED: 'CREATED', DELEGATE_SUBMIT: 'DELEGATESUBMIT', // OldDot Action @@ -753,10 +753,10 @@ const CONST = { LEAVE_POLICY: 'POLICYCHANGELOG_LEAVE_POLICY', }, ROOM_CHANGE_LOG: { - INVITE_TO_ROOM: 'INVITE_TO_ROOM', - REMOVE_FROM_ROOM: 'REMOVE_FROM_ROOM', - LEAVE_ROOM: 'LEAVE_ROOM', - UPDATE_ROOM_DESCRIPTION: 'UPDATE_ROOM_DESCRIPTION', + INVITE_TO_ROOM: 'INVITETOROOM', + REMOVE_FROM_ROOM: 'REMOVEFROMROOM', + LEAVE_ROOM: 'LEAVEROOM', + UPDATE_ROOM_DESCRIPTION: 'UPDATEROOMDESCRIPTION', }, }, THREAD_DISABLED: ['CREATED'], diff --git a/src/libs/ReportUtils.ts b/src/libs/ReportUtils.ts index e8d860209ada..7227e1dff23f 100644 --- a/src/libs/ReportUtils.ts +++ b/src/libs/ReportUtils.ts @@ -4736,7 +4736,7 @@ function canFlagReportAction(reportAction: OnyxEntry<ReportAction>, reportID: st const isOriginalMessageHaveHtml = reportAction?.actionName === CONST.REPORT.ACTIONS.TYPE.ADD_COMMENT || reportAction?.actionName === CONST.REPORT.ACTIONS.TYPE.RENAMED || - reportAction?.actionName === CONST.REPORT.ACTIONS.TYPE.CHRONOS_OO_LIST; + reportAction?.actionName === CONST.REPORT.ACTIONS.TYPE.CHRONOS_OOO_LIST; if (ReportActionsUtils.isWhisperAction(reportAction)) { // Allow flagging welcome message whispers as they can be set by any room creator if (report?.description && !isCurrentUserAction && isOriginalMessageHaveHtml && reportAction?.originalMessage?.html === report.description) { diff --git a/src/pages/home/report/ReportActionItem.tsx b/src/pages/home/report/ReportActionItem.tsx index 8fd0b885791c..24165420ef44 100644 --- a/src/pages/home/report/ReportActionItem.tsx +++ b/src/pages/home/report/ReportActionItem.tsx @@ -793,7 +793,7 @@ function ReportActionItem({ if (action.actionName === CONST.REPORT.ACTIONS.TYPE.RENAMED) { return <RenameAction action={action} />; } - if (action.actionName === CONST.REPORT.ACTIONS.TYPE.CHRONOS_OO_LIST) { + if (action.actionName === CONST.REPORT.ACTIONS.TYPE.CHRONOS_OOO_LIST) { return ( <ChronosOOOListActions action={action} diff --git a/src/types/onyx/OriginalMessage.ts b/src/types/onyx/OriginalMessage.ts index a7d7c06f1bdb..9af132c3d1ec 100644 --- a/src/types/onyx/OriginalMessage.ts +++ b/src/types/onyx/OriginalMessage.ts @@ -8,7 +8,7 @@ type ActionName = DeepValueOf<typeof CONST.REPORT.ACTIONS.TYPE>; type OriginalMessageActionName = | 'ADDCOMMENT' | 'APPROVED' - | 'CHRONOSOOLIST' + | 'CHRONOSOOOLIST' | 'CLOSED' | 'CREATED' | 'HOLD' @@ -203,7 +203,7 @@ type ChronosOOOEvent = { }; type OriginalMessageChronosOOOList = { - actionName: typeof CONST.REPORT.ACTIONS.TYPE.CHRONOS_OO_LIST; + actionName: typeof CONST.REPORT.ACTIONS.TYPE.CHRONOS_OOO_LIST; originalMessage: { edits: string[]; events: ChronosOOOEvent[]; From 8a6de6127e5f652deaae0b639fa5391a3eada627 Mon Sep 17 00:00:00 2001 From: Shahe Shahinyan <shahe.shahinyan@gmail.com> Date: Wed, 17 Apr 2024 15:54:08 +0400 Subject: [PATCH 151/206] Correction of omissions --- src/libs/actions/IOU.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libs/actions/IOU.ts b/src/libs/actions/IOU.ts index 4ee8937233eb..6b3b84888fe1 100644 --- a/src/libs/actions/IOU.ts +++ b/src/libs/actions/IOU.ts @@ -291,7 +291,7 @@ function getReportPreviewAction(chatReportID: string, iouReportID: string): Onyx // Find the report preview action from the chat report return ( Object.values(reportActions).find( - (reportAction) => reportAction && reportAction.actionName === CONST.REPORT.ACTIONS.TYPE.REPORTPREVIEW && reportAction.originalMessage.linkedReportID === iouReportID, + (reportAction) => reportAction && reportAction.actionName === CONST.REPORT.ACTIONS.TYPE.REPORT_PREVIEW && reportAction.originalMessage.linkedReportID === iouReportID, ) ?? null ); } From 7ca64702dd3d453194243e87443a07307eb1d3ad Mon Sep 17 00:00:00 2001 From: Shahe Shahinyan <shahe.shahinyan@gmail.com> Date: Wed, 17 Apr 2024 15:59:17 +0400 Subject: [PATCH 152/206] Correction of omissions --- src/libs/ReportActionsUtils.ts | 2 +- src/libs/actions/Report.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/libs/ReportActionsUtils.ts b/src/libs/ReportActionsUtils.ts index 7c9ca250939b..a4ff8b87e35e 100644 --- a/src/libs/ReportActionsUtils.ts +++ b/src/libs/ReportActionsUtils.ts @@ -1081,7 +1081,7 @@ function isActionableJoinRequest(reportAction: OnyxEntry<ReportAction>): boolean } function isActionableTrackExpense(reportAction: OnyxEntry<ReportAction>): boolean { - return reportAction?.actionName === CONST.REPORT.ACTIONS.TYPE.ACTIONABLETRACKEXPENSEWHISPER; + return reportAction?.actionName === CONST.REPORT.ACTIONS.TYPE.ACTIONABLE_TRACK_EXPENSE_WHISPER; } /** diff --git a/src/libs/actions/Report.ts b/src/libs/actions/Report.ts index 3c70c7133741..a5c86f78620d 100644 --- a/src/libs/actions/Report.ts +++ b/src/libs/actions/Report.ts @@ -1045,7 +1045,7 @@ function markCommentAsUnread(reportID: string, reportActionCreated: string) { current.actorAccountID !== currentUserAccountID && (!latest || current.created > latest.created) && // Whisper action doesn't affect lastVisibleActionCreated, so skip whisper action except actionable mention whisper - (!ReportActionsUtils.isWhisperAction(current) || current.actionName === CONST.REPORT.ACTIONS.TYPE.ACTIONABLEMENTIONWHISPER) + (!ReportActionsUtils.isWhisperAction(current) || current.actionName === CONST.REPORT.ACTIONS.TYPE.ACTIONABLE_MENTION_WHISPER) ) { return current; } From c1fbad8c44073558aea51cd99cdf719e84d4a6d4 Mon Sep 17 00:00:00 2001 From: Bruno Rocha <95647348+brunovjk@users.noreply.github.com> Date: Wed, 17 Apr 2024 09:47:51 -0300 Subject: [PATCH 153/206] remove unnecessary lint comment Co-authored-by: Eric Han <117511920+eh2077@users.noreply.github.com> --- src/components/MoneyRequestConfirmationList.tsx | 1 - 1 file changed, 1 deletion(-) diff --git a/src/components/MoneyRequestConfirmationList.tsx b/src/components/MoneyRequestConfirmationList.tsx index a3a208b38185..dbe06a260491 100755 --- a/src/components/MoneyRequestConfirmationList.tsx +++ b/src/components/MoneyRequestConfirmationList.tsx @@ -730,7 +730,6 @@ function MoneyRequestConfirmationList({ style={[styles.moneyRequestMenuItem]} titleStyle={styles.flex1} onPress={() => Navigation.navigate(ROUTES.MONEY_REQUEST_STEP_DISTANCE.getRoute(action, iouType, transactionID, reportID, Navigation.getActiveRouteWithoutParams()))} - // eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing disabled={didConfirm} // todo: handle edit for transaction while moving from track expense interactive={!isReadOnly && !isMovingTransactionFromTrackExpense} From 6ca91ecad91e6593a64406ee125946166312eac1 Mon Sep 17 00:00:00 2001 From: Bruno Rocha <95647348+brunovjk@users.noreply.github.com> Date: Wed, 17 Apr 2024 09:49:33 -0300 Subject: [PATCH 154/206] apply nullish coalescing Co-authored-by: Eric Han <117511920+eh2077@users.noreply.github.com> --- src/components/MoneyRequestConfirmationList.tsx | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/components/MoneyRequestConfirmationList.tsx b/src/components/MoneyRequestConfirmationList.tsx index dbe06a260491..2e37036416f7 100755 --- a/src/components/MoneyRequestConfirmationList.tsx +++ b/src/components/MoneyRequestConfirmationList.tsx @@ -171,8 +171,7 @@ type MoneyRequestConfirmationListProps = MoneyRequestConfirmationListOnyxProps & }; const getTaxAmount = (transaction: OnyxEntry<OnyxTypes.Transaction>, defaultTaxValue: string) => { - // eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing - const percentage = (transaction?.taxRate ? transaction?.taxRate?.data?.value : defaultTaxValue) || ''; + const percentage = (transaction?.taxRate ? transaction?.taxRate?.data?.value : defaultTaxValue) ?? ''; return TransactionUtils.calculateTaxAmount(percentage, transaction?.amount ?? 0); }; From 895dd20b1123ec7df4760f0e28084ae87a6e95d1 Mon Sep 17 00:00:00 2001 From: Krishna Gupta <belivethatkg@gmail.com> Date: Wed, 17 Apr 2024 19:14:10 +0530 Subject: [PATCH 155/206] fix: wrong attachment corrupt alert for pdf. Signed-off-by: Krishna Gupta <belivethatkg@gmail.com> --- src/components/AttachmentPicker/index.native.tsx | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/components/AttachmentPicker/index.native.tsx b/src/components/AttachmentPicker/index.native.tsx index ef4d7e3e4064..865e79a8cd37 100644 --- a/src/components/AttachmentPicker/index.native.tsx +++ b/src/components/AttachmentPicker/index.native.tsx @@ -238,8 +238,7 @@ function AttachmentPicker({type = CONST.ATTACHMENT_PICKER_TYPE.FILE, children, s const validateAndCompleteAttachmentSelection = useCallback( (fileData: FileResponse) => { // Check if the file dimensions indicate corruption - // The width/height for corrupt file is -1 on android native and 0 on ios native - if (!fileData.width || !fileData.height || (fileData.width <= 0 && fileData.height <= 0)) { + if (fileData.width === -1 || fileData.height === -1) { showImageCorruptionAlert(); return Promise.resolve(); } @@ -287,6 +286,10 @@ function AttachmentPicker({type = CONST.ATTACHMENT_PICKER_TYPE.FILE, children, s if (fileDataName && Str.isImage(fileDataName)) { ImageSize.getSize(fileDataUri) .then(({width, height}) => { + // The width/height for corrupt file is -1 on android native and 0 on ios native + if (width <= 0 || height <= 0) { + throw new Error('Image dimensions are invalid.'); + } fileDataObject.width = width; fileDataObject.height = height; validateAndCompleteAttachmentSelection(fileDataObject); From 1b330657e5437c1a8a75381a466d2dba68526ce2 Mon Sep 17 00:00:00 2001 From: Wojciech Boman <wojciechboman@gmail.com> Date: Wed, 17 Apr 2024 17:50:51 +0200 Subject: [PATCH 156/206] Remove redundant const --- src/CONST.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/src/CONST.ts b/src/CONST.ts index 906e190b8ae8..9e1a0ba5d22c 100755 --- a/src/CONST.ts +++ b/src/CONST.ts @@ -3295,7 +3295,6 @@ const CONST = { NEW_ROOM: 'room', RECEIPT_TAB_ID: 'ReceiptTab', IOU_REQUEST_TYPE: 'iouRequestType', - SEARCH: 'search', }, TAB_REQUEST: { MANUAL: 'manual', From 2047184f38fd6e67ce40264e5ebbaa5973587172 Mon Sep 17 00:00:00 2001 From: Tim Golen <tgolen@expensify.com> Date: Wed, 17 Apr 2024 10:00:12 -0600 Subject: [PATCH 157/206] Specify the resolution when completing actionable whisper --- src/libs/actions/IOU.ts | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/libs/actions/IOU.ts b/src/libs/actions/IOU.ts index 3ce1edb36630..0f55c383111c 100644 --- a/src/libs/actions/IOU.ts +++ b/src/libs/actions/IOU.ts @@ -2486,6 +2486,7 @@ const getConvertTrackedExpenseInformation = ( linkedTrackedExpenseReportAction: OnyxTypes.ReportAction, linkedTrackedExpenseReportID: string, transactionThreadReportID: string, + resolution: ValueOf<typeof CONST.IOU.ACTION>, ) => { const optimisticData: OnyxUpdate[] = []; const successData: OnyxUpdate[] = []; @@ -2537,7 +2538,7 @@ const getConvertTrackedExpenseInformation = ( value: { [actionableWhisperReportActionID]: { originalMessage: { - resolution: CONST.REPORT.ACTIONABLE_MENTION_WHISPER_RESOLUTION.NOTHING, + resolution, }, }, }, @@ -2593,6 +2594,7 @@ function convertTrackedExpenseToRequest( linkedTrackedExpenseReportAction, linkedTrackedExpenseReportID, transactionThreadReportID, + CONST.IOU.ACTION.MOVE, ); optimisticData?.push(...moveTransactionOptimisticData); @@ -2659,6 +2661,7 @@ function categorizeTrackedExpense( linkedTrackedExpenseReportAction, linkedTrackedExpenseReportID, transactionThreadReportID, + CONST.IOU.ACTION.CATEGORIZE, ); optimisticData?.push(...moveTransactionOptimisticData); @@ -2728,6 +2731,7 @@ function shareTrackedExpense( linkedTrackedExpenseReportAction, linkedTrackedExpenseReportID, transactionThreadReportID, + CONST.IOU.ACTION.SHARE, ); optimisticData?.push(...moveTransactionOptimisticData); From 39a308a7d0922e4905b1d184fb6d74746c710905 Mon Sep 17 00:00:00 2001 From: Wojciech Boman <wojciechboman@gmail.com> Date: Wed, 17 Apr 2024 18:00:20 +0200 Subject: [PATCH 158/206] Remove test code from TabSelector --- src/components/TabSelector/TabSelector.tsx | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/src/components/TabSelector/TabSelector.tsx b/src/components/TabSelector/TabSelector.tsx index 00ecd41beb08..fc19e6a8062e 100644 --- a/src/components/TabSelector/TabSelector.tsx +++ b/src/components/TabSelector/TabSelector.tsx @@ -33,16 +33,6 @@ function getIconAndTitle(route: string, translate: LocaleContextProps['translate return {icon: Expensicons.Hashtag, title: translate('tabSelector.room')}; case CONST.TAB_REQUEST.DISTANCE: return {icon: Expensicons.Car, title: translate('common.distance')}; - case CONST.TAB_SEARCH.ALL: - return {icon: Expensicons.ExpensifyLogoNew, title: 'All'}; - case CONST.TAB_SEARCH.SENT: - return {icon: Expensicons.ExpensifyLogoNew, title: 'Sent'}; - case CONST.TAB_SEARCH.DRAFTS: - return {icon: Expensicons.ExpensifyLogoNew, title: 'Drafts'}; - case CONST.TAB_SEARCH.WAITING_ON_YOU: - return {icon: Expensicons.ExpensifyLogoNew, title: 'Waiting on you'}; - case CONST.TAB_SEARCH.FINISHED: - return {icon: Expensicons.ExpensifyLogoNew, title: 'Finished'}; default: throw new Error(`Route ${route} has no icon nor title set.`); } From 0c538bb9651cf00fa86ad084e1e68dc01229867d Mon Sep 17 00:00:00 2001 From: Wojciech Boman <wojciechboman@gmail.com> Date: Wed, 17 Apr 2024 18:04:25 +0200 Subject: [PATCH 159/206] Refactor createCustomStackNavigator --- .../AppNavigator/createCustomStackNavigator/index.tsx | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/libs/Navigation/AppNavigator/createCustomStackNavigator/index.tsx b/src/libs/Navigation/AppNavigator/createCustomStackNavigator/index.tsx index 767190bb1967..29b9b1072d3d 100644 --- a/src/libs/Navigation/AppNavigator/createCustomStackNavigator/index.tsx +++ b/src/libs/Navigation/AppNavigator/createCustomStackNavigator/index.tsx @@ -4,6 +4,7 @@ import type {StackNavigationEventMap, StackNavigationOptions} from '@react-navig import {StackView} from '@react-navigation/stack'; import React, {useEffect, useMemo} from 'react'; import {View} from 'react-native'; +import useThemeStyles from '@hooks/useThemeStyles'; import useWindowDimensions from '@hooks/useWindowDimensions'; import getTopmostCentralPaneRoute from '@libs/Navigation/getTopmostCentralPaneRoute'; import navigationRef from '@libs/Navigation/navigationRef'; @@ -36,6 +37,7 @@ function reduceCentralPaneRoutes(routes: Routes): Routes { function ResponsiveStackNavigator(props: ResponsiveStackNavigatorProps) { const {isSmallScreenWidth} = useWindowDimensions(); + const styles = useThemeStyles(); const {navigation, state, descriptors, NavigationContent} = useNavigationBuilder< StackNavigationState<ParamListBase>, @@ -64,6 +66,7 @@ function ResponsiveStackNavigator(props: ResponsiveStackNavigatorProps) { const firstRoute = routes[0]; + // On narrow layout, if we are on /search route we want to hide all central pane routes and show only the bottom tab navigator. if (isSmallScreenWidth && isLastRouteSearchRoute) { return { stateToRender: { @@ -94,7 +97,7 @@ function ResponsiveStackNavigator(props: ResponsiveStackNavigatorProps) { descriptors={descriptors} navigation={navigation} /> - {searchRoute && <View style={{display: 'none'}}>{descriptors[searchRoute.key].render()}</View>} + {searchRoute && <View style={styles.dNone}>{descriptors[searchRoute.key].render()}</View>} </NavigationContent> ); } From 85e5e923dd5d590e585118ccc82aa8db233a425d Mon Sep 17 00:00:00 2001 From: Tim Golen <tgolen@expensify.com> Date: Wed, 17 Apr 2024 10:06:38 -0600 Subject: [PATCH 160/206] Rename "move" to "request" --- src/CONST.ts | 2 +- src/libs/IOUUtils.ts | 4 ++-- src/libs/actions/IOU.ts | 4 ++-- src/pages/home/report/ReportActionItem.tsx | 2 +- .../MoneyTemporaryForRefactorRequestParticipantsSelector.js | 4 ++-- src/pages/iou/request/step/IOURequestStepConfirmation.tsx | 2 +- src/pages/iou/request/step/IOURequestStepParticipants.tsx | 2 +- 7 files changed, 10 insertions(+), 10 deletions(-) diff --git a/src/CONST.ts b/src/CONST.ts index eba68999cc39..d2173fd31ee9 100755 --- a/src/CONST.ts +++ b/src/CONST.ts @@ -1411,7 +1411,7 @@ const CONST = { ACTION: { EDIT: 'edit', CREATE: 'create', - MOVE: 'move', + REQUEST: 'request', CATEGORIZE: 'categorize', SHARE: 'share', }, diff --git a/src/libs/IOUUtils.ts b/src/libs/IOUUtils.ts index 27af031d19a8..c21152ea310d 100644 --- a/src/libs/IOUUtils.ts +++ b/src/libs/IOUUtils.ts @@ -15,7 +15,7 @@ function navigateToStartMoneyRequestStep( reportID: string, iouAction?: ValueOf<typeof CONST.IOU.ACTION>, ): void { - if (iouAction === CONST.IOU.ACTION.CATEGORIZE || iouAction === CONST.IOU.ACTION.MOVE) { + if (iouAction === CONST.IOU.ACTION.CATEGORIZE || iouAction === CONST.IOU.ACTION.REQUEST) { Navigation.goBack(); return; } @@ -135,7 +135,7 @@ function insertTagIntoTransactionTagsString(transactionTags: string, tag: string } function isMovingTransactionFromTrackExpense(action?: ValueOf<typeof CONST.IOU.ACTION>) { - if (action === CONST.IOU.ACTION.MOVE || action === CONST.IOU.ACTION.SHARE || action === CONST.IOU.ACTION.CATEGORIZE) { + if (action === CONST.IOU.ACTION.REQUEST || action === CONST.IOU.ACTION.SHARE || action === CONST.IOU.ACTION.CATEGORIZE) { return true; } diff --git a/src/libs/actions/IOU.ts b/src/libs/actions/IOU.ts index 0f55c383111c..3a6ab2a0ae8b 100644 --- a/src/libs/actions/IOU.ts +++ b/src/libs/actions/IOU.ts @@ -2594,7 +2594,7 @@ function convertTrackedExpenseToRequest( linkedTrackedExpenseReportAction, linkedTrackedExpenseReportID, transactionThreadReportID, - CONST.IOU.ACTION.MOVE, + CONST.IOU.ACTION.REQUEST, ); optimisticData?.push(...moveTransactionOptimisticData); @@ -2835,7 +2835,7 @@ function requestMoney( const activeReportID = isMoneyRequestReport ? report?.reportID : chatReport.reportID; switch (action) { - case CONST.IOU.ACTION.MOVE: { + case CONST.IOU.ACTION.REQUEST: { if (!linkedTrackedExpenseReportAction || !actionableWhisperReportActionID || !linkedTrackedExpenseReportID) { return; } diff --git a/src/pages/home/report/ReportActionItem.tsx b/src/pages/home/report/ReportActionItem.tsx index a23f3bab8dc8..3313bf0413be 100644 --- a/src/pages/home/report/ReportActionItem.tsx +++ b/src/pages/home/report/ReportActionItem.tsx @@ -393,7 +393,7 @@ function ReportActionItem({ text: 'actionableMentionTrackExpense.request', key: `${action.reportActionID}-actionableMentionTrackExpense-request`, onPress: () => { - ReportUtils.createDraftTransactionAndNavigateToParticipantSelector(transactionID, report.reportID, CONST.IOU.ACTION.MOVE, action.reportActionID); + ReportUtils.createDraftTransactionAndNavigateToParticipantSelector(transactionID, report.reportID, CONST.IOU.ACTION.REQUEST, action.reportActionID); }, isMediumSized: true, }, diff --git a/src/pages/iou/request/MoneyTemporaryForRefactorRequestParticipantsSelector.js b/src/pages/iou/request/MoneyTemporaryForRefactorRequestParticipantsSelector.js index 87883972f84f..5ab487a6e77f 100644 --- a/src/pages/iou/request/MoneyTemporaryForRefactorRequestParticipantsSelector.js +++ b/src/pages/iou/request/MoneyTemporaryForRefactorRequestParticipantsSelector.js @@ -109,7 +109,7 @@ function MoneyTemporaryForRefactorRequestParticipantsSelector({participants, onF // If we are using this component in the "Request money" flow then we pass the includeOwnedWorkspaceChats argument so that the current user // sees the option to request money from their admin on their own Workspace Chat. - iouType === CONST.IOU.TYPE.REQUEST && action !== CONST.IOU.ACTION.MOVE, + iouType === CONST.IOU.TYPE.REQUEST && action !== CONST.IOU.ACTION.REQUEST, (canUseP2PDistanceRequests || iouRequestType !== CONST.IOU.REQUEST_TYPE.DISTANCE) && ![CONST.IOU.ACTION.CATEGORIZE, CONST.IOU.ACTION.SHARE].includes(action), false, @@ -267,7 +267,7 @@ function MoneyTemporaryForRefactorRequestParticipantsSelector({participants, onF (canUseP2PDistanceRequests || iouRequestType !== CONST.IOU.REQUEST_TYPE.DISTANCE) && iouType !== CONST.IOU.TYPE.SEND && iouType !== CONST.IOU.TYPE.TRACK_EXPENSE && - ![CONST.IOU.ACTION.SHARE, CONST.IOU.ACTION.MOVE, CONST.IOU.ACTION.CATEGORIZE].includes(action); + ![CONST.IOU.ACTION.SHARE, CONST.IOU.ACTION.REQUEST, CONST.IOU.ACTION.CATEGORIZE].includes(action); const handleConfirmSelection = useCallback( (keyEvent, option) => { diff --git a/src/pages/iou/request/step/IOURequestStepConfirmation.tsx b/src/pages/iou/request/step/IOURequestStepConfirmation.tsx index 46e663956e4a..1c3a7d7c3f0c 100644 --- a/src/pages/iou/request/step/IOURequestStepConfirmation.tsx +++ b/src/pages/iou/request/step/IOURequestStepConfirmation.tsx @@ -77,7 +77,7 @@ function IOURequestStepConfirmation({ const transactionTaxAmount = transaction?.taxAmount; const isSharingTrackExpense = action === CONST.IOU.ACTION.SHARE; const isCategorizingTrackExpense = action === CONST.IOU.ACTION.CATEGORIZE; - const isRequestingFromTrackExpense = action === CONST.IOU.ACTION.MOVE; + const isRequestingFromTrackExpense = action === CONST.IOU.ACTION.REQUEST; const requestType = TransactionUtils.getRequestType(transaction); diff --git a/src/pages/iou/request/step/IOURequestStepParticipants.tsx b/src/pages/iou/request/step/IOURequestStepParticipants.tsx index 5d81a7711cad..158050e8bbf6 100644 --- a/src/pages/iou/request/step/IOURequestStepParticipants.tsx +++ b/src/pages/iou/request/step/IOURequestStepParticipants.tsx @@ -50,7 +50,7 @@ function IOURequestStepParticipants({ if (action === CONST.IOU.ACTION.CATEGORIZE) { return translate('iou.categorize'); } - if (action === CONST.IOU.ACTION.MOVE) { + if (action === CONST.IOU.ACTION.REQUEST) { return translate('iou.request'); } if (action === CONST.IOU.ACTION.SHARE) { From b7deeb7d63b990628aa7c1cd70fa0610fe83fffe Mon Sep 17 00:00:00 2001 From: Tim Golen <tgolen@expensify.com> Date: Wed, 17 Apr 2024 10:06:45 -0600 Subject: [PATCH 161/206] Remove unused reference --- src/CONST.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/src/CONST.ts b/src/CONST.ts index d2173fd31ee9..b5a5a7797b52 100755 --- a/src/CONST.ts +++ b/src/CONST.ts @@ -1436,7 +1436,6 @@ const CONST = { DELETE: 'delete', APPROVE: 'approve', TRACK: 'track', - MOVE: 'move', }, AMOUNT_MAX_LENGTH: 10, RECEIPT_STATE: { From 3cb9dbe7b370b54b341d4f60244c2f3a28946b80 Mon Sep 17 00:00:00 2001 From: Wojciech Boman <wojciechboman@gmail.com> Date: Wed, 17 Apr 2024 18:08:12 +0200 Subject: [PATCH 162/206] Refactor search pages --- src/pages/Search/SearchPage.tsx | 2 +- src/pages/Search/SearchPageBottomTab.tsx | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/pages/Search/SearchPage.tsx b/src/pages/Search/SearchPage.tsx index 971705351cd2..3f69371841ce 100644 --- a/src/pages/Search/SearchPage.tsx +++ b/src/pages/Search/SearchPage.tsx @@ -12,7 +12,7 @@ function SearchPage({route}: SearchPageProps) { useCustomBackHandler(); return ( - <ScreenWrapper testID="testPage"> + <ScreenWrapper testID={SearchPage.displayName}> <SearchResults query={route.params.query} /> </ScreenWrapper> ); diff --git a/src/pages/Search/SearchPageBottomTab.tsx b/src/pages/Search/SearchPageBottomTab.tsx index 797add51b4b5..62413d743d76 100644 --- a/src/pages/Search/SearchPageBottomTab.tsx +++ b/src/pages/Search/SearchPageBottomTab.tsx @@ -42,7 +42,7 @@ function SearchPageBottomTab() { ]; return ( - <ScreenWrapper testID="testPage"> + <ScreenWrapper testID={SearchPageBottomTab.displayName}> <View style={[styles.pb4, styles.mh3, styles.mt3]}> {searchMenuItems.map((item) => ( <MenuItem @@ -63,6 +63,6 @@ function SearchPageBottomTab() { ); } -SearchPageBottomTab.displayName = 'SearchPage'; +SearchPageBottomTab.displayName = 'SearchPageBottomTab'; export default SearchPageBottomTab; From faf9a691a73a8529f97659cf95065fdb10f57213 Mon Sep 17 00:00:00 2001 From: Wojciech Boman <wojciechboman@gmail.com> Date: Wed, 17 Apr 2024 18:27:20 +0200 Subject: [PATCH 163/206] Remove unused code --- src/ROUTES.ts | 5 ----- src/SCREENS.ts | 2 -- .../ModalStackNavigators/index.tsx | 6 ------ .../Navigators/RightModalNavigator.tsx | 4 ---- .../BottomTabBar.tsx | 21 ------------------- src/libs/Navigation/linkingConfig/config.ts | 5 ----- src/libs/Navigation/types.ts | 9 -------- 7 files changed, 52 deletions(-) diff --git a/src/ROUTES.ts b/src/ROUTES.ts index cee554f34c4d..a9978c49767c 100644 --- a/src/ROUTES.ts +++ b/src/ROUTES.ts @@ -27,11 +27,6 @@ const ROUTES = { getRoute: (query: string) => `search/${query}` as const, }, - SEARCH_REPORT: { - route: '/search/:query/view/:reportID', - getRoute: (query: string, reportID: string) => `search/${query}/view/${reportID}` as const, - }, - // This is a utility route used to go to the user's concierge chat, or the sign-in page if the user's not authenticated CONCIERGE: 'concierge', FLAG_COMMENT: { diff --git a/src/SCREENS.ts b/src/SCREENS.ts index 0b654fe65809..a816103f2f80 100644 --- a/src/SCREENS.ts +++ b/src/SCREENS.ts @@ -25,7 +25,6 @@ const SCREENS = { WORKSPACES_CENTRAL_PANE: 'WorkspacesCentralPane', SEARCH: { CENTRAL_PANE: 'Search_Central_Pane', - REPORT: 'Search_Report', BOTTOM_TAB: 'Search_Bottom_Tab', }, SETTINGS: { @@ -132,7 +131,6 @@ const SCREENS = { ROOM_INVITE: 'RoomInvite', REFERRAL: 'Referral', PROCESS_MONEY_REQUEST_HOLD: 'ProcessMoneyRequestHold', - SEARCH_REPORT: 'Search_Report', }, ONBOARDING_MODAL: { ONBOARDING: 'Onboarding', diff --git a/src/libs/Navigation/AppNavigator/ModalStackNavigators/index.tsx b/src/libs/Navigation/AppNavigator/ModalStackNavigators/index.tsx index 0a53dcf6d468..3b295f652b88 100644 --- a/src/libs/Navigation/AppNavigator/ModalStackNavigators/index.tsx +++ b/src/libs/Navigation/AppNavigator/ModalStackNavigators/index.tsx @@ -23,7 +23,6 @@ import type { ReportSettingsNavigatorParamList, RoomInviteNavigatorParamList, RoomMembersNavigatorParamList, - SearchReportParamList, SettingsNavigatorParamList, SignInNavigatorParamList, SplitDetailsNavigatorParamList, @@ -148,10 +147,6 @@ const RoomInviteModalStackNavigator = createModalStackNavigator<RoomInviteNaviga [SCREENS.ROOM_INVITE_ROOT]: () => require('../../../../pages/RoomInvitePage').default as React.ComponentType, }); -const SearchReportModalStackNavigator = createModalStackNavigator<SearchReportParamList>({ - [SCREENS.SEARCH.REPORT]: () => require('../../../../pages/home/ReportScreen').default as React.ComponentType, -}); - const ChatFinderModalStackNavigator = createModalStackNavigator<ChatFinderNavigatorParamList>({ [SCREENS.CHAT_FINDER_ROOT]: () => require('../../../../pages/ChatFinderPage').default as React.ComponentType, }); @@ -355,5 +350,4 @@ export { WalletStatementStackNavigator, ProcessMoneyRequestHoldStackNavigator, WorkspaceSettingsModalStackNavigator, - SearchReportModalStackNavigator, }; diff --git a/src/libs/Navigation/AppNavigator/Navigators/RightModalNavigator.tsx b/src/libs/Navigation/AppNavigator/Navigators/RightModalNavigator.tsx index 3d3fb569f69f..c421bdc82028 100644 --- a/src/libs/Navigation/AppNavigator/Navigators/RightModalNavigator.tsx +++ b/src/libs/Navigation/AppNavigator/Navigators/RightModalNavigator.tsx @@ -137,10 +137,6 @@ function RightModalNavigator({navigation}: RightModalNavigatorProps) { name="ProcessMoneyRequestHold" component={ModalStackNavigators.ProcessMoneyRequestHoldStackNavigator} /> - <Stack.Screen - name={SCREENS.RIGHT_MODAL.SEARCH_REPORT} - component={ModalStackNavigators.SearchReportModalStackNavigator} - /> </Stack.Navigator> </View> </NoDropZone> diff --git a/src/libs/Navigation/AppNavigator/createCustomBottomTabNavigator/BottomTabBar.tsx b/src/libs/Navigation/AppNavigator/createCustomBottomTabNavigator/BottomTabBar.tsx index 0f2f3d2b0ce6..02bfda6ba51b 100644 --- a/src/libs/Navigation/AppNavigator/createCustomBottomTabNavigator/BottomTabBar.tsx +++ b/src/libs/Navigation/AppNavigator/createCustomBottomTabNavigator/BottomTabBar.tsx @@ -102,27 +102,6 @@ function BottomTabBar({isLoadingApp = false}: PurposeForUsingExpensifyModalProps </View> </PressableWithFeedback> </Tooltip> - {/** @TODO: Uncomment this code and change order of the items according to the designs once the new search tab is ready */} - {/* <Tooltip text={translate('common.search')}> - <PressableWithFeedback - onPress={() => { - Navigation.navigate(ROUTES.SEARCH.getRoute(CONST.TAB_SEARCH.ALL)); - }} - role={CONST.ROLE.BUTTON} - accessibilityLabel={translate('common.search')} - wrapperStyle={styles.flex1} - style={styles.bottomTabBarItem} - > - <View> - <Icon - src={Expensicons.ReceiptSearch} - fill={currentTabName === SCREENS.SEARCH.CENTRAL_PANE ? theme.iconMenu : theme.icon} - width={variables.iconBottomBar} - height={variables.iconBottomBar} - /> - </View> - </PressableWithFeedback> - </Tooltip> */} <BottomTabBarFloatingActionButton /> <BottomTabAvatar isSelected={currentTabName === SCREENS.SETTINGS.ROOT} /> </View> diff --git a/src/libs/Navigation/linkingConfig/config.ts b/src/libs/Navigation/linkingConfig/config.ts index 9d41e6fd7bf8..add3e42c0177 100644 --- a/src/libs/Navigation/linkingConfig/config.ts +++ b/src/libs/Navigation/linkingConfig/config.ts @@ -638,11 +638,6 @@ const config: LinkingOptions<RootStackParamList>['config'] = { [SCREENS.PROCESS_MONEY_REQUEST_HOLD_ROOT]: ROUTES.PROCESS_MONEY_REQUEST_HOLD, }, }, - [SCREENS.RIGHT_MODAL.SEARCH_REPORT]: { - screens: { - [SCREENS.SEARCH.REPORT]: ROUTES.SEARCH_REPORT.route, - }, - }, }, }, diff --git a/src/libs/Navigation/types.ts b/src/libs/Navigation/types.ts index dd4189518886..5aff6ba1cba5 100644 --- a/src/libs/Navigation/types.ts +++ b/src/libs/Navigation/types.ts @@ -621,13 +621,6 @@ type LeftModalNavigatorParamList = { [SCREENS.LEFT_MODAL.WORKSPACE_SWITCHER]: NavigatorScreenParams<WorkspaceSwitcherNavigatorParamList>; }; -type SearchReportParamList = { - [SCREENS.SEARCH.REPORT]: { - query: string; - reportID: string; - }; -}; - type RightModalNavigatorParamList = { [SCREENS.RIGHT_MODAL.SETTINGS]: NavigatorScreenParams<SettingsNavigatorParamList>; [SCREENS.RIGHT_MODAL.NEW_CHAT]: NavigatorScreenParams<NewChatNavigatorParamList>; @@ -655,7 +648,6 @@ type RightModalNavigatorParamList = { [SCREENS.RIGHT_MODAL.PROCESS_MONEY_REQUEST_HOLD]: NavigatorScreenParams<ProcessMoneyRequestHoldNavigatorParamList>; [SCREENS.RIGHT_MODAL.REFERRAL]: NavigatorScreenParams<ReferralDetailsNavigatorParamList>; [SCREENS.RIGHT_MODAL.PRIVATE_NOTES]: NavigatorScreenParams<PrivateNotesNavigatorParamList>; - [SCREENS.RIGHT_MODAL.SEARCH_REPORT]: NavigatorScreenParams<SearchReportParamList>; }; type WorkspacesCentralPaneNavigatorParamList = { @@ -867,5 +859,4 @@ export type { FullScreenNavigatorParamList, WorkspacesCentralPaneNavigatorParamList, BackToParams, - SearchReportParamList, }; From 87a4076c73fec5a2ba8bcdbadae5307b9659d4f3 Mon Sep 17 00:00:00 2001 From: Wojciech Boman <wojciechboman@gmail.com> Date: Wed, 17 Apr 2024 18:29:32 +0200 Subject: [PATCH 164/206] Remove unused code --- src/libs/Navigation/linkingConfig/CENTRAL_PANE_TO_RHP_MAPPING.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/src/libs/Navigation/linkingConfig/CENTRAL_PANE_TO_RHP_MAPPING.ts b/src/libs/Navigation/linkingConfig/CENTRAL_PANE_TO_RHP_MAPPING.ts index 1db8738bc9a5..3407656c5e94 100755 --- a/src/libs/Navigation/linkingConfig/CENTRAL_PANE_TO_RHP_MAPPING.ts +++ b/src/libs/Navigation/linkingConfig/CENTRAL_PANE_TO_RHP_MAPPING.ts @@ -38,7 +38,6 @@ const CENTRAL_PANE_TO_RHP_MAPPING: Partial<Record<CentralPaneName, string[]>> = [SCREENS.SETTINGS.ABOUT]: [SCREENS.SETTINGS.APP_DOWNLOAD_LINKS], [SCREENS.SETTINGS.SAVE_THE_WORLD]: [SCREENS.I_KNOW_A_TEACHER, SCREENS.INTRO_SCHOOL_PRINCIPAL, SCREENS.I_AM_A_TEACHER], [SCREENS.SETTINGS.TROUBLESHOOT]: [SCREENS.SETTINGS.CONSOLE], - [SCREENS.SEARCH.CENTRAL_PANE]: [SCREENS.SEARCH.REPORT], }; export default CENTRAL_PANE_TO_RHP_MAPPING; From 725222ea2b38dd1b27ea6561fe83ae7dd81b5ba7 Mon Sep 17 00:00:00 2001 From: Rushat Gabhane <rushatgabhane@gmail.com> Date: Wed, 17 Apr 2024 19:29:50 +0300 Subject: [PATCH 165/206] Update README.md --- README.md | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/README.md b/README.md index 026a63606db0..2c2faf0e7d9b 100644 --- a/README.md +++ b/README.md @@ -82,6 +82,17 @@ If you want to run the app on an actual physical iOS device, please follow the i ## Running the MacOS desktop app 🖥 * To run the **Development app**, run: `npm run desktop`, this will start a new Electron process running on your MacOS desktop in the `dist/Mac` folder. +## Receiving Notifications +To receive notifications on development build of the app, you need to use the production airship config. +### Android +1. Copy the [production config](https://github.com/Expensify/App/blob/d7c1256f952c0020344d809ee7299b49a4c70db2/android/app/src/main/assets/airshipconfig.properties#L1-L7) to the [development config](https://github.com/Expensify/App/blob/d7c1256f952c0020344d809ee7299b49a4c70db2/android/app/src/development/assets/airshipconfig.properties#L1-L8). +2. Rebuild the app. + +### iOS +1. Replace the [development key and secret](https://github.com/Expensify/App/blob/d7c1256f952c0020344d809ee7299b49a4c70db2/ios/AirshipConfig.plist#L7-L10) with the [production values](https://github.com/Expensify/App/blob/d7c1256f952c0020344d809ee7299b49a4c70db2/ios/AirshipConfig.plist#L11-L14). +2. Rebuild the app. + + ## Troubleshooting 1. If you are having issues with **_Getting Started_**, please reference [React Native's Documentation](https://reactnative.dev/docs/environment-setup) 2. If you are running into CORS errors like (in the browser dev console) From 2fab2ffc65d31184542543f8d7c6749758fe94b2 Mon Sep 17 00:00:00 2001 From: Tim Golen <tgolen@expensify.com> Date: Wed, 17 Apr 2024 10:30:21 -0600 Subject: [PATCH 166/206] Make the type a little more strict --- src/libs/actions/IOU.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libs/actions/IOU.ts b/src/libs/actions/IOU.ts index 3a6ab2a0ae8b..4fbfcc3bac5a 100644 --- a/src/libs/actions/IOU.ts +++ b/src/libs/actions/IOU.ts @@ -2486,7 +2486,7 @@ const getConvertTrackedExpenseInformation = ( linkedTrackedExpenseReportAction: OnyxTypes.ReportAction, linkedTrackedExpenseReportID: string, transactionThreadReportID: string, - resolution: ValueOf<typeof CONST.IOU.ACTION>, + resolution: Omit<ValueOf<typeof CONST.IOU.ACTION>, 'edit' | 'create'>, ) => { const optimisticData: OnyxUpdate[] = []; const successData: OnyxUpdate[] = []; From d2a38a211ea777d04ed09897bfe53f526efa05ed Mon Sep 17 00:00:00 2001 From: Rushat Gabhane <rushatgabhane@gmail.com> Date: Wed, 17 Apr 2024 19:34:39 +0300 Subject: [PATCH 167/206] Update README.md --- README.md | 1 - 1 file changed, 1 deletion(-) diff --git a/README.md b/README.md index 2c2faf0e7d9b..e493e4678d6f 100644 --- a/README.md +++ b/README.md @@ -92,7 +92,6 @@ To receive notifications on development build of the app, you need to use the pr 1. Replace the [development key and secret](https://github.com/Expensify/App/blob/d7c1256f952c0020344d809ee7299b49a4c70db2/ios/AirshipConfig.plist#L7-L10) with the [production values](https://github.com/Expensify/App/blob/d7c1256f952c0020344d809ee7299b49a4c70db2/ios/AirshipConfig.plist#L11-L14). 2. Rebuild the app. - ## Troubleshooting 1. If you are having issues with **_Getting Started_**, please reference [React Native's Documentation](https://reactnative.dev/docs/environment-setup) 2. If you are running into CORS errors like (in the browser dev console) From 484344fc4d8672d434f407477bb8b5012416a600 Mon Sep 17 00:00:00 2001 From: Krishna Gupta <belivethatkg@gmail.com> Date: Wed, 17 Apr 2024 22:43:37 +0530 Subject: [PATCH 168/206] placed validating the dimensions in one place. Signed-off-by: Krishna Gupta <belivethatkg@gmail.com> --- src/components/AttachmentPicker/index.native.tsx | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/src/components/AttachmentPicker/index.native.tsx b/src/components/AttachmentPicker/index.native.tsx index 865e79a8cd37..5e54458da001 100644 --- a/src/components/AttachmentPicker/index.native.tsx +++ b/src/components/AttachmentPicker/index.native.tsx @@ -238,7 +238,9 @@ function AttachmentPicker({type = CONST.ATTACHMENT_PICKER_TYPE.FILE, children, s const validateAndCompleteAttachmentSelection = useCallback( (fileData: FileResponse) => { // Check if the file dimensions indicate corruption - if (fileData.width === -1 || fileData.height === -1) { + // The width/height for a corrupted file is -1 on android native and 0 on ios native + // We must check only numeric values because the width/height can be undefined for non-image files + if ((typeof fileData.width === 'number' && fileData.width <= 0) || (typeof fileData.height === 'number' && fileData.height <= 0)) { showImageCorruptionAlert(); return Promise.resolve(); } @@ -286,10 +288,6 @@ function AttachmentPicker({type = CONST.ATTACHMENT_PICKER_TYPE.FILE, children, s if (fileDataName && Str.isImage(fileDataName)) { ImageSize.getSize(fileDataUri) .then(({width, height}) => { - // The width/height for corrupt file is -1 on android native and 0 on ios native - if (width <= 0 || height <= 0) { - throw new Error('Image dimensions are invalid.'); - } fileDataObject.width = width; fileDataObject.height = height; validateAndCompleteAttachmentSelection(fileDataObject); From db01cf5b4aa52069cf416d7a1a84ea3bdbfeea8f Mon Sep 17 00:00:00 2001 From: Rushat Gabhane <rushatgabhane@gmail.com> Date: Wed, 17 Apr 2024 23:20:00 +0530 Subject: [PATCH 169/206] Update README.md Co-authored-by: Andrew Gable <andrewgable@gmail.com> --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index e493e4678d6f..8adadfc9cbe6 100644 --- a/README.md +++ b/README.md @@ -83,7 +83,7 @@ If you want to run the app on an actual physical iOS device, please follow the i * To run the **Development app**, run: `npm run desktop`, this will start a new Electron process running on your MacOS desktop in the `dist/Mac` folder. ## Receiving Notifications -To receive notifications on development build of the app, you need to use the production airship config. +To receive notifications on development build of the app while hitting the Staging or Production API, you need to use the production airship config. ### Android 1. Copy the [production config](https://github.com/Expensify/App/blob/d7c1256f952c0020344d809ee7299b49a4c70db2/android/app/src/main/assets/airshipconfig.properties#L1-L7) to the [development config](https://github.com/Expensify/App/blob/d7c1256f952c0020344d809ee7299b49a4c70db2/android/app/src/development/assets/airshipconfig.properties#L1-L8). 2. Rebuild the app. From aece8dbc26f559fad95c4921a458a90f3a5891dc Mon Sep 17 00:00:00 2001 From: Kevin Brian Bader <kevin.bader96@gmail.com> Date: Wed, 17 Apr 2024 21:48:34 +0300 Subject: [PATCH 170/206] resolved conflicts --- src/pages/WorkspaceSwitcherPage/index.tsx | 29 ++++++++--------------- 1 file changed, 10 insertions(+), 19 deletions(-) diff --git a/src/pages/WorkspaceSwitcherPage/index.tsx b/src/pages/WorkspaceSwitcherPage/index.tsx index 489c9566d6c7..0a5492536d56 100644 --- a/src/pages/WorkspaceSwitcherPage/index.tsx +++ b/src/pages/WorkspaceSwitcherPage/index.tsx @@ -1,6 +1,5 @@ import React, {useCallback, useMemo} from 'react'; -import type {OnyxCollection} from 'react-native-onyx'; -import {withOnyx} from 'react-native-onyx'; +import {useOnyx} from 'react-native-onyx'; import HeaderWithBackButton from '@components/HeaderWithBackButton'; import * as Expensicons from '@components/Icon/Expensicons'; import ScreenWrapper from '@components/ScreenWrapper'; @@ -19,7 +18,6 @@ import type {BrickRoad} from '@libs/WorkspacesSettingsUtils'; import WorkspaceCardCreateAWorkspace from '@pages/workspace/card/WorkspaceCardCreateAWorkspace'; import CONST from '@src/CONST'; import ONYXKEYS from '@src/ONYXKEYS'; -import type {Policy} from '@src/types/onyx'; import {isEmptyObject} from '@src/types/utils/EmptyObject'; import WorkspacesSectionHeader from './WorkspacesSectionHeader'; @@ -40,23 +38,20 @@ const sortWorkspacesBySelected = (workspace1: WorkspaceListItem, workspace2: Wor return workspace1.text?.toLowerCase().localeCompare(workspace2.text?.toLowerCase() ?? '') ?? 0; }; -type WorkspaceSwitcherPageOnyxProps = { - /** The list of this user's policies */ - policies: OnyxCollection<Policy>; -}; - -type WorkspaceSwitcherPageProps = WorkspaceSwitcherPageOnyxProps; - const WorkspaceCardCreateAWorkspaceInstance = <WorkspaceCardCreateAWorkspace />; -function WorkspaceSwitcherPage({policies}: WorkspaceSwitcherPageProps) { +function WorkspaceSwitcherPage() { const {isOffline} = useNetwork(); const [searchTerm, debouncedSearchTerm, setSearchTerm] = useDebouncedState(''); const {translate} = useLocalize(); const {activeWorkspaceID, setActiveWorkspaceID} = useActiveWorkspace(); - const brickRoadsForPolicies = useMemo(() => getWorkspacesBrickRoads(), []); - const unreadStatusesForPolicies = useMemo(() => getWorkspacesUnreadStatuses(), []); + const [reports] = useOnyx(ONYXKEYS.COLLECTION.REPORT); + const [reportActions] = useOnyx(ONYXKEYS.COLLECTION.REPORT_ACTIONS); + const [policies] = useOnyx(ONYXKEYS.COLLECTION.POLICY); + + const brickRoadsForPolicies = useMemo(() => getWorkspacesBrickRoads(reports, policies, reportActions), [reports, policies, reportActions]); + const unreadStatusesForPolicies = useMemo(() => getWorkspacesUnreadStatuses(reports), [reports]); const getIndicatorTypeForPolicy = useCallback( (policyId?: string) => { @@ -125,7 +120,7 @@ function WorkspaceSwitcherPage({policies}: WorkspaceSwitcherPageProps) { type: CONST.ICON_TYPE_WORKSPACE, }, ], - boldStyle: hasUnreadData(policy?.id), + isBold: hasUnreadData(policy?.id), keyForList: policy?.id, isPolicyAdmin: PolicyUtils.isPolicyAdmin(policy), isSelected: activeWorkspaceID === policy?.id, @@ -201,8 +196,4 @@ function WorkspaceSwitcherPage({policies}: WorkspaceSwitcherPageProps) { WorkspaceSwitcherPage.displayName = 'WorkspaceSwitcherPage'; -export default withOnyx<WorkspaceSwitcherPageProps, WorkspaceSwitcherPageOnyxProps>({ - policies: { - key: ONYXKEYS.COLLECTION.POLICY, - }, -})(WorkspaceSwitcherPage); +export default WorkspaceSwitcherPage; From 5fc9bd67e09355aad04166cff37a3d5d183fe2d2 Mon Sep 17 00:00:00 2001 From: brunovjk <brunovjk@gmail.com> Date: Wed, 17 Apr 2024 16:11:35 -0300 Subject: [PATCH 171/206] fix type --- package-lock.json | 2 +- src/components/MoneyRequestConfirmationList.tsx | 2 +- src/pages/iou/SplitBillDetailsPage.tsx | 2 -- 3 files changed, 2 insertions(+), 4 deletions(-) diff --git a/package-lock.json b/package-lock.json index 7ccbbed9e03b..75e527bbc483 100644 --- a/package-lock.json +++ b/package-lock.json @@ -13,7 +13,7 @@ "@babel/plugin-proposal-private-methods": "^7.18.6", "@babel/plugin-proposal-private-property-in-object": "^7.21.11", "@dotlottie/react-player": "^1.6.3", - "@expensify/react-native-live-markdown": "^0.1.49", + "@expensify/react-native-live-markdown": "0.1.49", "@expo/metro-runtime": "~3.1.1", "@formatjs/intl-datetimeformat": "^6.10.0", "@formatjs/intl-listformat": "^7.2.2", diff --git a/src/components/MoneyRequestConfirmationList.tsx b/src/components/MoneyRequestConfirmationList.tsx index 036ef7089de8..53a5abf7df93 100755 --- a/src/components/MoneyRequestConfirmationList.tsx +++ b/src/components/MoneyRequestConfirmationList.tsx @@ -112,7 +112,7 @@ type MoneyRequestConfirmationListProps = MoneyRequestConfirmationListOnyxProps & selectedParticipants: Participant[]; /** Payee of the expense with login */ - payeePersonalDetails?: OnyxTypes.PersonalDetails; + payeePersonalDetails?: OnyxEntry<OnyxTypes.PersonalDetails>; /** Can the participants be modified or not */ canModifyParticipants?: boolean; diff --git a/src/pages/iou/SplitBillDetailsPage.tsx b/src/pages/iou/SplitBillDetailsPage.tsx index a868fd51fbd0..157f14d1dde5 100644 --- a/src/pages/iou/SplitBillDetailsPage.tsx +++ b/src/pages/iou/SplitBillDetailsPage.tsx @@ -85,7 +85,6 @@ function SplitBillDetailsPage({personalDetails, report, route, reportActions, tr merchant: splitMerchant, created: splitCreated, category: splitCategory, - tag: splitTag, billable: splitBillable, } = ReportUtils.getTransactionDetails(isEditingSplitBill && draftTransaction ? draftTransaction : transaction) ?? {}; @@ -117,7 +116,6 @@ function SplitBillDetailsPage({personalDetails, report, route, reportActions, tr iouCreated={splitCreated} iouMerchant={splitMerchant} iouCategory={splitCategory} - iouTag={splitTag} iouIsBillable={splitBillable} iouType={CONST.IOU.TYPE.SPLIT} isReadOnly={!isEditingSplitBill} From 1ca5520284b0b548077ec16bebc69ed0c23de239 Mon Sep 17 00:00:00 2001 From: Ishpaul Singh <ishpaul207@gmail.com> Date: Thu, 18 Apr 2024 04:10:57 +0530 Subject: [PATCH 172/206] fixes the issue --- .../MoneyTemporaryForRefactorRequestConfirmationList.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/MoneyTemporaryForRefactorRequestConfirmationList.tsx b/src/components/MoneyTemporaryForRefactorRequestConfirmationList.tsx index d6ac31749a27..b1a7d63fc4bf 100755 --- a/src/components/MoneyTemporaryForRefactorRequestConfirmationList.tsx +++ b/src/components/MoneyTemporaryForRefactorRequestConfirmationList.tsx @@ -894,7 +894,7 @@ function MoneyTemporaryForRefactorRequestConfirmationList({ isLocalFile && Str.isPDF(receiptFilename) ? ( <PDFThumbnail // eslint-disable-next-line @typescript-eslint/non-nullable-type-assertion-style - previewSourceURL={resolvedThumbnail as string} + previewSourceURL={resolvedReceiptImage as string} style={styles.moneyRequestImage} // We don't support scaning password protected PDF receipt enabled={!isAttachmentInvalid} From 657c8c062e7ab6c1aee54d995fbbb1dca36fc5e8 Mon Sep 17 00:00:00 2001 From: Bernhard Owen Josephus <bernhard.josephus@gmail.com> Date: Thu, 18 Apr 2024 14:25:09 +0800 Subject: [PATCH 173/206] pop the current screen before navigating back to member details page --- src/pages/workspace/members/WorkspaceOwnerChangeCheck.tsx | 1 + src/pages/workspace/members/WorkspaceOwnerChangeErrorPage.tsx | 1 + src/pages/workspace/members/WorkspaceOwnerChangeSuccessPage.tsx | 1 + src/pages/workspace/members/WorkspaceOwnerChangeWrapperPage.tsx | 1 + 4 files changed, 4 insertions(+) diff --git a/src/pages/workspace/members/WorkspaceOwnerChangeCheck.tsx b/src/pages/workspace/members/WorkspaceOwnerChangeCheck.tsx index 83bc3a1d1b4d..1ec928158a59 100644 --- a/src/pages/workspace/members/WorkspaceOwnerChangeCheck.tsx +++ b/src/pages/workspace/members/WorkspaceOwnerChangeCheck.tsx @@ -64,6 +64,7 @@ function WorkspaceOwnerChangeCheck({personalDetails, policy, accountID, error}: if (error === CONST.POLICY.OWNERSHIP_ERRORS.HAS_FAILED_SETTLEMENTS || error === CONST.POLICY.OWNERSHIP_ERRORS.FAILED_TO_CLEAR_BALANCE) { // cannot transfer ownership if there are failed settlements, or we cannot clear the balance PolicyActions.clearWorkspaceOwnerChangeFlow(policyID); + Navigation.goBack(); Navigation.navigate(ROUTES.WORKSPACE_MEMBER_DETAILS.getRoute(policyID, accountID)); return; } diff --git a/src/pages/workspace/members/WorkspaceOwnerChangeErrorPage.tsx b/src/pages/workspace/members/WorkspaceOwnerChangeErrorPage.tsx index 81c43f6ab818..8604ba23fc92 100644 --- a/src/pages/workspace/members/WorkspaceOwnerChangeErrorPage.tsx +++ b/src/pages/workspace/members/WorkspaceOwnerChangeErrorPage.tsx @@ -31,6 +31,7 @@ function WorkspaceOwnerChangeErrorPage({route}: WorkspaceOwnerChangeSuccessPageP const closePage = useCallback(() => { PolicyActions.clearWorkspaceOwnerChangeFlow(policyID); + Navigation.goBack(); Navigation.navigate(ROUTES.WORKSPACE_MEMBER_DETAILS.getRoute(policyID, accountID)); }, [accountID, policyID]); diff --git a/src/pages/workspace/members/WorkspaceOwnerChangeSuccessPage.tsx b/src/pages/workspace/members/WorkspaceOwnerChangeSuccessPage.tsx index 856a852037b4..c4968128df06 100644 --- a/src/pages/workspace/members/WorkspaceOwnerChangeSuccessPage.tsx +++ b/src/pages/workspace/members/WorkspaceOwnerChangeSuccessPage.tsx @@ -25,6 +25,7 @@ function WorkspaceOwnerChangeSuccessPage({route}: WorkspaceOwnerChangeSuccessPag const closePage = useCallback(() => { PolicyActions.clearWorkspaceOwnerChangeFlow(policyID); + Navigation.goBack(); Navigation.navigate(ROUTES.WORKSPACE_MEMBER_DETAILS.getRoute(policyID, accountID)); }, [accountID, policyID]); diff --git a/src/pages/workspace/members/WorkspaceOwnerChangeWrapperPage.tsx b/src/pages/workspace/members/WorkspaceOwnerChangeWrapperPage.tsx index 9f9540327c53..6eda891a8fc9 100644 --- a/src/pages/workspace/members/WorkspaceOwnerChangeWrapperPage.tsx +++ b/src/pages/workspace/members/WorkspaceOwnerChangeWrapperPage.tsx @@ -62,6 +62,7 @@ function WorkspaceOwnerChangeWrapperPage({route, policy}: WorkspaceOwnerChangeWr title={translate('workspace.changeOwner.changeOwnerPageTitle')} onBackButtonPress={() => { PolicyActions.clearWorkspaceOwnerChangeFlow(policyID); + Navigation.goBack(); Navigation.navigate(ROUTES.WORKSPACE_MEMBER_DETAILS.getRoute(policyID, accountID)); }} /> From 90d4cb95fe26c793d30333493eb6816959c18573 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?F=C3=A1bio=20Henriques?= <contact@fabiohenriques.dev> Date: Thu, 18 Apr 2024 09:49:01 +0100 Subject: [PATCH 174/206] Refactor codebase to use IOUType and IOUAction types --- src/CONST.ts | 4 +- .../MoneyRequestConfirmationList.tsx | 12 +- ...raryForRefactorRequestConfirmationList.tsx | 14 +- src/libs/IOUUtils.ts | 18 +- src/libs/MoneyRequestUtils.ts | 6 +- src/libs/Navigation/types.ts | 132 +++--- src/libs/ReportUtils.ts | 443 +++++++++--------- src/libs/actions/IOU.ts | 91 ++-- .../AttachmentPickerWithMenuItems.tsx | 4 +- .../step/IOURequestStepParticipants.tsx | 16 +- 10 files changed, 367 insertions(+), 373 deletions(-) diff --git a/src/CONST.ts b/src/CONST.ts index a6df33987c8d..b418715ce543 100755 --- a/src/CONST.ts +++ b/src/CONST.ts @@ -4341,8 +4341,10 @@ const CONST = { } as const; type Country = keyof typeof CONST.ALL_COUNTRIES; + type IOUType = ValueOf<typeof CONST.IOU.TYPE>; +type IOUAction = ValueOf<typeof CONST.IOU.ACTION>; -export type {Country, IOUType}; +export type {Country, IOUAction, IOUType}; export default CONST; diff --git a/src/components/MoneyRequestConfirmationList.tsx b/src/components/MoneyRequestConfirmationList.tsx index 4b3e4096484f..d82d81a7c47f 100755 --- a/src/components/MoneyRequestConfirmationList.tsx +++ b/src/components/MoneyRequestConfirmationList.tsx @@ -5,7 +5,6 @@ import type {StyleProp, ViewStyle} from 'react-native'; import {View} from 'react-native'; import type {OnyxEntry} from 'react-native-onyx'; import {withOnyx} from 'react-native-onyx'; -import type {ValueOf} from 'type-fest'; import useCurrentUserPersonalDetails from '@hooks/useCurrentUserPersonalDetails'; import useLocalize from '@hooks/useLocalize'; import usePermissions from '@hooks/usePermissions'; @@ -24,6 +23,7 @@ import * as ReceiptUtils from '@libs/ReceiptUtils'; import * as ReportUtils from '@libs/ReportUtils'; import * as TransactionUtils from '@libs/TransactionUtils'; import * as IOU from '@userActions/IOU'; +import type {IOUType} from '@src/CONST'; import CONST from '@src/CONST'; import ONYXKEYS from '@src/ONYXKEYS'; import type {Route} from '@src/ROUTES'; @@ -45,8 +45,6 @@ import ShowMoreButton from './ShowMoreButton'; import Switch from './Switch'; import Text from './Text'; -type IouType = ValueOf<typeof CONST.IOU.TYPE>; - type MoneyRequestConfirmationListOnyxProps = { /** Collection of categories attached to a policy */ policyCategories: OnyxEntry<OnyxTypes.PolicyCategories>; @@ -71,7 +69,7 @@ type MoneyRequestConfirmationListProps = MoneyRequestConfirmationListOnyxProps & onConfirm?: (selectedParticipants: Array<Participant | ReportUtils.OptionData>) => void; /** Callback to parent modal to send money */ - onSendMoney?: (paymentMethod: IouType | PaymentMethodType | undefined) => void; + onSendMoney?: (paymentMethod: IOUType | PaymentMethodType | undefined) => void; /** Callback to inform a participant is selected */ onSelectParticipant?: (option: Participant) => void; @@ -89,7 +87,7 @@ type MoneyRequestConfirmationListProps = MoneyRequestConfirmationListOnyxProps & iouCurrencyCode?: string; /** IOU type */ - iouType?: IouType; + iouType?: IOUType; /** IOU date */ iouCreated?: string; @@ -337,7 +335,7 @@ function MoneyRequestConfirmationList({ setDidConfirm(false); } - const splitOrRequestOptions: Array<DropdownOption<IouType>> = useMemo(() => { + const splitOrRequestOptions: Array<DropdownOption<IOUType>> = useMemo(() => { let text; if (isSplitBill && iouAmount === 0) { text = translate('iou.split'); @@ -472,7 +470,7 @@ function MoneyRequestConfirmationList({ }; const confirm = useCallback( - (paymentMethod: IouType | PaymentMethodType | undefined) => { + (paymentMethod: IOUType | PaymentMethodType | undefined) => { if (!selectedParticipants.length) { return; } diff --git a/src/components/MoneyTemporaryForRefactorRequestConfirmationList.tsx b/src/components/MoneyTemporaryForRefactorRequestConfirmationList.tsx index d6ac31749a27..11e6eec089f7 100755 --- a/src/components/MoneyTemporaryForRefactorRequestConfirmationList.tsx +++ b/src/components/MoneyTemporaryForRefactorRequestConfirmationList.tsx @@ -2,11 +2,10 @@ import {useIsFocused} from '@react-navigation/native'; import {format} from 'date-fns'; import Str from 'expensify-common/lib/str'; import React, {useCallback, useEffect, useMemo, useReducer, useRef, useState} from 'react'; -import {View} from 'react-native'; import type {StyleProp, ViewStyle} from 'react-native'; -import {withOnyx} from 'react-native-onyx'; +import {View} from 'react-native'; import type {OnyxEntry} from 'react-native-onyx'; -import type {ValueOf} from 'type-fest'; +import {withOnyx} from 'react-native-onyx'; import useCurrentUserPersonalDetails from '@hooks/useCurrentUserPersonalDetails'; import useLocalize from '@hooks/useLocalize'; import usePermissions from '@hooks/usePermissions'; @@ -14,8 +13,8 @@ import usePrevious from '@hooks/usePrevious'; import useTheme from '@hooks/useTheme'; import useThemeStyles from '@hooks/useThemeStyles'; import * as CurrencyUtils from '@libs/CurrencyUtils'; -import DistanceRequestUtils from '@libs/DistanceRequestUtils'; import type {DefaultMileageRate} from '@libs/DistanceRequestUtils'; +import DistanceRequestUtils from '@libs/DistanceRequestUtils'; import * as IOUUtils from '@libs/IOUUtils'; import Log from '@libs/Log'; import * as MoneyRequestUtils from '@libs/MoneyRequestUtils'; @@ -29,10 +28,11 @@ import playSound, {SOUNDS} from '@libs/Sound'; import * as TransactionUtils from '@libs/TransactionUtils'; import tryResolveUrlFromApiRoot from '@libs/tryResolveUrlFromApiRoot'; import * as IOU from '@userActions/IOU'; +import type {IOUAction, IOUType} from '@src/CONST'; import CONST from '@src/CONST'; import ONYXKEYS from '@src/ONYXKEYS'; -import ROUTES from '@src/ROUTES'; import type {Route} from '@src/ROUTES'; +import ROUTES from '@src/ROUTES'; import type * as OnyxTypes from '@src/types/onyx'; import type {Participant} from '@src/types/onyx/IOU'; import type {PaymentMethodType} from '@src/types/onyx/OriginalMessage'; @@ -92,7 +92,7 @@ type MoneyRequestConfirmationListProps = MoneyRequestConfirmationListOnyxProps & iouCurrencyCode?: string; /** IOU type */ - iouType?: ValueOf<typeof CONST.IOU.TYPE>; + iouType?: IOUType; /** IOU date */ iouCreated?: string; @@ -162,7 +162,7 @@ type MoneyRequestConfirmationListProps = MoneyRequestConfirmationListOnyxProps & reportActionID?: string; - action?: ValueOf<typeof CONST.IOU.ACTION>; + action?: IOUAction; }; const getTaxAmount = (transaction: OnyxEntry<OnyxTypes.Transaction>, defaultTaxValue: string) => { diff --git a/src/libs/IOUUtils.ts b/src/libs/IOUUtils.ts index 27eff132ef40..6a2051db0ed0 100644 --- a/src/libs/IOUUtils.ts +++ b/src/libs/IOUUtils.ts @@ -1,5 +1,5 @@ import type {OnyxEntry} from 'react-native-onyx'; -import type {ValueOf} from 'type-fest'; +import type {IOUAction, IOUType} from '@src/CONST'; import CONST from '@src/CONST'; import ROUTES from '@src/ROUTES'; import type {Report, Transaction} from '@src/types/onyx'; @@ -8,13 +8,7 @@ import * as CurrencyUtils from './CurrencyUtils'; import Navigation from './Navigation/Navigation'; import * as TransactionUtils from './TransactionUtils'; -function navigateToStartMoneyRequestStep( - requestType: IOURequestType, - iouType: ValueOf<typeof CONST.IOU.TYPE>, - transactionID: string, - reportID: string, - iouAction?: ValueOf<typeof CONST.IOU.ACTION>, -): void { +function navigateToStartMoneyRequestStep(requestType: IOURequestType, iouType: IOUType, transactionID: string, reportID: string, iouAction?: IOUAction): void { if (iouAction === CONST.IOU.ACTION.CATEGORIZE || iouAction === CONST.IOU.ACTION.MOVE) { Navigation.goBack(); return; @@ -134,7 +128,7 @@ function insertTagIntoTransactionTagsString(transactionTags: string, tag: string return tagArray.join(CONST.COLON).replace(/:*$/, ''); } -function isMovingTransactionFromTrackExpense(action?: ValueOf<typeof CONST.IOU.ACTION>) { +function isMovingTransactionFromTrackExpense(action?: IOUAction) { if (action === CONST.IOU.ACTION.MOVE || action === CONST.IOU.ACTION.SHARE || action === CONST.IOU.ACTION.CATEGORIZE) { return true; } @@ -144,10 +138,10 @@ function isMovingTransactionFromTrackExpense(action?: ValueOf<typeof CONST.IOU.A export { calculateAmount, - updateIOUOwnerAndTotal, + insertTagIntoTransactionTagsString, isIOUReportPendingCurrencyConversion, + isMovingTransactionFromTrackExpense, isValidMoneyRequestType, navigateToStartMoneyRequestStep, - insertTagIntoTransactionTagsString, - isMovingTransactionFromTrackExpense, + updateIOUOwnerAndTotal, }; diff --git a/src/libs/MoneyRequestUtils.ts b/src/libs/MoneyRequestUtils.ts index ec934cb87888..4e681e016b6b 100644 --- a/src/libs/MoneyRequestUtils.ts +++ b/src/libs/MoneyRequestUtils.ts @@ -1,5 +1,5 @@ import type {OnyxEntry} from 'react-native-onyx'; -import type {ValueOf} from 'type-fest'; +import type {IOUType} from '@src/CONST'; import CONST from '@src/CONST'; import type {SelectedTabRequest} from '@src/types/onyx'; @@ -80,7 +80,7 @@ function replaceAllDigits(text: string, convertFn: (char: string) => string): st /** * Check if distance expense or not */ -function isDistanceRequest(iouType: ValueOf<typeof CONST.IOU.TYPE>, selectedTab: OnyxEntry<SelectedTabRequest>): boolean { +function isDistanceRequest(iouType: IOUType, selectedTab: OnyxEntry<SelectedTabRequest>): boolean { return iouType === CONST.IOU.TYPE.REQUEST && selectedTab === CONST.TAB_REQUEST.DISTANCE; } @@ -91,4 +91,4 @@ function isScanRequest(selectedTab: SelectedTabRequest): boolean { return selectedTab === CONST.TAB_REQUEST.SCAN; } -export {stripCommaFromAmount, stripDecimalsFromAmount, stripSpacesFromAmount, addLeadingZero, validateAmount, replaceAllDigits, isDistanceRequest, isScanRequest}; +export {addLeadingZero, isDistanceRequest, isScanRequest, replaceAllDigits, stripCommaFromAmount, stripDecimalsFromAmount, stripSpacesFromAmount, validateAmount}; diff --git a/src/libs/Navigation/types.ts b/src/libs/Navigation/types.ts index 7dd2f274aa9e..49829f707886 100644 --- a/src/libs/Navigation/types.ts +++ b/src/libs/Navigation/types.ts @@ -13,7 +13,7 @@ import type { import type {ValueOf} from 'type-fest'; import type {IOURequestType} from '@libs/actions/IOU'; import type CONST from '@src/CONST'; -import type {Country} from '@src/CONST'; +import type {Country, IOUAction, IOUType} from '@src/CONST'; import type NAVIGATORS from '@src/NAVIGATORS'; import type {HybridAppRoute, Route as Routes} from '@src/ROUTES'; import type SCREENS from '@src/SCREENS'; @@ -371,39 +371,39 @@ type MoneyRequestNavigatorParamList = { reportID: string; }; [SCREENS.MONEY_REQUEST.STEP_DATE]: { - action: ValueOf<typeof CONST.IOU.ACTION>; - iouType: ValueOf<typeof CONST.IOU.TYPE>; + action: IOUAction; + iouType: IOUType; transactionID: string; reportID: string; backTo: Routes; }; [SCREENS.MONEY_REQUEST.STEP_DESCRIPTION]: { - action: ValueOf<typeof CONST.IOU.ACTION>; - iouType: ValueOf<typeof CONST.IOU.TYPE>; + action: IOUAction; + iouType: IOUType; transactionID: string; reportID: string; backTo: Routes; reportActionID: string; }; [SCREENS.MONEY_REQUEST.STEP_CATEGORY]: { - action: ValueOf<typeof CONST.IOU.ACTION>; - iouType: ValueOf<typeof CONST.IOU.TYPE>; + action: IOUAction; + iouType: IOUType; transactionID: string; reportActionID: string; reportID: string; backTo: Routes; }; [SCREENS.MONEY_REQUEST.STEP_TAX_AMOUNT]: { - action: ValueOf<typeof CONST.IOU.ACTION>; - iouType: ValueOf<typeof CONST.IOU.TYPE>; + action: IOUAction; + iouType: IOUType; transactionID: string; reportID: string; backTo: Routes; currency?: string; }; [SCREENS.MONEY_REQUEST.STEP_TAG]: { - action: ValueOf<typeof CONST.IOU.ACTION>; - iouType: ValueOf<typeof CONST.IOU.TYPE>; + action: IOUAction; + iouType: IOUType; transactionID: string; reportID: string; backTo: Routes; @@ -411,23 +411,23 @@ type MoneyRequestNavigatorParamList = { orderWeight: string; }; [SCREENS.MONEY_REQUEST.STEP_TAX_RATE]: { - action: ValueOf<typeof CONST.IOU.ACTION>; - iouType: ValueOf<typeof CONST.IOU.TYPE>; + action: IOUAction; + iouType: IOUType; transactionID: string; reportID: string; backTo: Routes; }; [SCREENS.MONEY_REQUEST.STEP_WAYPOINT]: { - iouType: ValueOf<typeof CONST.IOU.TYPE>; + iouType: IOUType; reportID: string; backTo: Routes | undefined; - action: ValueOf<typeof CONST.IOU.ACTION>; + action: IOUAction; pageIndex: string; transactionID: string; }; [SCREENS.MONEY_REQUEST.STEP_MERCHANT]: { - action: ValueOf<typeof CONST.IOU.ACTION>; - iouType: ValueOf<typeof CONST.IOU.TYPE>; + action: IOUAction; + iouType: IOUType; transactionID: string; reportID: string; backTo: Routes; @@ -442,8 +442,8 @@ type MoneyRequestNavigatorParamList = { threadReportID: number; }; [SCREENS.MONEY_REQUEST.STEP_DISTANCE]: { - action: ValueOf<typeof CONST.IOU.ACTION>; - iouType: ValueOf<typeof CONST.IOU.TYPE>; + action: IOUAction; + iouType: IOUType; transactionID: string; reportID: string; backTo: Routes; @@ -453,7 +453,7 @@ type MoneyRequestNavigatorParamList = { reportID: string; }; [SCREENS.MONEY_REQUEST.CREATE]: { - iouType: ValueOf<typeof CONST.IOU.TYPE>; + iouType: IOUType; reportID: string; transactionID: string; @@ -464,44 +464,44 @@ type MoneyRequestNavigatorParamList = { currency: never; }; [SCREENS.MONEY_REQUEST.START]: { - iouType: ValueOf<typeof CONST.IOU.TYPE>; + iouType: IOUType; reportID: string; transactionID: string; iouRequestType: IOURequestType; }; [SCREENS.MONEY_REQUEST.STEP_AMOUNT]: { - iouType: ValueOf<typeof CONST.IOU.TYPE>; + iouType: IOUType; reportID: string; transactionID: string; backTo: Routes; - action: ValueOf<typeof CONST.IOU.ACTION>; + action: IOUAction; currency?: string; }; [SCREENS.MONEY_REQUEST.STEP_PARTICIPANTS]: { - action: ValueOf<typeof CONST.IOU.ACTION>; - iouType: ValueOf<typeof CONST.IOU.TYPE>; + action: IOUAction; + iouType: IOUType; transactionID: string; reportID: string; }; [SCREENS.MONEY_REQUEST.STEP_CONFIRMATION]: { - action: ValueOf<typeof CONST.IOU.ACTION>; - iouType: ValueOf<typeof CONST.IOU.TYPE>; + action: IOUAction; + iouType: IOUType; transactionID: string; reportID: string; pageIndex?: string; backTo?: string; }; [SCREENS.MONEY_REQUEST.STEP_SCAN]: { - action: ValueOf<typeof CONST.IOU.ACTION>; - iouType: ValueOf<typeof CONST.IOU.TYPE>; + action: IOUAction; + iouType: IOUType; transactionID: string; reportID: string; pageIndex: number; backTo: Routes; }; [SCREENS.MONEY_REQUEST.STEP_CURRENCY]: { - action: ValueOf<typeof CONST.IOU.ACTION>; - iouType: ValueOf<typeof CONST.IOU.TYPE>; + action: IOUAction; + iouType: IOUType; transactionID: string; reportID: string; pageIndex?: string; @@ -805,54 +805,54 @@ type SwitchPolicyIDParams = { }; export type { - NavigationRef, - StackNavigationAction, - CentralPaneNavigatorParamList, + AddPersonalBankAccountNavigatorParamList, + AuthScreensParamList, + BackToParams, BottomTabName, + BottomTabNavigatorParamList, CentralPaneName, + CentralPaneNavigatorParamList, + ChatFinderNavigatorParamList, + DetailsNavigatorParamList, + EditRequestNavigatorParamList, + EnablePaymentsNavigatorParamList, + FlagCommentNavigatorParamList, FullScreenName, - RootStackParamList, - StateOrRoute, - NavigationStateRoute, + FullScreenNavigatorParamList, + LeftModalNavigatorParamList, + MoneyRequestNavigatorParamList, NavigationPartialRoute, + NavigationRef, NavigationRoot, - AuthScreensParamList, - BottomTabNavigatorParamList, - LeftModalNavigatorParamList, - RightModalNavigatorParamList, + NavigationStateRoute, + NewChatNavigatorParamList, + NewTaskNavigatorParamList, + OnboardEngagementNavigatorParamList, OnboardingModalNavigatorParamList, - WelcomeVideoModalNavigatorParamList, - PublicScreensParamList, - MoneyRequestNavigatorParamList, - SplitDetailsNavigatorParamList, - DetailsNavigatorParamList, + ParticipantsNavigatorParamList, + PrivateNotesNavigatorParamList, ProfileNavigatorParamList, + PublicScreensParamList, + ReferralDetailsNavigatorParamList, + ReimbursementAccountNavigatorParamList, + ReportDescriptionNavigatorParamList, ReportDetailsNavigatorParamList, ReportSettingsNavigatorParamList, - TaskDetailsNavigatorParamList, - ReportDescriptionNavigatorParamList, - ParticipantsNavigatorParamList, - RoomMembersNavigatorParamList, + RightModalNavigatorParamList, RoomInviteNavigatorParamList, - ChatFinderNavigatorParamList, - NewChatNavigatorParamList, - NewTaskNavigatorParamList, - TeachersUniteNavigatorParamList, + RoomMembersNavigatorParamList, + RootStackParamList, SettingsNavigatorParamList, - EnablePaymentsNavigatorParamList, - AddPersonalBankAccountNavigatorParamList, - WalletStatementNavigatorParamList, - FlagCommentNavigatorParamList, - EditRequestNavigatorParamList, - PrivateNotesNavigatorParamList, SignInNavigatorParamList, - ReferralDetailsNavigatorParamList, - ReimbursementAccountNavigatorParamList, + SplitDetailsNavigatorParamList, + StackNavigationAction, State, - WorkspaceSwitcherNavigatorParamList, - OnboardEngagementNavigatorParamList, + StateOrRoute, SwitchPolicyIDParams, - FullScreenNavigatorParamList, + TaskDetailsNavigatorParamList, + TeachersUniteNavigatorParamList, + WalletStatementNavigatorParamList, + WelcomeVideoModalNavigatorParamList, + WorkspaceSwitcherNavigatorParamList, WorkspacesCentralPaneNavigatorParamList, - BackToParams, }; diff --git a/src/libs/ReportUtils.ts b/src/libs/ReportUtils.ts index 28a0f6b385bb..560d1eb7e72d 100644 --- a/src/libs/ReportUtils.ts +++ b/src/libs/ReportUtils.ts @@ -13,6 +13,7 @@ import type {FileObject} from '@components/AttachmentModal'; import * as Expensicons from '@components/Icon/Expensicons'; import * as defaultGroupAvatars from '@components/Icon/GroupDefaultAvatars'; import * as defaultWorkspaceAvatars from '@components/Icon/WorkspaceDefaultAvatars'; +import type {IOUAction, IOUType} from '@src/CONST'; import CONST from '@src/CONST'; import type {ParentNavigationSummaryParams, TranslationPaths} from '@src/languages/types'; import ONYXKEYS from '@src/ONYXKEYS'; @@ -5059,7 +5060,7 @@ function isGroupChatAdmin(report: OnyxEntry<Report>, accountID: number) { * None of the options should show in chat threads or if there is some special Expensify account * as a participant of the report. */ -function getMoneyRequestOptions(report: OnyxEntry<Report>, policy: OnyxEntry<Policy>, reportParticipants: number[], canUseTrackExpense = true): Array<ValueOf<typeof CONST.IOU.TYPE>> { +function getMoneyRequestOptions(report: OnyxEntry<Report>, policy: OnyxEntry<Policy>, reportParticipants: number[], canUseTrackExpense = true): IOUType[] { // In any thread or task report, we do not allow any new expenses yet if (isChatThread(report) || isTaskReport(report) || (!canUseTrackExpense && isSelfDM(report))) { return []; @@ -5074,7 +5075,7 @@ function getMoneyRequestOptions(report: OnyxEntry<Report>, policy: OnyxEntry<Pol const otherParticipants = reportParticipants.filter((accountID) => currentUserPersonalDetails?.accountID !== accountID); const hasSingleOtherParticipantInReport = otherParticipants.length === 1; - let options: Array<ValueOf<typeof CONST.IOU.TYPE>> = []; + let options: IOUType[] = []; if (isSelfDM(report)) { options = [CONST.IOU.TYPE.TRACK_EXPENSE]; @@ -5963,7 +5964,7 @@ function getReportActionActorAccountID(reportAction: OnyxEntry<ReportAction>, io } } -function createDraftTransactionAndNavigateToParticipantSelector(transactionID: string, reportID: string, actionName: ValueOf<typeof CONST.IOU.ACTION>, reportActionID: string): void { +function createDraftTransactionAndNavigateToParticipantSelector(transactionID: string, reportID: string, actionName: IOUAction, reportActionID: string): void { const transaction = allTransactions?.[`${ONYXKEYS.COLLECTION.TRANSACTION}${transactionID}`] ?? ({} as Transaction); const reportActions = allReportActions?.[`${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${reportID}`] ?? ([] as ReportAction[]); @@ -6024,257 +6025,257 @@ function canReportBeMentionedWithinPolicy(report: OnyxEntry<Report>, policyID: s } export { - getReportParticipantsTitle, - isReportMessageAttachment, - findLastAccessedReport, - canBeAutoReimbursed, - canEditReportAction, - canFlagReportAction, - shouldShowFlagComment, - isActionCreator, - canDeleteReportAction, - canLeaveRoom, - sortReportsByLastRead, - isDefaultRoom, - isAdminRoom, - isAdminsOnlyPostingRoom, - isAnnounceRoom, - isUserCreatedPolicyRoom, - isChatRoom, - getChatRoomSubtitle, - getParentNavigationSubtitle, - getPolicyName, - getPolicyType, - isArchivedRoom, - isClosedExpenseReportWithNoExpenses, - isExpensifyOnlyParticipantInReport, - canCreateTaskInReport, - isPolicyExpenseChatAdmin, - isPolicyAdmin, - isPublicRoom, - isPublicAnnounceRoom, - isConciergeChatReport, - isProcessingReport, - isCurrentUserTheOnlyParticipant, - hasAutomatedExpensifyAccountIDs, - hasExpensifyGuidesEmails, - requiresAttentionFromCurrentUser, - isIOUOwnedByCurrentUser, - getMoneyRequestSpendBreakdown, - canShowReportRecipientLocalTime, - formatReportLastMessageText, - chatIncludesConcierge, - isPolicyExpenseChat, - isGroupPolicy, - isPaidGroupPolicy, - isControlPolicyExpenseChat, - isControlPolicyExpenseReport, - isPaidGroupPolicyExpenseChat, - isPaidGroupPolicyExpenseReport, - getIconsForParticipants, - getIcons, - getRoomWelcomeMessage, - getDisplayNamesWithTooltips, - getReportName, - getReport, - getReportNotificationPreference, - getReportIDFromLink, - getReportPolicyID, - getRouteFromLink, - getDeletedParentActionMessageForChatReport, - getLastVisibleMessage, - navigateToDetailsPage, - generateReportID, - hasReportNameError, - isUnread, - isUnreadWithMention, - buildOptimisticWorkspaceChats, - buildOptimisticTaskReport, + addDomainToShortMention, + areAllRequestsBeingSmartScanned, + buildOptimisticAddCommentReportAction, + buildOptimisticApprovedReportAction, + buildOptimisticCancelPaymentReportAction, + buildOptimisticChangedTaskAssigneeReportAction, buildOptimisticChatReport, - buildOptimisticGroupChatReport, buildOptimisticClosedReportAction, buildOptimisticCreatedReportAction, - buildOptimisticRenamedRoomReportAction, buildOptimisticEditedTaskFieldReportAction, - buildOptimisticChangedTaskAssigneeReportAction, - buildOptimisticIOUReport, - buildOptimisticApprovedReportAction, - buildOptimisticMovedReportAction, - buildOptimisticSubmittedReportAction, buildOptimisticExpenseReport, + buildOptimisticGroupChatReport, + buildOptimisticHoldReportAction, + buildOptimisticHoldReportActionComment, + buildOptimisticIOUReport, buildOptimisticIOUReportAction, - buildOptimisticMoneyRequestEntities, - buildOptimisticReportPreview, buildOptimisticModifiedExpenseReportAction, + buildOptimisticMoneyRequestEntities, + buildOptimisticMovedReportAction, buildOptimisticMovedTrackedExpenseModifiedReportAction, - buildOptimisticCancelPaymentReportAction, - updateReportPreview, - buildOptimisticTaskReportAction, - buildOptimisticAddCommentReportAction, + buildOptimisticRenamedRoomReportAction, + buildOptimisticReportPreview, + buildOptimisticSubmittedReportAction, buildOptimisticTaskCommentReportAction, - updateOptimisticParentReportAction, - getOptimisticDataForParentReportAction, - shouldReportBeInOptionList, + buildOptimisticTaskReport, + buildOptimisticTaskReportAction, + buildOptimisticUnHoldReportAction, + buildOptimisticWorkspaceChats, + buildParticipantsFromAccountIDs, + buildTransactionThread, + canAccessReport, + canAddOrDeleteTransactions, + canBeAutoReimbursed, + canCreateRequest, + canCreateTaskInReport, + canDeleteReportAction, + canEditFieldOfMoneyRequest, + canEditMoneyRequest, + canEditPolicyDescription, + canEditReportAction, + canEditReportDescription, + canEditRoomVisibility, + canEditWriteCapability, + canFlagReportAction, + canLeavePolicyExpenseChat, + canLeaveRoom, + canReportBeMentionedWithinPolicy, + canRequestMoney, + canSeeDefaultRoom, + canShowReportRecipientLocalTime, + canUserPerformWriteAction, + chatIncludesChronos, + chatIncludesConcierge, + createDraftTransactionAndNavigateToParticipantSelector, + doesReportBelongToWorkspace, + doesTransactionThreadHaveViolations, + findLastAccessedReport, + findSelfDMReportID, + formatReportLastMessageText, + generateReportID, + getAddWorkspaceRoomOrChatReportErrors, + getAllAncestorReportActionIDs, + getAllAncestorReportActions, + getAllHeldTransactions, + getAllPolicyReports, + getAllWorkspaceReports, + getAvailableReportFields, + getBankAccountRoute, getChatByParticipants, getChatByParticipantsAndPolicy, - getAllPolicyReports, - getIOUReportActionMessage, - getDisplayNameForParticipant, - getWorkspaceIcon, - isOptimisticPersonalDetail, - shouldDisableDetailPage, - isChatReport, - isCurrentUserSubmitter, - isExpenseReport, - isExpenseRequest, - isIOUReport, - isTaskReport, - isOpenTaskReport, - isCanceledTaskReport, - isCompletedTaskReport, - isReportManager, - isReportApproved, - isMoneyRequestReport, - isMoneyRequest, - chatIncludesChronos, - getNewMarkerReportActionID, - canSeeDefaultRoom, + getChatRoomSubtitle, + getChildReportNotificationPreference, + getCommentLength, + getDefaultGroupAvatar, getDefaultWorkspaceAvatar, getDefaultWorkspaceAvatarTestID, - getCommentLength, - getParsedComment, - addDomainToShortMention, + getDeletedParentActionMessageForChatReport, + getDisplayNameForParticipant, + getDisplayNamesWithTooltips, + getGroupChatName, + getIOUReportActionDisplayMessage, + getIOUReportActionMessage, + getIcons, + getIconsForParticipants, + getIndicatedMissingPaymentMethod, + getLastUpdatedReport, + getLastVisibleMessage, getMoneyRequestOptions, - canCreateRequest, - hasIOUWaitingOnCurrentUserBankAccount, - canRequestMoney, - getWhisperDisplayNames, - getWorkspaceAvatar, - isThread, - isChatThread, - isThreadFirstChat, - isChildReport, - shouldReportShowSubscript, - isReportDataReady, - isValidReportIDFromPath, - isSettled, - isAllowedToComment, - getBankAccountRoute, - getRootParentReport, - getReportPreviewMessage, - isMoneyRequestReportPendingDeletion, - canUserPerformWriteAction, + getMoneyRequestSpendBreakdown, + getNewMarkerReportActionID, + getNonHeldAndFullAmount, + getOptimisticDataForParentReportAction, getOriginalReportID, - canAccessReport, - getAddWorkspaceRoomOrChatReportErrors, + getOutstandingChildRequest, + getParentNavigationSubtitle, + getParsedComment, + getParticipantAccountIDs, + getParticipants, + getPayeeName, + getPendingChatMembers, + getPersonalDetailsForAccountID, + getPolicyDescriptionText, + getPolicyName, + getPolicyType, + getReimbursementDeQueuedActionMessage, + getReimbursementQueuedActionMessage, + getReport, + getReportActionActorAccountID, + getReportDescriptionText, + getReportFieldKey, + getReportIDFromLink, + getReportName, + getReportNotificationPreference, getReportOfflinePendingActionAndErrors, - isDM, - isSelfDM, - getWorkspaceChats, - getAllWorkspaceReports, - shouldDisableRename, - hasSingleParticipant, + getReportParticipantsTitle, + getReportPolicyID, + getReportPreviewMessage, getReportRecipientAccountIDs, - isOneOnOneChat, - isOneTransactionThread, - isPayer, - goBackToDetailsPage, - getTransactionReportName, - getTransactionDetails, + getRoom, + getRoomWelcomeMessage, + getRootParentReport, + getRouteFromLink, getTaskAssigneeChatOnyxData, - canEditMoneyRequest, - canEditFieldOfMoneyRequest, - buildTransactionThread, - areAllRequestsBeingSmartScanned, + getTransactionDetails, + getTransactionReportName, getTransactionsWithReceipts, - hasOnlyTransactionsWithPendingRoutes, - hasNonReimbursableTransactions, - hasMissingSmartscanFields, - getIOUReportActionDisplayMessage, - isWaitingForAssigneeToCompleteTask, - isDeprecatedGroupDM, - isOpenExpenseReport, - shouldUseFullTitleToDisplay, - parseReportRouteParams, - getReimbursementQueuedActionMessage, - getReimbursementDeQueuedActionMessage, - getPersonalDetailsForAccountID, - getRoom, - canEditReportDescription, - doesTransactionThreadHaveViolations, - shouldDisplayTransactionThreadViolations, - hasViolations, - navigateToPrivateNotes, - canEditWriteCapability, - isHoldCreator, + getUserDetailTooltipText, + getVisibleChatMemberAccountIDs, + getWhisperDisplayNames, + getWorkspaceAvatar, + getWorkspaceChats, + getWorkspaceIcon, + goBackToDetailsPage, + hasActionsWithErrors, + hasAutomatedExpensifyAccountIDs, + hasExpensifyGuidesEmails, hasHeldExpenses, + hasIOUWaitingOnCurrentUserBankAccount, + hasMissingPaymentMethod, + hasMissingSmartscanFields, + hasNonReimbursableTransactions, hasOnlyHeldExpenses, - getNonHeldAndFullAmount, + hasOnlyTransactionsWithPendingRoutes, + hasReportNameError, + hasSingleParticipant, hasSmartscanError, - shouldAutoFocusOnKeyPress, - buildOptimisticHoldReportAction, - buildOptimisticHoldReportActionComment, - buildOptimisticUnHoldReportAction, - shouldDisplayThreadReplies, - shouldDisableThread, - getUserDetailTooltipText, - doesReportBelongToWorkspace, - getChildReportNotificationPreference, - getAllAncestorReportActions, - isReportParticipant, - isValidReport, - getReportDescriptionText, - isReportFieldOfTypeTitle, - hasMissingPaymentMethod, - isIOUReportUsingReport, hasUpdatedTotal, + hasViolations, + isActionCreator, + isAdminRoom, + isAdminsOnlyPostingRoom, + isAllowedToApproveExpenseReport, + isAllowedToComment, + isAllowedToSubmitDraftExpenseReport, + isAnnounceRoom, + isArchivedRoom, + isCanceledTaskReport, + isChatReport, + isChatRoom, + isChatThread, + isChildReport, + isClosedExpenseReportWithNoExpenses, + isCompletedTaskReport, + isConciergeChatReport, + isControlPolicyExpenseChat, + isControlPolicyExpenseReport, + isCurrentUserSubmitter, + isCurrentUserTheOnlyParticipant, + isDM, + isDefaultRoom, + isDeprecatedGroupDM, + isExpenseReport, + isExpenseRequest, + isExpensifyOnlyParticipantInReport, + isGroupChat, + isGroupChatAdmin, + isGroupPolicy, + isHoldCreator, + isIOUOwnedByCurrentUser, + isIOUReport, + isIOUReportUsingReport, + isJoinRequestInAdminRoom, + isMoneyRequest, + isMoneyRequestReport, + isMoneyRequestReportPendingDeletion, + isOneOnOneChat, + isOneTransactionThread, + isOpenExpenseReport, + isOpenTaskReport, + isOptimisticPersonalDetail, + isPaidGroupPolicy, + isPaidGroupPolicyExpenseChat, + isPaidGroupPolicyExpenseReport, + isPayer, + isPolicyAdmin, + isPolicyExpenseChat, + isPolicyExpenseChatAdmin, + isProcessingReport, + isPublicAnnounceRoom, + isPublicRoom, + isReportApproved, + isReportDataReady, isReportFieldDisabled, - getAvailableReportFields, + isReportFieldOfTypeTitle, + isReportManager, + isReportMessageAttachment, isReportOwner, - getReportFieldKey, + isReportParticipant, + isSelfDM, + isSettled, + isTaskReport, + isThread, + isThreadFirstChat, + isTrackExpenseReport, + isUnread, + isUnreadWithMention, + isUserCreatedPolicyRoom, + isValidReport, + isValidReportIDFromPath, + isWaitingForAssigneeToCompleteTask, + navigateToDetailsPage, + navigateToPrivateNotes, + parseReportRouteParams, reportFieldsEnabled, - getAllAncestorReportActionIDs, - getPendingChatMembers, - canEditRoomVisibility, - canEditPolicyDescription, - getPolicyDescriptionText, - getDefaultGroupAvatar, - isAllowedToSubmitDraftExpenseReport, - isAllowedToApproveExpenseReport, - findSelfDMReportID, - getIndicatedMissingPaymentMethod, - isJoinRequestInAdminRoom, - canAddOrDeleteTransactions, + requiresAttentionFromCurrentUser, + shouldAutoFocusOnKeyPress, shouldCreateNewMoneyRequestReport, - getLastUpdatedReport, - isGroupChat, - isTrackExpenseReport, - hasActionsWithErrors, - createDraftTransactionAndNavigateToParticipantSelector, - getReportActionActorAccountID, - getGroupChatName, - canLeavePolicyExpenseChat, - getOutstandingChildRequest, - getVisibleChatMemberAccountIDs, - getParticipantAccountIDs, - getParticipants, - isGroupChatAdmin, - buildParticipantsFromAccountIDs, - canReportBeMentionedWithinPolicy, - getAllHeldTransactions, - getPayeeName, + shouldDisableDetailPage, + shouldDisableRename, + shouldDisableThread, + shouldDisplayThreadReplies, + shouldDisplayTransactionThreadViolations, + shouldReportBeInOptionList, + shouldReportShowSubscript, + shouldShowFlagComment, + shouldUseFullTitleToDisplay, + sortReportsByLastRead, + updateOptimisticParentReportAction, + updateReportPreview, }; export type { - ExpenseOriginalMessage, - OptionData, - OptimisticChatReport, + Ancestor, DisplayNameWithTooltips, - OptimisticTaskReportAction, + ExpenseOriginalMessage, OptimisticAddCommentReportAction, - OptimisticCreatedReportAction, + OptimisticChatReport, OptimisticClosedReportAction, - Ancestor, + OptimisticCreatedReportAction, OptimisticIOUReportAction, + OptimisticTaskReportAction, + OptionData, TransactionDetails, }; diff --git a/src/libs/actions/IOU.ts b/src/libs/actions/IOU.ts index 83caa65e1d77..0c8306cd9d54 100644 --- a/src/libs/actions/IOU.ts +++ b/src/libs/actions/IOU.ts @@ -2,8 +2,8 @@ import type {ParamListBase, StackNavigationState} from '@react-navigation/native import {format} from 'date-fns'; import fastMerge from 'expensify-common/lib/fastMerge'; import Str from 'expensify-common/lib/str'; -import Onyx from 'react-native-onyx'; import type {OnyxCollection, OnyxEntry, OnyxUpdate} from 'react-native-onyx'; +import Onyx from 'react-native-onyx'; import type {ValueOf} from 'type-fest'; import ReceiptGeneric from '@assets/images/receipt-generic.png'; import * as API from '@libs/API'; @@ -40,12 +40,13 @@ import Permissions from '@libs/Permissions'; import * as PhoneNumber from '@libs/PhoneNumber'; import * as PolicyUtils from '@libs/PolicyUtils'; import * as ReportActionsUtils from '@libs/ReportActionsUtils'; -import * as ReportUtils from '@libs/ReportUtils'; import type {OptimisticChatReport, OptimisticCreatedReportAction, OptimisticIOUReportAction, TransactionDetails} from '@libs/ReportUtils'; +import * as ReportUtils from '@libs/ReportUtils'; import * as TransactionUtils from '@libs/TransactionUtils'; import * as UserUtils from '@libs/UserUtils'; import ViolationsUtils from '@libs/Violations/ViolationsUtils'; import type {NavigationPartialRoute} from '@navigation/types'; +import type {IOUAction, IOUType} from '@src/CONST'; import CONST from '@src/CONST'; import ONYXKEYS from '@src/ONYXKEYS'; import ROUTES from '@src/ROUTES'; @@ -377,7 +378,7 @@ function updateMoneyRequestTypeParams(routes: StackNavigationState<ParamListBase } // eslint-disable-next-line @typescript-eslint/naming-convention -function startMoneyRequest(iouType: ValueOf<typeof CONST.IOU.TYPE>, reportID: string, requestType?: IOURequestType) { +function startMoneyRequest(iouType: IOUType, reportID: string, requestType?: IOURequestType) { clearMoneyRequest(CONST.IOU.OPTIMISTIC_TRANSACTION_ID); switch (requestType) { case CONST.IOU.REQUEST_TYPE.MANUAL: @@ -2782,7 +2783,7 @@ function requestMoney( policyTagList?: OnyxEntry<OnyxTypes.PolicyTagList>, policyCategories?: OnyxEntry<OnyxTypes.PolicyCategories>, gpsPoints?: GPSPoint, - action?: ValueOf<typeof CONST.IOU.ACTION>, + action?: IOUAction, actionableWhisperReportActionID?: string, linkedTrackedExpenseReportAction?: OnyxTypes.ReportAction, linkedTrackedExpenseReportID?: string, @@ -2924,7 +2925,7 @@ function trackExpense( policyCategories?: OnyxEntry<OnyxTypes.PolicyCategories>, gpsPoints?: GPSPoint, validWaypoints?: WaypointCollection, - action?: ValueOf<typeof CONST.IOU.ACTION>, + action?: IOUAction, actionableWhisperReportActionID?: string, linkedTrackedExpenseReportAction?: OnyxTypes.ReportAction, linkedTrackedExpenseReportID?: string, @@ -5971,7 +5972,7 @@ function navigateToStartStepIfScanFileCannotBeRead( receiptPath: ReceiptSource | undefined, onSuccess: (file: File) => void, requestType: IOURequestType, - iouType: ValueOf<typeof CONST.IOU.TYPE>, + iouType: IOUType, transactionID: string, reportID: string, receiptType: string | undefined, @@ -5996,67 +5997,67 @@ function savePreferredPaymentMethod(policyID: string, paymentMethod: PaymentMeth Onyx.merge(`${ONYXKEYS.NVP_LAST_PAYMENT_METHOD}`, {[policyID]: paymentMethod}); } -export type {GPSPoint as GpsPoint, IOURequestType}; export { - setMoneyRequestParticipants, + approveMoneyRequest, + canApproveIOU, + canIOUBePaid, + cancelPayment, + clearMoneyRequest, + completeSplitBill, createDistanceRequest, + createDraftTransaction, deleteMoneyRequest, deleteTrackExpense, - splitBill, - splitBillAndOpenReport, - setDraftSplitTransaction, - startSplitBill, - completeSplitBill, + detachReceipt, + editMoneyRequest, + initMoneyRequest, + navigateToStartStepIfScanFileCannotBeRead, + payMoneyRequest, + putOnHold, + replaceReceipt, requestMoney, + resetMoneyRequestInfo, + savePreferredPaymentMethod, sendMoneyElsewhere, - approveMoneyRequest, - submitReport, - payMoneyRequest, sendMoneyWithWallet, - initMoneyRequest, - startMoneyRequest, - resetMoneyRequestInfo, - clearMoneyRequest, - updateMoneyRequestTypeParams, + setDraftSplitTransaction, + setMoneyRequestAmount, setMoneyRequestAmount_temporaryForRefactor, + setMoneyRequestBillable, setMoneyRequestBillable_temporaryForRefactor, + setMoneyRequestCategory, setMoneyRequestCreated, + setMoneyRequestCurrency, setMoneyRequestCurrency_temporaryForRefactor, setMoneyRequestDescription, - setMoneyRequestParticipants_temporaryForRefactor, - setMoneyRequestPendingFields, - setMoneyRequestReceipt, - setMoneyRequestAmount, - setMoneyRequestBillable, - setMoneyRequestCategory, - setMoneyRequestCurrency, setMoneyRequestId, setMoneyRequestMerchant, + setMoneyRequestParticipants, setMoneyRequestParticipantsFromReport, + setMoneyRequestParticipants_temporaryForRefactor, + setMoneyRequestPendingFields, + setMoneyRequestReceipt, setMoneyRequestTag, setMoneyRequestTaxAmount, setMoneyRequestTaxRate, setShownHoldUseExplanation, - updateMoneyRequestDate, + splitBill, + splitBillAndOpenReport, + startMoneyRequest, + startSplitBill, + submitReport, + trackExpense, + unholdRequest, + updateMoneyRequestAmountAndCurrency, updateMoneyRequestBillable, + updateMoneyRequestCategory, + updateMoneyRequestDate, + updateMoneyRequestDescription, + updateMoneyRequestDistance, updateMoneyRequestMerchant, updateMoneyRequestTag, updateMoneyRequestTaxAmount, updateMoneyRequestTaxRate, - updateMoneyRequestDistance, - updateMoneyRequestCategory, - updateMoneyRequestAmountAndCurrency, - updateMoneyRequestDescription, - replaceReceipt, - detachReceipt, - editMoneyRequest, - putOnHold, - unholdRequest, - cancelPayment, - navigateToStartStepIfScanFileCannotBeRead, - savePreferredPaymentMethod, - trackExpense, - canIOUBePaid, - canApproveIOU, - createDraftTransaction, + updateMoneyRequestTypeParams, }; +export type {GPSPoint as GpsPoint, IOURequestType}; diff --git a/src/pages/home/report/ReportActionCompose/AttachmentPickerWithMenuItems.tsx b/src/pages/home/report/ReportActionCompose/AttachmentPickerWithMenuItems.tsx index ab24c6667ad4..1294d2ca8aea 100644 --- a/src/pages/home/report/ReportActionCompose/AttachmentPickerWithMenuItems.tsx +++ b/src/pages/home/report/ReportActionCompose/AttachmentPickerWithMenuItems.tsx @@ -3,7 +3,6 @@ import React, {useCallback, useEffect, useMemo} from 'react'; import {View} from 'react-native'; import type {OnyxEntry} from 'react-native-onyx'; import {withOnyx} from 'react-native-onyx'; -import type {ValueOf} from 'type-fest'; import type {FileObject} from '@components/AttachmentModal'; import AttachmentPicker from '@components/AttachmentPicker'; import Icon from '@components/Icon'; @@ -23,11 +22,12 @@ import * as ReportUtils from '@libs/ReportUtils'; import * as IOU from '@userActions/IOU'; import * as Report from '@userActions/Report'; import * as Task from '@userActions/Task'; +import type {IOUType} from '@src/CONST'; import CONST from '@src/CONST'; import ONYXKEYS from '@src/ONYXKEYS'; import type * as OnyxTypes from '@src/types/onyx'; -type MoneyRequestOptions = Record<ValueOf<typeof CONST.IOU.TYPE>, PopoverMenuItem>; +type MoneyRequestOptions = Record<IOUType, PopoverMenuItem>; type AttachmentPickerWithMenuItemsOnyxProps = { /** The policy tied to the report */ diff --git a/src/pages/iou/request/step/IOURequestStepParticipants.tsx b/src/pages/iou/request/step/IOURequestStepParticipants.tsx index 125c2a93b8a1..ff4c715223c1 100644 --- a/src/pages/iou/request/step/IOURequestStepParticipants.tsx +++ b/src/pages/iou/request/step/IOURequestStepParticipants.tsx @@ -2,36 +2,34 @@ import {useNavigation} from '@react-navigation/native'; import lodashIsEqual from 'lodash/isEqual'; import React, {useCallback, useEffect, useMemo, useRef} from 'react'; import type {OnyxEntry} from 'react-native-onyx'; -import type {ValueOf} from 'type-fest'; import useLocalize from '@hooks/useLocalize'; import * as IOUUtils from '@libs/IOUUtils'; import Navigation from '@libs/Navigation/Navigation'; import * as TransactionUtils from '@libs/TransactionUtils'; import MoneyRequestParticipantsSelector from '@pages/iou/request/MoneyTemporaryForRefactorRequestParticipantsSelector'; import * as IOU from '@userActions/IOU'; +import type {IOUType} from '@src/CONST'; import CONST from '@src/CONST'; import ROUTES from '@src/ROUTES'; import type SCREENS from '@src/SCREENS'; import type {Transaction} from '@src/types/onyx'; import type {Participant} from '@src/types/onyx/IOU'; import StepScreenWrapper from './StepScreenWrapper'; -import withFullTransactionOrNotFound from './withFullTransactionOrNotFound'; import type {WithFullTransactionOrNotFoundProps} from './withFullTransactionOrNotFound'; -import withWritableReportOrNotFound from './withWritableReportOrNotFound'; +import withFullTransactionOrNotFound from './withFullTransactionOrNotFound'; import type {WithWritableReportOrNotFoundProps} from './withWritableReportOrNotFound'; +import withWritableReportOrNotFound from './withWritableReportOrNotFound'; type IOURequestStepParticipantsOnyxProps = { /** The transaction object being modified in Onyx */ transaction: OnyxEntry<Transaction>; }; -type IOUValueType = ValueOf<typeof CONST.IOU.TYPE>; - type IOURequestStepParticipantsProps = IOURequestStepParticipantsOnyxProps & WithWritableReportOrNotFoundProps<typeof SCREENS.MONEY_REQUEST.STEP_PARTICIPANTS> & WithFullTransactionOrNotFoundProps<typeof SCREENS.MONEY_REQUEST.STEP_PARTICIPANTS>; -type IOURef = IOUValueType | null; +type IOURef = IOUType | null; function IOURequestStepParticipants({ route: { @@ -100,7 +98,7 @@ function IOURequestStepParticipants({ }, [participants, updateRouteParams]); const addParticipant = useCallback( - (val: Participant[], selectedIouType: IOUValueType) => { + (val: Participant[], selectedIouType: IOUType) => { const isSplit = selectedIouType === CONST.IOU.TYPE.SPLIT; // It's only possible to switch between REQUEST and SPLIT. // We want to update the IOU type only if it's not updated yet to prevent unnecessary updates. @@ -136,9 +134,9 @@ function IOURequestStepParticipants({ ); const goToNextStep = useCallback( - (selectedIouType: IOUValueType) => { + (selectedIouType: IOUType) => { const isSplit = selectedIouType === CONST.IOU.TYPE.SPLIT; - let nextStepIOUType: IOUValueType = CONST.IOU.TYPE.REQUEST; + let nextStepIOUType: IOUType = CONST.IOU.TYPE.REQUEST; if (isSplit && iouType !== CONST.IOU.TYPE.REQUEST) { nextStepIOUType = CONST.IOU.TYPE.SPLIT; From 7935c670ed484771b69b5d0ca0e80b0f3d77dbcd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?F=C3=A1bio=20Henriques?= <contact@fabiohenriques.dev> Date: Thu, 18 Apr 2024 10:59:53 +0100 Subject: [PATCH 175/206] Reduce string unions on ROUTES.ts --- src/ROUTES.ts | 99 ++++++++++++--------------- src/components/MoneyRequestHeader.tsx | 6 +- 2 files changed, 50 insertions(+), 55 deletions(-) diff --git a/src/ROUTES.ts b/src/ROUTES.ts index 7d73d8e55503..bd9454e38c7b 100644 --- a/src/ROUTES.ts +++ b/src/ROUTES.ts @@ -1,5 +1,6 @@ import type {ValueOf} from 'type-fest'; import type CONST from './CONST'; +import type {IOUAction, IOUType} from './CONST'; import type {IOURequestType} from './libs/actions/IOU'; import type AssertTypesNotEqual from './types/utils/AssertTypesNotEqual'; @@ -205,7 +206,7 @@ const ROUTES = { EDIT_REQUEST: { route: 'r/:threadReportID/edit/:field/:tagIndex?', getRoute: (threadReportID: string, field: ValueOf<typeof CONST.EDIT_REQUEST_FIELD>, tagIndex?: number) => - `r/${threadReportID}/edit/${field}${typeof tagIndex === 'number' ? `/${tagIndex}` : ''}` as const, + `r/${threadReportID}/edit/${field as string}${typeof tagIndex === 'number' ? `/${tagIndex}` : ''}` as const, }, EDIT_CURRENCY_REQUEST: { route: 'r/:threadReportID/edit/currency', @@ -274,7 +275,7 @@ const ROUTES = { EDIT_SPLIT_BILL: { route: `r/:reportID/split/:reportActionID/edit/:field/:tagIndex?`, getRoute: (reportID: string, reportActionID: string, field: ValueOf<typeof CONST.EDIT_REQUEST_FIELD>, tagIndex?: number) => - `r/${reportID}/split/${reportActionID}/edit/${field}${typeof tagIndex === 'number' ? `/${tagIndex}` : ''}` as const, + `r/${reportID}/split/${reportActionID}/edit/${field as string}${typeof tagIndex === 'number' ? `/${tagIndex}` : ''}` as const, }, TASK_TITLE: { route: 'r/:reportID/title', @@ -306,122 +307,112 @@ const ROUTES = { }, MONEY_REQUEST_PARTICIPANTS: { route: ':iouType/new/participants/:reportID?', - getRoute: (iouType: string, reportID = '') => `${iouType}/new/participants/${reportID}` as const, + getRoute: (iouType: IOUType, reportID = '') => `${iouType}/new/participants/${reportID}` as const, }, MONEY_REQUEST_HOLD_REASON: { - route: ':iouType/edit/reason/:transactionID?', - getRoute: (iouType: string, transactionID: string, reportID: string, backTo: string) => `${iouType}/edit/reason/${transactionID}?backTo=${backTo}&reportID=${reportID}` as const, + route: ':type/edit/reason/:transactionID?', + getRoute: (type: ValueOf<typeof CONST.POLICY.TYPE>, transactionID: string, reportID: string, backTo: string) => `${type}/edit/reason/${transactionID}?backTo=${backTo}&reportID=${reportID}` as const, }, MONEY_REQUEST_MERCHANT: { route: ':iouType/new/merchant/:reportID?', - getRoute: (iouType: string, reportID = '') => `${iouType}/new/merchant/${reportID}` as const, + getRoute: (iouType: IOUType, reportID = '') => `${iouType}/new/merchant/${reportID}` as const, }, MONEY_REQUEST_RECEIPT: { route: ':iouType/new/receipt/:reportID?', - getRoute: (iouType: string, reportID = '') => `${iouType}/new/receipt/${reportID}` as const, + getRoute: (iouType: IOUType, reportID = '') => `${iouType}/new/receipt/${reportID}` as const, }, MONEY_REQUEST_CREATE: { route: ':action/:iouType/start/:transactionID/:reportID', - getRoute: (action: ValueOf<typeof CONST.IOU.ACTION>, iouType: ValueOf<typeof CONST.IOU.TYPE>, transactionID: string, reportID: string) => - `${action}/${iouType}/start/${transactionID}/${reportID}` as const, + getRoute: (action: IOUAction, iouType: IOUType, transactionID: string, reportID: string) => `${action as string}/${iouType as string}/start/${transactionID}/${reportID}` as const, }, MONEY_REQUEST_STEP_CONFIRMATION: { route: ':action/:iouType/confirmation/:transactionID/:reportID', - getRoute: (action: ValueOf<typeof CONST.IOU.ACTION>, iouType: ValueOf<typeof CONST.IOU.TYPE>, transactionID: string, reportID: string) => - `${action}/${iouType}/confirmation/${transactionID}/${reportID}` as const, + getRoute: (action: IOUAction, iouType: IOUType, transactionID: string, reportID: string) => + `${action as string}/${iouType as string}/confirmation/${transactionID}/${reportID}` as const, }, MONEY_REQUEST_STEP_AMOUNT: { route: ':action/:iouType/amount/:transactionID/:reportID', - getRoute: (action: ValueOf<typeof CONST.IOU.ACTION>, iouType: ValueOf<typeof CONST.IOU.TYPE>, transactionID: string, reportID: string, backTo = '') => - getUrlWithBackToParam(`${action}/${iouType}/amount/${transactionID}/${reportID}`, backTo), + getRoute: (action: IOUAction, iouType: IOUType, transactionID: string, reportID: string, backTo = '') => + getUrlWithBackToParam(`${action as string}/${iouType as string}/amount/${transactionID}/${reportID}`, backTo), }, MONEY_REQUEST_STEP_TAX_RATE: { route: ':action/:iouType/taxRate/:transactionID/:reportID?', - getRoute: (action: ValueOf<typeof CONST.IOU.ACTION>, iouType: ValueOf<typeof CONST.IOU.TYPE>, transactionID: string, reportID: string, backTo = '') => - getUrlWithBackToParam(`${action}/${iouType}/taxRate/${transactionID}/${reportID}`, backTo), + getRoute: (action: IOUAction, iouType: IOUType, transactionID: string, reportID: string, backTo = '') => + getUrlWithBackToParam(`${action as string}/${iouType as string}/taxRate/${transactionID}/${reportID}`, backTo), }, MONEY_REQUEST_STEP_TAX_AMOUNT: { route: ':action/:iouType/taxAmount/:transactionID/:reportID?', - getRoute: (action: ValueOf<typeof CONST.IOU.ACTION>, iouType: ValueOf<typeof CONST.IOU.TYPE>, transactionID: string, reportID: string, backTo = '') => - getUrlWithBackToParam(`${action}/${iouType}/taxAmount/${transactionID}/${reportID}`, backTo), + getRoute: (action: IOUAction, iouType: IOUType, transactionID: string, reportID: string, backTo = '') => + getUrlWithBackToParam(`${action as string}/${iouType as string}/taxAmount/${transactionID}/${reportID}`, backTo), }, MONEY_REQUEST_STEP_CATEGORY: { route: ':action/:iouType/category/:transactionID/:reportID/:reportActionID?', - getRoute: (action: ValueOf<typeof CONST.IOU.ACTION>, iouType: ValueOf<typeof CONST.IOU.TYPE>, transactionID: string, reportID: string, backTo = '', reportActionID?: string) => - getUrlWithBackToParam(`${action}/${iouType}/category/${transactionID}/${reportID}${reportActionID ? `/${reportActionID}` : ''}`, backTo), + getRoute: (action: IOUAction, iouType: IOUType, transactionID: string, reportID: string, backTo = '', reportActionID?: string) => + getUrlWithBackToParam(`${action as string}/${iouType as string}/category/${transactionID}/${reportID}${reportActionID ? `/${reportActionID}` : ''}`, backTo), }, MONEY_REQUEST_STEP_CURRENCY: { route: ':action/:iouType/currency/:transactionID/:reportID/:pageIndex?', - getRoute: (action: ValueOf<typeof CONST.IOU.ACTION>, iouType: ValueOf<typeof CONST.IOU.TYPE>, transactionID: string, reportID: string, pageIndex = '', currency = '', backTo = '') => - getUrlWithBackToParam(`${action}/${iouType}/currency/${transactionID}/${reportID}/${pageIndex}?currency=${currency}`, backTo), + getRoute: (action: IOUAction, iouType: IOUType, transactionID: string, reportID: string, pageIndex = '', currency = '', backTo = '') => + getUrlWithBackToParam(`${action as string}/${iouType as string}/currency/${transactionID}/${reportID}/${pageIndex}?currency=${currency}`, backTo), }, MONEY_REQUEST_STEP_DATE: { route: ':action/:iouType/date/:transactionID/:reportID', - getRoute: (action: ValueOf<typeof CONST.IOU.ACTION>, iouType: ValueOf<typeof CONST.IOU.TYPE>, transactionID: string, reportID: string, backTo = '') => - getUrlWithBackToParam(`${action}/${iouType}/date/${transactionID}/${reportID}`, backTo), + getRoute: (action: IOUAction, iouType: IOUType, transactionID: string, reportID: string, backTo = '') => + getUrlWithBackToParam(`${action as string}/${iouType as string}/date/${transactionID}/${reportID}`, backTo), }, MONEY_REQUEST_STEP_DESCRIPTION: { route: ':action/:iouType/description/:transactionID/:reportID/:reportActionID?', - getRoute: (action: ValueOf<typeof CONST.IOU.ACTION>, iouType: ValueOf<typeof CONST.IOU.TYPE>, transactionID: string, reportID: string, backTo = '', reportActionID?: string) => - getUrlWithBackToParam(`${action}/${iouType}/description/${transactionID}/${reportID}${reportActionID ? `/${reportActionID}` : ''}`, backTo), + getRoute: (action: IOUAction, iouType: IOUType, transactionID: string, reportID: string, backTo = '', reportActionID?: string) => + getUrlWithBackToParam(`${action as string}/${iouType as string}/description/${transactionID}/${reportID}${reportActionID ? `/${reportActionID}` : ''}`, backTo), }, MONEY_REQUEST_STEP_DISTANCE: { route: ':action/:iouType/distance/:transactionID/:reportID', - getRoute: (action: ValueOf<typeof CONST.IOU.ACTION>, iouType: ValueOf<typeof CONST.IOU.TYPE>, transactionID: string, reportID: string, backTo = '') => - getUrlWithBackToParam(`${action}/${iouType}/distance/${transactionID}/${reportID}`, backTo), + getRoute: (action: IOUAction, iouType: IOUType, transactionID: string, reportID: string, backTo = '') => + getUrlWithBackToParam(`${action as string}/${iouType as string}/distance/${transactionID}/${reportID}`, backTo), }, MONEY_REQUEST_STEP_MERCHANT: { route: ':action/:iouType/merchant/:transactionID/:reportID', - getRoute: (action: ValueOf<typeof CONST.IOU.ACTION>, iouType: ValueOf<typeof CONST.IOU.TYPE>, transactionID: string, reportID: string, backTo = '') => - getUrlWithBackToParam(`${action}/${iouType}/merchant/${transactionID}/${reportID}`, backTo), + getRoute: (action: IOUAction, iouType: IOUType, transactionID: string, reportID: string, backTo = '') => + getUrlWithBackToParam(`${action as string}/${iouType as string}/merchant/${transactionID}/${reportID}`, backTo), }, MONEY_REQUEST_STEP_PARTICIPANTS: { route: ':action/:iouType/participants/:transactionID/:reportID', - getRoute: (iouType: ValueOf<typeof CONST.IOU.TYPE>, transactionID: string, reportID: string, backTo = '', action: ValueOf<typeof CONST.IOU.ACTION> = 'create') => - getUrlWithBackToParam(`${action}/${iouType}/participants/${transactionID}/${reportID}`, backTo), + getRoute: (iouType: IOUType, transactionID: string, reportID: string, backTo = '', action: IOUAction = 'create') => + getUrlWithBackToParam(`${action as string}/${iouType as string}/participants/${transactionID}/${reportID}`, backTo), }, MONEY_REQUEST_STEP_SCAN: { route: ':action/:iouType/scan/:transactionID/:reportID', - getRoute: (action: ValueOf<typeof CONST.IOU.ACTION>, iouType: ValueOf<typeof CONST.IOU.TYPE>, transactionID: string, reportID: string, backTo = '') => - getUrlWithBackToParam(`${action}/${iouType}/scan/${transactionID}/${reportID}`, backTo), + getRoute: (action: IOUAction, iouType: IOUType, transactionID: string, reportID: string, backTo = '') => + getUrlWithBackToParam(`${action as string}/${iouType as string}/scan/${transactionID}/${reportID}`, backTo), }, MONEY_REQUEST_STEP_TAG: { route: ':action/:iouType/tag/:orderWeight/:transactionID/:reportID/:reportActionID?', - getRoute: ( - action: ValueOf<typeof CONST.IOU.ACTION>, - iouType: ValueOf<typeof CONST.IOU.TYPE>, - orderWeight: number, - transactionID: string, - reportID: string, - backTo = '', - reportActionID?: string, - ) => getUrlWithBackToParam(`${action}/${iouType}/tag/${orderWeight}/${transactionID}/${reportID}${reportActionID ? `/${reportActionID}` : ''}`, backTo), + getRoute: (action: IOUAction, iouType: IOUType, orderWeight: number, transactionID: string, reportID: string, backTo = '', reportActionID?: string) => + getUrlWithBackToParam(`${action as string}/${iouType as string}/tag/${orderWeight}/${transactionID}/${reportID}${reportActionID ? `/${reportActionID}` : ''}`, backTo), }, MONEY_REQUEST_STEP_WAYPOINT: { route: ':action/:iouType/waypoint/:transactionID/:reportID/:pageIndex', - getRoute: (action: ValueOf<typeof CONST.IOU.ACTION>, iouType: ValueOf<typeof CONST.IOU.TYPE>, transactionID: string, reportID?: string, pageIndex = '', backTo = '') => - getUrlWithBackToParam(`${action}/${iouType}/waypoint/${transactionID}/${reportID}/${pageIndex}`, backTo), + getRoute: (action: IOUAction, iouType: IOUType, transactionID: string, reportID?: string, pageIndex = '', backTo = '') => + getUrlWithBackToParam(`${action as string}/${iouType as string}/waypoint/${transactionID}/${reportID}/${pageIndex}`, backTo), }, // This URL is used as a redirect to one of the create tabs below. This is so that we can message users with a link // straight to those flows without needing to have optimistic transaction and report IDs. MONEY_REQUEST_START: { route: 'start/:iouType/:iouRequestType', - getRoute: (iouType: ValueOf<typeof CONST.IOU.TYPE>, iouRequestType: IOURequestType) => `start/${iouType}/${iouRequestType}` as const, + getRoute: (iouType: IOUType, iouRequestType: IOURequestType) => `start/${iouType as string}/${iouRequestType}` as const, }, MONEY_REQUEST_CREATE_TAB_DISTANCE: { route: ':action/:iouType/start/:transactionID/:reportID/distance', - getRoute: (action: ValueOf<typeof CONST.IOU.ACTION>, iouType: ValueOf<typeof CONST.IOU.TYPE>, transactionID: string, reportID: string) => - `create/${iouType}/start/${transactionID}/${reportID}/distance` as const, + getRoute: (action: IOUAction, iouType: IOUType, transactionID: string, reportID: string) => `create/${iouType as string}/start/${transactionID}/${reportID}/distance` as const, }, MONEY_REQUEST_CREATE_TAB_MANUAL: { route: ':action/:iouType/start/:transactionID/:reportID/manual', - getRoute: (action: ValueOf<typeof CONST.IOU.ACTION>, iouType: ValueOf<typeof CONST.IOU.TYPE>, transactionID: string, reportID: string) => - `${action}/${iouType}/start/${transactionID}/${reportID}/manual` as const, + getRoute: (action: IOUAction, iouType: IOUType, transactionID: string, reportID: string) => + `${action as string}/${iouType as string}/start/${transactionID}/${reportID}/manual` as const, }, MONEY_REQUEST_CREATE_TAB_SCAN: { route: ':action/:iouType/start/:transactionID/:reportID/scan', - getRoute: (action: ValueOf<typeof CONST.IOU.ACTION>, iouType: ValueOf<typeof CONST.IOU.TYPE>, transactionID: string, reportID: string) => - `create/${iouType}/start/${transactionID}/${reportID}/scan` as const, + getRoute: (action: IOUAction, iouType: IOUType, transactionID: string, reportID: string) => `create/${iouType as string}/start/${transactionID}/${reportID}/scan` as const, }, MONEY_REQUEST_STATE_SELECTOR: { @@ -654,7 +645,7 @@ const ROUTES = { WORKSPACE_OWNER_CHANGE_CHECK: { route: 'settings/workspaces/:policyID/change-owner/:accountID/:error', getRoute: (policyID: string, accountID: number, error: ValueOf<typeof CONST.POLICY.OWNERSHIP_ERRORS>) => - `settings/workspaces/${policyID}/change-owner/${accountID}/${error}` as const, + `settings/workspaces/${policyID}/change-owner/${accountID}/${error as string}` as const, }, WORKSPACE_TAX_CREATE: { route: 'settings/workspaces/:policyID/taxes/new', @@ -742,7 +733,7 @@ const HYBRID_APP_ROUTES = { MONEY_REQUEST_CREATE: '/request/new/scan', } as const; -export {getUrlWithBackToParam, HYBRID_APP_ROUTES}; +export {HYBRID_APP_ROUTES, getUrlWithBackToParam}; export default ROUTES; // eslint-disable-next-line @typescript-eslint/no-explicit-any @@ -762,4 +753,4 @@ type RouteIsPlainString = AssertTypesNotEqual<string, Route, RoutesValidationErr type HybridAppRoute = (typeof HYBRID_APP_ROUTES)[keyof typeof HYBRID_APP_ROUTES]; -export type {Route, HybridAppRoute}; +export type {HybridAppRoute, Route}; diff --git a/src/components/MoneyRequestHeader.tsx b/src/components/MoneyRequestHeader.tsx index f7825ef2f622..da087c57fcba 100644 --- a/src/components/MoneyRequestHeader.tsx +++ b/src/components/MoneyRequestHeader.tsx @@ -96,8 +96,12 @@ function MoneyRequestHeader({session, parentReport, report, parentReportAction, if (isOnHold) { IOU.unholdRequest(iouTransactionID, report?.reportID); } else { + if (!policy?.type) { + return; + } + const activeRoute = encodeURIComponent(Navigation.getActiveRouteWithoutParams()); - Navigation.navigate(ROUTES.MONEY_REQUEST_HOLD_REASON.getRoute(policy?.type ?? '', iouTransactionID, report?.reportID, activeRoute)); + Navigation.navigate(ROUTES.MONEY_REQUEST_HOLD_REASON.getRoute(policy.type, iouTransactionID, report?.reportID, activeRoute)); } }; From 728dc1035e4e80653b6d5a403c38b9c78d26e606 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?F=C3=A1bio=20Henriques?= <contact@fabiohenriques.dev> Date: Thu, 18 Apr 2024 11:32:24 +0100 Subject: [PATCH 176/206] Fix prettier --- src/ROUTES.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/ROUTES.ts b/src/ROUTES.ts index bd9454e38c7b..69bf075adcf7 100644 --- a/src/ROUTES.ts +++ b/src/ROUTES.ts @@ -311,7 +311,8 @@ const ROUTES = { }, MONEY_REQUEST_HOLD_REASON: { route: ':type/edit/reason/:transactionID?', - getRoute: (type: ValueOf<typeof CONST.POLICY.TYPE>, transactionID: string, reportID: string, backTo: string) => `${type}/edit/reason/${transactionID}?backTo=${backTo}&reportID=${reportID}` as const, + getRoute: (type: ValueOf<typeof CONST.POLICY.TYPE>, transactionID: string, reportID: string, backTo: string) => + `${type}/edit/reason/${transactionID}?backTo=${backTo}&reportID=${reportID}` as const, }, MONEY_REQUEST_MERCHANT: { route: ':iouType/new/merchant/:reportID?', From 86cb0467967ad23d028feaaead91cd9bf9402f0f Mon Sep 17 00:00:00 2001 From: FitseTLT <engfitsum@gmail.com> Date: Thu, 18 Apr 2024 13:52:25 +0300 Subject: [PATCH 177/206] removed server logging code --- src/libs/ReportUtils.ts | 11 +---------- src/pages/home/report/ReportActionItemMessage.tsx | 2 +- 2 files changed, 2 insertions(+), 11 deletions(-) diff --git a/src/libs/ReportUtils.ts b/src/libs/ReportUtils.ts index 28a0f6b385bb..d1fe14271749 100644 --- a/src/libs/ReportUtils.ts +++ b/src/libs/ReportUtils.ts @@ -5458,7 +5458,7 @@ function getTaskAssigneeChatOnyxData( /** * Return iou report action display message */ -function getIOUReportActionDisplayMessage(reportAction: OnyxEntry<ReportAction>, transaction?: OnyxEntry<Transaction>, shouldLog = false): string { +function getIOUReportActionDisplayMessage(reportAction: OnyxEntry<ReportAction>, transaction?: OnyxEntry<Transaction>): string { if (reportAction?.actionName !== CONST.REPORT.ACTIONS.TYPE.IOU) { return ''; } @@ -5488,15 +5488,6 @@ function getIOUReportActionDisplayMessage(reportAction: OnyxEntry<ReportAction>, return Localize.translateLocal(translationKey, {amount: formattedAmount, payer: ''}); } - // This log to server is temporary and needed to determine if there is a case we need the transaction param - // when we call getIOUReportActionDisplayMessage from ReportActionItemMessage - if (shouldLog) { - Log.alert('Transaction Param Used when getIOUReportActionDisplayMessage was called from ReportActionItemMessage', { - reportActionID: reportAction.reportActionID, - originalMessageType: originalMessage.type, - }); - } - const transactionDetails = getTransactionDetails(!isEmptyObject(transaction) ? transaction : null); const formattedAmount = CurrencyUtils.convertToDisplayString(transactionDetails?.amount ?? 0, transactionDetails?.currency); const isRequestSettled = isSettled(originalMessage.IOUReportID); diff --git a/src/pages/home/report/ReportActionItemMessage.tsx b/src/pages/home/report/ReportActionItemMessage.tsx index b2f120f16ef4..35bf2507ba64 100644 --- a/src/pages/home/report/ReportActionItemMessage.tsx +++ b/src/pages/home/report/ReportActionItemMessage.tsx @@ -66,7 +66,7 @@ function ReportActionItemMessage({action, transaction, displayAsGroup, reportID, const originalMessage = action.actionName === CONST.REPORT.ACTIONS.TYPE.IOU ? action.originalMessage : null; const iouReportID = originalMessage?.IOUReportID; if (iouReportID) { - iouMessage = ReportUtils.getIOUReportActionDisplayMessage(action, transaction, true); + iouMessage = ReportUtils.getIOUReportActionDisplayMessage(action, transaction); } } From 57aa026053ac3dd0f2e63e86197da99f3dc12b16 Mon Sep 17 00:00:00 2001 From: FitseTLT <engfitsum@gmail.com> Date: Thu, 18 Apr 2024 14:00:58 +0300 Subject: [PATCH 178/206] remove unnecessary import --- src/libs/ReportUtils.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/src/libs/ReportUtils.ts b/src/libs/ReportUtils.ts index d1fe14271749..34f7614a2773 100644 --- a/src/libs/ReportUtils.ts +++ b/src/libs/ReportUtils.ts @@ -63,7 +63,6 @@ import isReportMessageAttachment from './isReportMessageAttachment'; import localeCompare from './LocaleCompare'; import * as LocalePhoneNumber from './LocalePhoneNumber'; import * as Localize from './Localize'; -import Log from './Log'; import {isEmailPublicDomain} from './LoginUtils'; import ModifiedExpenseMessage from './ModifiedExpenseMessage'; import linkingConfig from './Navigation/linkingConfig'; From f74c3d57b869345a252af45e45616a2c5a57f427 Mon Sep 17 00:00:00 2001 From: Wojciech Boman <wojciechboman@gmail.com> Date: Thu, 18 Apr 2024 13:20:18 +0200 Subject: [PATCH 179/206] Fix setting current selectedItemIndex --- src/components/PopoverMenu.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/PopoverMenu.tsx b/src/components/PopoverMenu.tsx index 7baf8bb8830e..ca4adc5109bd 100644 --- a/src/components/PopoverMenu.tsx +++ b/src/components/PopoverMenu.tsx @@ -105,8 +105,8 @@ function PopoverMenu({ setCurrentMenuItems([...selectedItem.subMenuItems]); setEnteredSubMenuIndexes([...enteredSubMenuIndexes, index]); } else { - onItemSelected(selectedItem, index); selectedItemIndex.current = index; + onItemSelected(selectedItem, index); } }; From 35798b945b4edd09d9285ebaa80bcba6c11e7724 Mon Sep 17 00:00:00 2001 From: Alberto <alberto@expensify.com> Date: Thu, 18 Apr 2024 13:21:55 +0200 Subject: [PATCH 180/206] Add label --- src/languages/en.ts | 1 + src/languages/es.ts | 1 + 2 files changed, 2 insertions(+) diff --git a/src/languages/en.ts b/src/languages/en.ts index ed2587e5e2c6..796d797a69ef 100755 --- a/src/languages/en.ts +++ b/src/languages/en.ts @@ -612,6 +612,7 @@ export default { card: 'Card', original: 'Original', split: 'Split', + request: 'Request', splitExpense: 'Split expense', paySomeone: ({name}: PaySomeoneParams) => `Pay ${name ?? 'someone'}`, expense: 'Expense', diff --git a/src/languages/es.ts b/src/languages/es.ts index beb654cf0bc4..df2daa3c5c6a 100644 --- a/src/languages/es.ts +++ b/src/languages/es.ts @@ -605,6 +605,7 @@ export default { card: 'Tarjeta', original: 'Original', split: 'Dividir', + request: 'Solicitar', splitExpense: 'Dividir gasto', expense: 'Gasto', categorize: 'Categorizar', From cc49be75acc91d5301299641cc6b647aa34741b5 Mon Sep 17 00:00:00 2001 From: Monil Bhavsar <monil@expensify.com> Date: Thu, 18 Apr 2024 17:53:03 +0530 Subject: [PATCH 181/206] Fix: Displaying member options --- src/pages/workspace/WorkspaceMembersPage.tsx | 48 ++++++++++++-------- 1 file changed, 30 insertions(+), 18 deletions(-) diff --git a/src/pages/workspace/WorkspaceMembersPage.tsx b/src/pages/workspace/WorkspaceMembersPage.tsx index 9c5631eff0aa..9158e49b234a 100644 --- a/src/pages/workspace/WorkspaceMembersPage.tsx +++ b/src/pages/workspace/WorkspaceMembersPage.tsx @@ -39,7 +39,13 @@ import CONST from '@src/CONST'; import ONYXKEYS from '@src/ONYXKEYS'; import ROUTES from '@src/ROUTES'; import type SCREENS from '@src/SCREENS'; -import type {InvitedEmailsToAccountIDs, PersonalDetailsList, PolicyEmployee, PolicyEmployeeList, Session} from '@src/types/onyx'; +import type { + InvitedEmailsToAccountIDs, + PersonalDetailsList, + PolicyEmployee, + PolicyEmployeeList, + Session +} from '@src/types/onyx'; import type {Errors, PendingAction} from '@src/types/onyx/OnyxCommon'; import {isEmptyObject} from '@src/types/utils/EmptyObject'; import type {WithPolicyAndFullscreenLoadingProps} from './withPolicyAndFullscreenLoading'; @@ -467,24 +473,30 @@ function WorkspaceMembersPage({personalDetails, invitedEmailsToAccountIDsDraft, }, ]; - if (PolicyUtils.isPaidGroupPolicy(policy)) { - if (selectedEmployees.find((employeeEmail) => policy?.employeeList?.[policyMemberEmailsToAccountIDs[employeeEmail]]?.role === CONST.POLICY.ROLE.ADMIN)) { - options.push({ - text: translate('workspace.people.makeMember'), - value: CONST.POLICY.MEMBERS_BULK_ACTION_TYPES.MAKE_MEMBER, - icon: Expensicons.User, - onSelected: () => changeUserRole(CONST.POLICY.ROLE.USER), - }); - } + if (!PolicyUtils.isPaidGroupPolicy(policy)) { + return options; + } - if (selectedEmployees.find((employeeEmail) => policy?.employeeList?.[policyMemberEmailsToAccountIDs[employeeEmail]]?.role === CONST.POLICY.ROLE.USER)) { - options.push({ - text: translate('workspace.people.makeAdmin'), - value: CONST.POLICY.MEMBERS_BULK_ACTION_TYPES.MAKE_ADMIN, - icon: Expensicons.MakeAdmin, - onSelected: () => changeUserRole(CONST.POLICY.ROLE.ADMIN), - }); - } + const selectedEmployeesRoles = selectedEmployees.map(accountID => { + const email = Object.keys(policyMemberEmailsToAccountIDs).find(email => policyMemberEmailsToAccountIDs[email] === accountID) ?? ''; + return policy?.employeeList?.[email]?.role; + }); + if (selectedEmployeesRoles.find((role) => role === CONST.POLICY.ROLE.ADMIN)) { + options.push({ + text: translate('workspace.people.makeMember'), + value: CONST.POLICY.MEMBERS_BULK_ACTION_TYPES.MAKE_MEMBER, + icon: Expensicons.User, + onSelected: () => changeUserRole(CONST.POLICY.ROLE.USER), + }); + } + + if (selectedEmployeesRoles.find((role) => role === CONST.POLICY.ROLE.USER)) { + options.push({ + text: translate('workspace.people.makeAdmin'), + value: CONST.POLICY.MEMBERS_BULK_ACTION_TYPES.MAKE_ADMIN, + icon: Expensicons.MakeAdmin, + onSelected: () => changeUserRole(CONST.POLICY.ROLE.ADMIN), + }); } return options; }; From 39b95acf7cc83d67271654baf0f136089aeaa238 Mon Sep 17 00:00:00 2001 From: Monil Bhavsar <monil@expensify.com> Date: Thu, 18 Apr 2024 18:14:33 +0530 Subject: [PATCH 182/206] Fix change user method --- src/pages/workspace/WorkspaceMembersPage.tsx | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/pages/workspace/WorkspaceMembersPage.tsx b/src/pages/workspace/WorkspaceMembersPage.tsx index 9158e49b234a..25e216204237 100644 --- a/src/pages/workspace/WorkspaceMembersPage.tsx +++ b/src/pages/workspace/WorkspaceMembersPage.tsx @@ -457,7 +457,10 @@ function WorkspaceMembersPage({personalDetails, invitedEmailsToAccountIDsDraft, return; } - const accountIDsToUpdate = selectedEmployees.filter((id) => policy?.employeeList?.[policyMemberEmailsToAccountIDs[id]]?.role !== role); + const accountIDsToUpdate = selectedEmployees.filter((accountID) => { + const email = Object.keys(policyMemberEmailsToAccountIDs).find(email => policyMemberEmailsToAccountIDs[email] === accountID) ?? ''; + return policy?.employeeList?.[email]?.role !== role; + }); Policy.updateWorkspaceMembersRole(route.params.policyID, accountIDsToUpdate, role); setSelectedEmployees([]); From 5cf9d2dd9ccbc07aa8708c056da9d40f0d67abbf Mon Sep 17 00:00:00 2001 From: Monil Bhavsar <monil@expensify.com> Date: Thu, 18 Apr 2024 18:34:23 +0530 Subject: [PATCH 183/206] Use personal details object --- src/pages/workspace/WorkspaceMembersPage.tsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/pages/workspace/WorkspaceMembersPage.tsx b/src/pages/workspace/WorkspaceMembersPage.tsx index 25e216204237..4114026145c0 100644 --- a/src/pages/workspace/WorkspaceMembersPage.tsx +++ b/src/pages/workspace/WorkspaceMembersPage.tsx @@ -458,7 +458,7 @@ function WorkspaceMembersPage({personalDetails, invitedEmailsToAccountIDsDraft, } const accountIDsToUpdate = selectedEmployees.filter((accountID) => { - const email = Object.keys(policyMemberEmailsToAccountIDs).find(email => policyMemberEmailsToAccountIDs[email] === accountID) ?? ''; + const email = personalDetails?.[accountID]?.login ?? ''; return policy?.employeeList?.[email]?.role !== role; }); @@ -481,7 +481,7 @@ function WorkspaceMembersPage({personalDetails, invitedEmailsToAccountIDsDraft, } const selectedEmployeesRoles = selectedEmployees.map(accountID => { - const email = Object.keys(policyMemberEmailsToAccountIDs).find(email => policyMemberEmailsToAccountIDs[email] === accountID) ?? ''; + const email = personalDetails?.[accountID]?.login ?? ''; return policy?.employeeList?.[email]?.role; }); if (selectedEmployeesRoles.find((role) => role === CONST.POLICY.ROLE.ADMIN)) { From 8377e34d2ce554fd62318846b50d084fa634621c Mon Sep 17 00:00:00 2001 From: Monil Bhavsar <monil@expensify.com> Date: Thu, 18 Apr 2024 18:43:32 +0530 Subject: [PATCH 184/206] Run prettier --- src/pages/workspace/WorkspaceMembersPage.tsx | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/src/pages/workspace/WorkspaceMembersPage.tsx b/src/pages/workspace/WorkspaceMembersPage.tsx index 4114026145c0..d475a916e0d4 100644 --- a/src/pages/workspace/WorkspaceMembersPage.tsx +++ b/src/pages/workspace/WorkspaceMembersPage.tsx @@ -39,13 +39,7 @@ import CONST from '@src/CONST'; import ONYXKEYS from '@src/ONYXKEYS'; import ROUTES from '@src/ROUTES'; import type SCREENS from '@src/SCREENS'; -import type { - InvitedEmailsToAccountIDs, - PersonalDetailsList, - PolicyEmployee, - PolicyEmployeeList, - Session -} from '@src/types/onyx'; +import type {InvitedEmailsToAccountIDs, PersonalDetailsList, PolicyEmployee, PolicyEmployeeList, Session} from '@src/types/onyx'; import type {Errors, PendingAction} from '@src/types/onyx/OnyxCommon'; import {isEmptyObject} from '@src/types/utils/EmptyObject'; import type {WithPolicyAndFullscreenLoadingProps} from './withPolicyAndFullscreenLoading'; @@ -480,7 +474,7 @@ function WorkspaceMembersPage({personalDetails, invitedEmailsToAccountIDsDraft, return options; } - const selectedEmployeesRoles = selectedEmployees.map(accountID => { + const selectedEmployeesRoles = selectedEmployees.map((accountID) => { const email = personalDetails?.[accountID]?.login ?? ''; return policy?.employeeList?.[email]?.role; }); From 838c5f3dd6c2c80b0dedff5f5c936c80bcf6be0a Mon Sep 17 00:00:00 2001 From: Wojciech Boman <wojciechboman@gmail.com> Date: Thu, 18 Apr 2024 15:27:51 +0200 Subject: [PATCH 185/206] Fix scrolling to last index in SelectionList using keyboard --- src/components/SelectionList/BaseSelectionList.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/SelectionList/BaseSelectionList.tsx b/src/components/SelectionList/BaseSelectionList.tsx index b24fe5351fad..9ab89aa73f86 100644 --- a/src/components/SelectionList/BaseSelectionList.tsx +++ b/src/components/SelectionList/BaseSelectionList.tsx @@ -228,7 +228,7 @@ function BaseSelectionList<TItem extends ListItem>( // If `initiallyFocusedOptionKey` is not passed, we fall back to `-1`, to avoid showing the highlight on the first member const [focusedIndex, setFocusedIndex] = useArrowKeyFocusManager({ initialFocusedIndex: flattenedSections.allOptions.findIndex((option) => option.keyForList === initiallyFocusedOptionKey), - maxIndex: flattenedSections.allOptions.length - 1, + maxIndex: Math.min(flattenedSections.allOptions.length, CONST.MAX_OPTIONS_SELECTOR_PAGE_LENGTH * currentPage - 1), isActive: true, onFocusedIndexChange: (index: number) => { scrollToIndex(index, true); From af29274df12ceb04da79f819667e62d911f69574 Mon Sep 17 00:00:00 2001 From: Alberto <alberto@expensify.com> Date: Thu, 18 Apr 2024 15:33:15 +0200 Subject: [PATCH 186/206] fix conflict issue --- .../iou/request/step/IOURequestStepScan/index.native.tsx | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/pages/iou/request/step/IOURequestStepScan/index.native.tsx b/src/pages/iou/request/step/IOURequestStepScan/index.native.tsx index 84c2137dafda..4ec17f7d14cd 100644 --- a/src/pages/iou/request/step/IOURequestStepScan/index.native.tsx +++ b/src/pages/iou/request/step/IOURequestStepScan/index.native.tsx @@ -295,14 +295,15 @@ function IOURequestStepScan({ const source = `file://${photo.path}`; IOU.setMoneyRequestReceipt(transactionID, source, photo.path, action !== CONST.IOU.ACTION.EDIT); - FileUtils.readFileAsync(source, photo.path, (file) => { if (action === CONST.IOU.ACTION.EDIT) { + FileUtils.readFileAsync(source, photo.path, (file) => { updateScanAndNavigate(file, source); + }); return; } + setDidCapturePhoto(true); navigateToConfirmationStep(file, source); - }); }) .catch((error: string) => { setDidCapturePhoto(false); From d89c34c6eb46e52ab33a36c1ac432751fe1eb960 Mon Sep 17 00:00:00 2001 From: Alberto <alberto@expensify.com> Date: Thu, 18 Apr 2024 15:57:21 +0200 Subject: [PATCH 187/206] undo last change. I was wrong --- .../iou/request/step/IOURequestStepScan/index.native.tsx | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/pages/iou/request/step/IOURequestStepScan/index.native.tsx b/src/pages/iou/request/step/IOURequestStepScan/index.native.tsx index 4ec17f7d14cd..84c2137dafda 100644 --- a/src/pages/iou/request/step/IOURequestStepScan/index.native.tsx +++ b/src/pages/iou/request/step/IOURequestStepScan/index.native.tsx @@ -295,15 +295,14 @@ function IOURequestStepScan({ const source = `file://${photo.path}`; IOU.setMoneyRequestReceipt(transactionID, source, photo.path, action !== CONST.IOU.ACTION.EDIT); + FileUtils.readFileAsync(source, photo.path, (file) => { if (action === CONST.IOU.ACTION.EDIT) { - FileUtils.readFileAsync(source, photo.path, (file) => { updateScanAndNavigate(file, source); - }); return; } - setDidCapturePhoto(true); navigateToConfirmationStep(file, source); + }); }) .catch((error: string) => { setDidCapturePhoto(false); From 68b1ede3e2b740a99de3b9e3b5fbb6ec64b8f37d Mon Sep 17 00:00:00 2001 From: Alberto <alberto@expensify.com> Date: Thu, 18 Apr 2024 16:11:57 +0200 Subject: [PATCH 188/206] Update button copy --- src/languages/en.ts | 1 - src/languages/es.ts | 1 - src/pages/iou/request/step/IOURequestStepDistance.tsx | 2 +- src/pages/iou/steps/MoneyRequestAmountForm.tsx | 2 +- 4 files changed, 2 insertions(+), 4 deletions(-) diff --git a/src/languages/en.ts b/src/languages/en.ts index 796d797a69ef..ed2587e5e2c6 100755 --- a/src/languages/en.ts +++ b/src/languages/en.ts @@ -612,7 +612,6 @@ export default { card: 'Card', original: 'Original', split: 'Split', - request: 'Request', splitExpense: 'Split expense', paySomeone: ({name}: PaySomeoneParams) => `Pay ${name ?? 'someone'}`, expense: 'Expense', diff --git a/src/languages/es.ts b/src/languages/es.ts index df2daa3c5c6a..beb654cf0bc4 100644 --- a/src/languages/es.ts +++ b/src/languages/es.ts @@ -605,7 +605,6 @@ export default { card: 'Tarjeta', original: 'Original', split: 'Dividir', - request: 'Solicitar', splitExpense: 'Dividir gasto', expense: 'Gasto', categorize: 'Categorizar', diff --git a/src/pages/iou/request/step/IOURequestStepDistance.tsx b/src/pages/iou/request/step/IOURequestStepDistance.tsx index 63e8f56af108..0602c2184365 100644 --- a/src/pages/iou/request/step/IOURequestStepDistance.tsx +++ b/src/pages/iou/request/step/IOURequestStepDistance.tsx @@ -113,7 +113,7 @@ function IOURequestStepDistance({ }, [report, skipConfirmation, policy, iouType]); let buttonText = !isCreatingNewRequest ? translate('common.save') : translate('common.next'); if (shouldSkipConfirmation) { - buttonText = iouType === CONST.IOU.TYPE.SPLIT ? translate('iou.split') : translate('iou.request'); + buttonText = iouType === CONST.IOU.TYPE.SPLIT ? translate('iou.split') : translate('iou.submitExpense'); } useEffect(() => { diff --git a/src/pages/iou/steps/MoneyRequestAmountForm.tsx b/src/pages/iou/steps/MoneyRequestAmountForm.tsx index 3529e67c5b1d..75d8ca6f1bf9 100644 --- a/src/pages/iou/steps/MoneyRequestAmountForm.tsx +++ b/src/pages/iou/steps/MoneyRequestAmountForm.tsx @@ -316,7 +316,7 @@ function MoneyRequestAmountForm( const formattedAmount = MoneyRequestUtils.replaceAllDigits(currentAmount, toLocaleDigit); let buttonText = isEditing ? translate('common.save') : translate('common.next'); if (skipConfirmation) { - buttonText = iouType === CONST.IOU.TYPE.SPLIT ? translate('iou.split') : translate('iou.request'); + buttonText = iouType === CONST.IOU.TYPE.SPLIT ? translate('iou.split') : translate('iou.submitExpense'); } const canUseTouchScreen = DeviceCapabilities.canUseTouchScreen(); From 4ae3c5d2f07ba4b27eb5de422aeca86f68e88906 Mon Sep 17 00:00:00 2001 From: Alberto <alberto@expensify.com> Date: Thu, 18 Apr 2024 16:36:20 +0200 Subject: [PATCH 189/206] better buttons --- .../iou/steps/MoneyRequestAmountForm.tsx | 20 ++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/src/pages/iou/steps/MoneyRequestAmountForm.tsx b/src/pages/iou/steps/MoneyRequestAmountForm.tsx index 75d8ca6f1bf9..87362baea3b5 100644 --- a/src/pages/iou/steps/MoneyRequestAmountForm.tsx +++ b/src/pages/iou/steps/MoneyRequestAmountForm.tsx @@ -1,6 +1,6 @@ import {useIsFocused} from '@react-navigation/core'; import type {ForwardedRef} from 'react'; -import React, {useCallback, useEffect, useRef, useState} from 'react'; +import React, {useCallback, useEffect, useMemo, useRef, useState} from 'react'; import {View} from 'react-native'; import type {NativeSyntheticEvent, TextInputSelectionChangeEventData} from 'react-native'; import type {ValueOf} from 'type-fest'; @@ -21,6 +21,7 @@ import getOperatingSystem from '@libs/getOperatingSystem'; import type {MaybePhraseKey} from '@libs/Localize'; import * as MoneyRequestUtils from '@libs/MoneyRequestUtils'; import Navigation from '@libs/Navigation/Navigation'; +import * as ReportUtils from '@libs/ReportUtils'; import type {BaseTextInputRef} from '@src/components/TextInput/BaseTextInput/types'; import CONST from '@src/CONST'; import type {Route} from '@src/ROUTES'; @@ -314,10 +315,19 @@ function MoneyRequestAmountForm( }; const formattedAmount = MoneyRequestUtils.replaceAllDigits(currentAmount, toLocaleDigit); - let buttonText = isEditing ? translate('common.save') : translate('common.next'); - if (skipConfirmation) { - buttonText = iouType === CONST.IOU.TYPE.SPLIT ? translate('iou.split') : translate('iou.submitExpense'); - } + const buttonText: string = useMemo(() => { + if (skipConfirmation) { + if (currentAmount !== '') { + const currencyAmount = CurrencyUtils.convertToDisplayString(CurrencyUtils.convertToBackendAmount(Number.parseFloat(currentAmount)), currency) ?? ''; + const text = iouType === CONST.IOU.TYPE.SPLIT ? translate('iou.splitAmount', {amount: currencyAmount}) : translate('iou.submitAmount', {amount: currencyAmount}); + return text[0].toUpperCase() + text.slice(1); + } else { + return iouType === CONST.IOU.TYPE.SPLIT ? translate('iou.splitExpense') : translate('iou.submitExpense'); + } + } + return isEditing ? translate('common.save') : translate('common.next'); + }, [skipConfirmation, iouType, currentAmount, currency]); + const canUseTouchScreen = DeviceCapabilities.canUseTouchScreen(); useEffect(() => { From 6379702471070a9ed6f4da479fb85d7c62efb071 Mon Sep 17 00:00:00 2001 From: Alberto <alberto@expensify.com> Date: Thu, 18 Apr 2024 16:48:18 +0200 Subject: [PATCH 190/206] lint --- src/pages/iou/steps/MoneyRequestAmountForm.tsx | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/pages/iou/steps/MoneyRequestAmountForm.tsx b/src/pages/iou/steps/MoneyRequestAmountForm.tsx index 87362baea3b5..66d04a845de0 100644 --- a/src/pages/iou/steps/MoneyRequestAmountForm.tsx +++ b/src/pages/iou/steps/MoneyRequestAmountForm.tsx @@ -21,7 +21,6 @@ import getOperatingSystem from '@libs/getOperatingSystem'; import type {MaybePhraseKey} from '@libs/Localize'; import * as MoneyRequestUtils from '@libs/MoneyRequestUtils'; import Navigation from '@libs/Navigation/Navigation'; -import * as ReportUtils from '@libs/ReportUtils'; import type {BaseTextInputRef} from '@src/components/TextInput/BaseTextInput/types'; import CONST from '@src/CONST'; import type {Route} from '@src/ROUTES'; @@ -321,9 +320,8 @@ function MoneyRequestAmountForm( const currencyAmount = CurrencyUtils.convertToDisplayString(CurrencyUtils.convertToBackendAmount(Number.parseFloat(currentAmount)), currency) ?? ''; const text = iouType === CONST.IOU.TYPE.SPLIT ? translate('iou.splitAmount', {amount: currencyAmount}) : translate('iou.submitAmount', {amount: currencyAmount}); return text[0].toUpperCase() + text.slice(1); - } else { - return iouType === CONST.IOU.TYPE.SPLIT ? translate('iou.splitExpense') : translate('iou.submitExpense'); } + return iouType === CONST.IOU.TYPE.SPLIT ? translate('iou.splitExpense') : translate('iou.submitExpense'); } return isEditing ? translate('common.save') : translate('common.next'); }, [skipConfirmation, iouType, currentAmount, currency]); From aa3a0cd74ae45990d167da430be7fd475a1af640 Mon Sep 17 00:00:00 2001 From: Alberto <alberto@expensify.com> Date: Thu, 18 Apr 2024 16:55:45 +0200 Subject: [PATCH 191/206] dependencies --- src/pages/iou/steps/MoneyRequestAmountForm.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pages/iou/steps/MoneyRequestAmountForm.tsx b/src/pages/iou/steps/MoneyRequestAmountForm.tsx index 66d04a845de0..a5ed35374e00 100644 --- a/src/pages/iou/steps/MoneyRequestAmountForm.tsx +++ b/src/pages/iou/steps/MoneyRequestAmountForm.tsx @@ -324,7 +324,7 @@ function MoneyRequestAmountForm( return iouType === CONST.IOU.TYPE.SPLIT ? translate('iou.splitExpense') : translate('iou.submitExpense'); } return isEditing ? translate('common.save') : translate('common.next'); - }, [skipConfirmation, iouType, currentAmount, currency]); + }, [skipConfirmation, iouType, currentAmount, currency, isEditing, translate]); const canUseTouchScreen = DeviceCapabilities.canUseTouchScreen(); From 3b7a83dc0eb5abf875f8ed9cf7ebad4f5c01200f Mon Sep 17 00:00:00 2001 From: Wojciech Boman <wojciechboman@gmail.com> Date: Thu, 18 Apr 2024 17:03:36 +0200 Subject: [PATCH 192/206] Handle displaying FAB on the new search page --- .../FloatingActionButtonAndPopover.tsx | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/src/pages/home/sidebar/SidebarScreen/FloatingActionButtonAndPopover.tsx b/src/pages/home/sidebar/SidebarScreen/FloatingActionButtonAndPopover.tsx index 212bf93166a1..872a6072527e 100644 --- a/src/pages/home/sidebar/SidebarScreen/FloatingActionButtonAndPopover.tsx +++ b/src/pages/home/sidebar/SidebarScreen/FloatingActionButtonAndPopover.tsx @@ -1,4 +1,4 @@ -import {useIsFocused} from '@react-navigation/native'; +import {useIsFocused as useIsFocusedOriginal, useNavigationState} from '@react-navigation/native'; import type {ImageContentFit} from 'expo-image'; import type {ForwardedRef, RefAttributes} from 'react'; import React, {forwardRef, useCallback, useEffect, useImperativeHandle, useMemo, useRef, useState} from 'react'; @@ -15,6 +15,7 @@ import usePrevious from '@hooks/usePrevious'; import useThemeStyles from '@hooks/useThemeStyles'; import useWindowDimensions from '@hooks/useWindowDimensions'; import interceptAnonymousUser from '@libs/interceptAnonymousUser'; +import getTopmostCentralPaneRoute from '@libs/Navigation/getTopmostCentralPaneRoute'; import * as ReportUtils from '@libs/ReportUtils'; import * as App from '@userActions/App'; import * as IOU from '@userActions/IOU'; @@ -24,10 +25,20 @@ import * as Task from '@userActions/Task'; import CONST from '@src/CONST'; import type {TranslationPaths} from '@src/languages/types'; import ONYXKEYS from '@src/ONYXKEYS'; +import SCREENS from '@src/SCREENS'; import type * as OnyxTypes from '@src/types/onyx'; import type {QuickActionName} from '@src/types/onyx/QuickAction'; import {isEmptyObject} from '@src/types/utils/EmptyObject'; +// On small screen we hide the search page from central pane to show the search bottom tab page with bottom tab bar. +// We need to take this in consideration when checking if the screen is focused. +const useIsFocused = () => { + const {isSmallScreenWidth} = useWindowDimensions(); + const isFocused = useIsFocusedOriginal(); + const topmostCentralPane = useNavigationState(getTopmostCentralPaneRoute); + return isFocused || (topmostCentralPane?.name === SCREENS.SEARCH.CENTRAL_PANE && isSmallScreenWidth); +}; + type PolicySelector = Pick<OnyxTypes.Policy, 'type' | 'role' | 'isPolicyExpenseChatEnabled' | 'pendingAction' | 'avatar' | 'name'>; type FloatingActionButtonAndPopoverOnyxProps = { From d26569cd35fccdf2cbb72ea1d8bc63c5b9a8f055 Mon Sep 17 00:00:00 2001 From: Anusha <anusharukhsar1@gmail.com> Date: Thu, 18 Apr 2024 20:42:22 +0500 Subject: [PATCH 193/206] Remove offline indicator --- src/pages/ReportParticipantsPage.tsx | 1 - 1 file changed, 1 deletion(-) diff --git a/src/pages/ReportParticipantsPage.tsx b/src/pages/ReportParticipantsPage.tsx index f6415ae9fa7d..827c4dd06db0 100755 --- a/src/pages/ReportParticipantsPage.tsx +++ b/src/pages/ReportParticipantsPage.tsx @@ -309,7 +309,6 @@ function ReportParticipantsPage({report, personalDetails, session}: ReportPartic includeSafeAreaPaddingBottom={false} style={[styles.defaultModalContainer]} testID={ReportParticipantsPage.displayName} - shouldShowOfflineIndicatorInWideScreen > <FullPageNotFoundView shouldShow={!report || ReportUtils.isArchivedRoom(report) || ReportUtils.isSelfDM(report)}> <HeaderWithBackButton From 2a01d46114f9abf2a32d03b02db4e9b180401936 Mon Sep 17 00:00:00 2001 From: Tim Golen <tgolen@expensify.com> Date: Thu, 18 Apr 2024 10:01:33 -0600 Subject: [PATCH 194/206] Use simplified type --- src/libs/actions/IOU.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libs/actions/IOU.ts b/src/libs/actions/IOU.ts index 85e9e736341f..da33b64982b4 100644 --- a/src/libs/actions/IOU.ts +++ b/src/libs/actions/IOU.ts @@ -2489,7 +2489,7 @@ const getConvertTrackedExpenseInformation = ( linkedTrackedExpenseReportAction: OnyxTypes.ReportAction, linkedTrackedExpenseReportID: string, transactionThreadReportID: string, - resolution: Omit<ValueOf<typeof CONST.IOU.ACTION>, 'edit' | 'create'>, + resolution: IOUAction, ) => { const optimisticData: OnyxUpdate[] = []; const successData: OnyxUpdate[] = []; From ac7a4619966e6ca3fc1a02343dcf94528d4163d9 Mon Sep 17 00:00:00 2001 From: Kevin Brian Bader <kevin.bader96@gmail.com> Date: Thu, 18 Apr 2024 21:17:58 +0300 Subject: [PATCH 195/206] made reportActions required --- src/libs/WorkspacesSettingsUtils.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libs/WorkspacesSettingsUtils.ts b/src/libs/WorkspacesSettingsUtils.ts index fd40a3035a5a..a8164c2d9fa8 100644 --- a/src/libs/WorkspacesSettingsUtils.ts +++ b/src/libs/WorkspacesSettingsUtils.ts @@ -146,7 +146,7 @@ function checkIfWorkspaceSettingsTabHasRBR(policyID?: string) { /** * @returns a map where the keys are policyIDs and the values are BrickRoads for each policy */ -function getWorkspacesBrickRoads(reports: OnyxCollection<Report>, policies: OnyxCollection<Policy>, reportActions?: OnyxCollection<ReportActions>): Record<string, BrickRoad> { +function getWorkspacesBrickRoads(reports: OnyxCollection<Report>, policies: OnyxCollection<Policy>, reportActions: OnyxCollection<ReportActions>): Record<string, BrickRoad> { if (!reports) { return {}; } From c39c100084a8eba78221ed22ed6a933a40b2c802 Mon Sep 17 00:00:00 2001 From: Kevin Brian Bader <kevin.bader96@gmail.com> Date: Thu, 18 Apr 2024 23:06:24 +0300 Subject: [PATCH 196/206] removed isEmptyObject check --- src/libs/WorkspacesSettingsUtils.ts | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/libs/WorkspacesSettingsUtils.ts b/src/libs/WorkspacesSettingsUtils.ts index a8164c2d9fa8..6c57c2a6f99d 100644 --- a/src/libs/WorkspacesSettingsUtils.ts +++ b/src/libs/WorkspacesSettingsUtils.ts @@ -6,7 +6,6 @@ import type {TranslationPaths} from '@src/languages/types'; import ONYXKEYS from '@src/ONYXKEYS'; import type {Policy, ReimbursementAccount, Report, ReportActions} from '@src/types/onyx'; import type {Unit} from '@src/types/onyx/Policy'; -import {isEmptyObject} from '@src/types/utils/EmptyObject'; import * as CurrencyUtils from './CurrencyUtils'; import type {Phrase, PhraseParameters} from './Localize'; import * as OptionsListUtils from './OptionsListUtils'; @@ -59,8 +58,7 @@ Onyx.connect({ * @returns BrickRoad for the policy passed as a param and optionally actionsByReport (if passed) */ const getBrickRoadForPolicy = (report: Report, altReportActions?: OnyxCollection<ReportActions>): BrickRoad => { - const finalReportActions = isEmptyObject(altReportActions) ? allReportActions : altReportActions; - const reportActions = finalReportActions?.[`${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${report.reportID}`] ?? {}; + const reportActions = (altReportActions ?? allReportActions)?.[`${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${report.reportID}`] ?? {}; const reportErrors = OptionsListUtils.getAllReportErrors(report, reportActions); const doesReportContainErrors = Object.keys(reportErrors ?? {}).length !== 0 ? CONST.BRICK_ROAD_INDICATOR_STATUS.ERROR : undefined; if (doesReportContainErrors) { From e9f042734648250a441085afc0f1c5ec75dc88b5 Mon Sep 17 00:00:00 2001 From: Andrew Gable <andrewgable@gmail.com> Date: Thu, 18 Apr 2024 16:14:59 -0600 Subject: [PATCH 197/206] Revert "Immediately show file size message for large attachments" --- src/components/AttachmentPicker/index.native.tsx | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/components/AttachmentPicker/index.native.tsx b/src/components/AttachmentPicker/index.native.tsx index 5e54458da001..ad4cf023c096 100644 --- a/src/components/AttachmentPicker/index.native.tsx +++ b/src/components/AttachmentPicker/index.native.tsx @@ -5,7 +5,7 @@ import RNFetchBlob from 'react-native-blob-util'; import RNDocumentPicker from 'react-native-document-picker'; import type {DocumentPickerOptions, DocumentPickerResponse} from 'react-native-document-picker'; import {launchImageLibrary} from 'react-native-image-picker'; -import type {Asset, Callback, CameraOptions, ImageLibraryOptions, ImagePickerResponse} from 'react-native-image-picker'; +import type {Asset, Callback, CameraOptions, ImagePickerResponse} from 'react-native-image-picker'; import ImageSize from 'react-native-image-size'; import type {FileObject, ImagePickerResponse as FileResponse} from '@components/AttachmentModal'; import * as Expensicons from '@components/Icon/Expensicons'; @@ -41,12 +41,11 @@ type Item = { * See https://github.com/react-native-image-picker/react-native-image-picker/#options * for ImagePicker configuration options */ -const imagePickerOptions: Partial<CameraOptions | ImageLibraryOptions> = { +const imagePickerOptions = { includeBase64: false, saveToPhotos: false, selectionLimit: 1, includeExtra: false, - assetRepresentationMode: 'current', }; /** From a6741daee0e654e71bf3094248dd7e8d9fff0059 Mon Sep 17 00:00:00 2001 From: OSBotify <infra+osbotify@expensify.com> Date: Thu, 18 Apr 2024 22:49:31 +0000 Subject: [PATCH 198/206] Update version to 1.4.63-1 --- android/app/build.gradle | 4 ++-- ios/NewExpensify/Info.plist | 2 +- ios/NewExpensifyTests/Info.plist | 2 +- ios/NotificationServiceExtension/Info.plist | 2 +- package-lock.json | 4 ++-- package.json | 2 +- 6 files changed, 8 insertions(+), 8 deletions(-) diff --git a/android/app/build.gradle b/android/app/build.gradle index 0db4b032ec9d..82f15243321c 100644 --- a/android/app/build.gradle +++ b/android/app/build.gradle @@ -98,8 +98,8 @@ android { minSdkVersion rootProject.ext.minSdkVersion targetSdkVersion rootProject.ext.targetSdkVersion multiDexEnabled rootProject.ext.multiDexEnabled - versionCode 1001046300 - versionName "1.4.63-0" + versionCode 1001046301 + versionName "1.4.63-1" // Supported language variants must be declared here to avoid from being removed during the compilation. // This also helps us to not include unnecessary language variants in the APK. resConfigs "en", "es" diff --git a/ios/NewExpensify/Info.plist b/ios/NewExpensify/Info.plist index ddcc64604581..28228305ec40 100644 --- a/ios/NewExpensify/Info.plist +++ b/ios/NewExpensify/Info.plist @@ -40,7 +40,7 @@ </dict> </array> <key>CFBundleVersion</key> - <string>1.4.63.0</string> + <string>1.4.63.1</string> <key>ITSAppUsesNonExemptEncryption</key> <false/> <key>LSApplicationQueriesSchemes</key> diff --git a/ios/NewExpensifyTests/Info.plist b/ios/NewExpensifyTests/Info.plist index a57ffb9500c5..c4ff78f55b7e 100644 --- a/ios/NewExpensifyTests/Info.plist +++ b/ios/NewExpensifyTests/Info.plist @@ -19,6 +19,6 @@ <key>CFBundleSignature</key> <string>????</string> <key>CFBundleVersion</key> - <string>1.4.63.0</string> + <string>1.4.63.1</string> </dict> </plist> diff --git a/ios/NotificationServiceExtension/Info.plist b/ios/NotificationServiceExtension/Info.plist index 3c8e8c1fb63f..adce0531018b 100644 --- a/ios/NotificationServiceExtension/Info.plist +++ b/ios/NotificationServiceExtension/Info.plist @@ -13,7 +13,7 @@ <key>CFBundleShortVersionString</key> <string>1.4.63</string> <key>CFBundleVersion</key> - <string>1.4.63.0</string> + <string>1.4.63.1</string> <key>NSExtension</key> <dict> <key>NSExtensionPointIdentifier</key> diff --git a/package-lock.json b/package-lock.json index 920fefc8242b..72c80c0776a5 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "new.expensify", - "version": "1.4.63-0", + "version": "1.4.63-1", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "new.expensify", - "version": "1.4.63-0", + "version": "1.4.63-1", "hasInstallScript": true, "license": "MIT", "dependencies": { diff --git a/package.json b/package.json index 20d066eabebe..422739527500 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "new.expensify", - "version": "1.4.63-0", + "version": "1.4.63-1", "author": "Expensify, Inc.", "homepage": "https://new.expensify.com", "description": "New Expensify is the next generation of Expensify: a reimagination of payments based atop a foundation of chat.", From bd5984ad98fa3a8f045f22ef50f4d2b784fe4153 Mon Sep 17 00:00:00 2001 From: OSBotify <infra+osbotify@expensify.com> Date: Thu, 18 Apr 2024 22:53:19 +0000 Subject: [PATCH 199/206] Update version to 1.4.63-2 --- android/app/build.gradle | 4 ++-- ios/NewExpensify/Info.plist | 2 +- ios/NewExpensifyTests/Info.plist | 2 +- ios/NotificationServiceExtension/Info.plist | 2 +- package-lock.json | 4 ++-- package.json | 2 +- 6 files changed, 8 insertions(+), 8 deletions(-) diff --git a/android/app/build.gradle b/android/app/build.gradle index 82f15243321c..b318487f4c08 100644 --- a/android/app/build.gradle +++ b/android/app/build.gradle @@ -98,8 +98,8 @@ android { minSdkVersion rootProject.ext.minSdkVersion targetSdkVersion rootProject.ext.targetSdkVersion multiDexEnabled rootProject.ext.multiDexEnabled - versionCode 1001046301 - versionName "1.4.63-1" + versionCode 1001046302 + versionName "1.4.63-2" // Supported language variants must be declared here to avoid from being removed during the compilation. // This also helps us to not include unnecessary language variants in the APK. resConfigs "en", "es" diff --git a/ios/NewExpensify/Info.plist b/ios/NewExpensify/Info.plist index 28228305ec40..8637655152d3 100644 --- a/ios/NewExpensify/Info.plist +++ b/ios/NewExpensify/Info.plist @@ -40,7 +40,7 @@ </dict> </array> <key>CFBundleVersion</key> - <string>1.4.63.1</string> + <string>1.4.63.2</string> <key>ITSAppUsesNonExemptEncryption</key> <false/> <key>LSApplicationQueriesSchemes</key> diff --git a/ios/NewExpensifyTests/Info.plist b/ios/NewExpensifyTests/Info.plist index c4ff78f55b7e..83a6da0661f6 100644 --- a/ios/NewExpensifyTests/Info.plist +++ b/ios/NewExpensifyTests/Info.plist @@ -19,6 +19,6 @@ <key>CFBundleSignature</key> <string>????</string> <key>CFBundleVersion</key> - <string>1.4.63.1</string> + <string>1.4.63.2</string> </dict> </plist> diff --git a/ios/NotificationServiceExtension/Info.plist b/ios/NotificationServiceExtension/Info.plist index adce0531018b..8de74381ceb0 100644 --- a/ios/NotificationServiceExtension/Info.plist +++ b/ios/NotificationServiceExtension/Info.plist @@ -13,7 +13,7 @@ <key>CFBundleShortVersionString</key> <string>1.4.63</string> <key>CFBundleVersion</key> - <string>1.4.63.1</string> + <string>1.4.63.2</string> <key>NSExtension</key> <dict> <key>NSExtensionPointIdentifier</key> diff --git a/package-lock.json b/package-lock.json index 72c80c0776a5..30be89e29422 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "new.expensify", - "version": "1.4.63-1", + "version": "1.4.63-2", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "new.expensify", - "version": "1.4.63-1", + "version": "1.4.63-2", "hasInstallScript": true, "license": "MIT", "dependencies": { diff --git a/package.json b/package.json index 422739527500..c894cd3ef4bd 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "new.expensify", - "version": "1.4.63-1", + "version": "1.4.63-2", "author": "Expensify, Inc.", "homepage": "https://new.expensify.com", "description": "New Expensify is the next generation of Expensify: a reimagination of payments based atop a foundation of chat.", From f33a5a43fd1b5afe7f0a5153fea36f3ba1ee0939 Mon Sep 17 00:00:00 2001 From: OSBotify <infra+osbotify@expensify.com> Date: Thu, 18 Apr 2024 23:00:16 +0000 Subject: [PATCH 200/206] Update version to 1.4.63-3 --- android/app/build.gradle | 4 ++-- ios/NewExpensify/Info.plist | 2 +- ios/NewExpensifyTests/Info.plist | 2 +- ios/NotificationServiceExtension/Info.plist | 2 +- package-lock.json | 4 ++-- package.json | 2 +- 6 files changed, 8 insertions(+), 8 deletions(-) diff --git a/android/app/build.gradle b/android/app/build.gradle index b318487f4c08..df91f87731fb 100644 --- a/android/app/build.gradle +++ b/android/app/build.gradle @@ -98,8 +98,8 @@ android { minSdkVersion rootProject.ext.minSdkVersion targetSdkVersion rootProject.ext.targetSdkVersion multiDexEnabled rootProject.ext.multiDexEnabled - versionCode 1001046302 - versionName "1.4.63-2" + versionCode 1001046303 + versionName "1.4.63-3" // Supported language variants must be declared here to avoid from being removed during the compilation. // This also helps us to not include unnecessary language variants in the APK. resConfigs "en", "es" diff --git a/ios/NewExpensify/Info.plist b/ios/NewExpensify/Info.plist index 8637655152d3..d926e1cef297 100644 --- a/ios/NewExpensify/Info.plist +++ b/ios/NewExpensify/Info.plist @@ -40,7 +40,7 @@ </dict> </array> <key>CFBundleVersion</key> - <string>1.4.63.2</string> + <string>1.4.63.3</string> <key>ITSAppUsesNonExemptEncryption</key> <false/> <key>LSApplicationQueriesSchemes</key> diff --git a/ios/NewExpensifyTests/Info.plist b/ios/NewExpensifyTests/Info.plist index 83a6da0661f6..ada5a50fc1a6 100644 --- a/ios/NewExpensifyTests/Info.plist +++ b/ios/NewExpensifyTests/Info.plist @@ -19,6 +19,6 @@ <key>CFBundleSignature</key> <string>????</string> <key>CFBundleVersion</key> - <string>1.4.63.2</string> + <string>1.4.63.3</string> </dict> </plist> diff --git a/ios/NotificationServiceExtension/Info.plist b/ios/NotificationServiceExtension/Info.plist index 8de74381ceb0..81407d6e6ca7 100644 --- a/ios/NotificationServiceExtension/Info.plist +++ b/ios/NotificationServiceExtension/Info.plist @@ -13,7 +13,7 @@ <key>CFBundleShortVersionString</key> <string>1.4.63</string> <key>CFBundleVersion</key> - <string>1.4.63.2</string> + <string>1.4.63.3</string> <key>NSExtension</key> <dict> <key>NSExtensionPointIdentifier</key> diff --git a/package-lock.json b/package-lock.json index 30be89e29422..eb3fc08dc7d0 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "new.expensify", - "version": "1.4.63-2", + "version": "1.4.63-3", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "new.expensify", - "version": "1.4.63-2", + "version": "1.4.63-3", "hasInstallScript": true, "license": "MIT", "dependencies": { diff --git a/package.json b/package.json index c894cd3ef4bd..f956cbe1a228 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "new.expensify", - "version": "1.4.63-2", + "version": "1.4.63-3", "author": "Expensify, Inc.", "homepage": "https://new.expensify.com", "description": "New Expensify is the next generation of Expensify: a reimagination of payments based atop a foundation of chat.", From 6c73169251a850677441a87b349f701f5ec750e0 Mon Sep 17 00:00:00 2001 From: OSBotify <infra+osbotify@expensify.com> Date: Thu, 18 Apr 2024 23:20:55 +0000 Subject: [PATCH 201/206] Update version to 1.4.63-4 --- android/app/build.gradle | 4 ++-- ios/NewExpensify/Info.plist | 2 +- ios/NewExpensifyTests/Info.plist | 2 +- ios/NotificationServiceExtension/Info.plist | 2 +- package-lock.json | 4 ++-- package.json | 2 +- 6 files changed, 8 insertions(+), 8 deletions(-) diff --git a/android/app/build.gradle b/android/app/build.gradle index df91f87731fb..0cd4fe20cf75 100644 --- a/android/app/build.gradle +++ b/android/app/build.gradle @@ -98,8 +98,8 @@ android { minSdkVersion rootProject.ext.minSdkVersion targetSdkVersion rootProject.ext.targetSdkVersion multiDexEnabled rootProject.ext.multiDexEnabled - versionCode 1001046303 - versionName "1.4.63-3" + versionCode 1001046304 + versionName "1.4.63-4" // Supported language variants must be declared here to avoid from being removed during the compilation. // This also helps us to not include unnecessary language variants in the APK. resConfigs "en", "es" diff --git a/ios/NewExpensify/Info.plist b/ios/NewExpensify/Info.plist index d926e1cef297..cf1fca5ee9a9 100644 --- a/ios/NewExpensify/Info.plist +++ b/ios/NewExpensify/Info.plist @@ -40,7 +40,7 @@ </dict> </array> <key>CFBundleVersion</key> - <string>1.4.63.3</string> + <string>1.4.63.4</string> <key>ITSAppUsesNonExemptEncryption</key> <false/> <key>LSApplicationQueriesSchemes</key> diff --git a/ios/NewExpensifyTests/Info.plist b/ios/NewExpensifyTests/Info.plist index ada5a50fc1a6..3091d1d22b64 100644 --- a/ios/NewExpensifyTests/Info.plist +++ b/ios/NewExpensifyTests/Info.plist @@ -19,6 +19,6 @@ <key>CFBundleSignature</key> <string>????</string> <key>CFBundleVersion</key> - <string>1.4.63.3</string> + <string>1.4.63.4</string> </dict> </plist> diff --git a/ios/NotificationServiceExtension/Info.plist b/ios/NotificationServiceExtension/Info.plist index 81407d6e6ca7..de0c0b6f767c 100644 --- a/ios/NotificationServiceExtension/Info.plist +++ b/ios/NotificationServiceExtension/Info.plist @@ -13,7 +13,7 @@ <key>CFBundleShortVersionString</key> <string>1.4.63</string> <key>CFBundleVersion</key> - <string>1.4.63.3</string> + <string>1.4.63.4</string> <key>NSExtension</key> <dict> <key>NSExtensionPointIdentifier</key> diff --git a/package-lock.json b/package-lock.json index eb3fc08dc7d0..9ba065e58828 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "new.expensify", - "version": "1.4.63-3", + "version": "1.4.63-4", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "new.expensify", - "version": "1.4.63-3", + "version": "1.4.63-4", "hasInstallScript": true, "license": "MIT", "dependencies": { diff --git a/package.json b/package.json index f956cbe1a228..32e4727f782a 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "new.expensify", - "version": "1.4.63-3", + "version": "1.4.63-4", "author": "Expensify, Inc.", "homepage": "https://new.expensify.com", "description": "New Expensify is the next generation of Expensify: a reimagination of payments based atop a foundation of chat.", From 9a6cafcabfcbaa4f81fe57d0fecbeab682b8309a Mon Sep 17 00:00:00 2001 From: OSBotify <infra+osbotify@expensify.com> Date: Fri, 19 Apr 2024 00:10:04 +0000 Subject: [PATCH 202/206] Update version to 1.4.63-5 --- android/app/build.gradle | 4 ++-- ios/NewExpensify/Info.plist | 2 +- ios/NewExpensifyTests/Info.plist | 2 +- ios/NotificationServiceExtension/Info.plist | 2 +- package-lock.json | 4 ++-- package.json | 2 +- 6 files changed, 8 insertions(+), 8 deletions(-) diff --git a/android/app/build.gradle b/android/app/build.gradle index 0cd4fe20cf75..af9ada750230 100644 --- a/android/app/build.gradle +++ b/android/app/build.gradle @@ -98,8 +98,8 @@ android { minSdkVersion rootProject.ext.minSdkVersion targetSdkVersion rootProject.ext.targetSdkVersion multiDexEnabled rootProject.ext.multiDexEnabled - versionCode 1001046304 - versionName "1.4.63-4" + versionCode 1001046305 + versionName "1.4.63-5" // Supported language variants must be declared here to avoid from being removed during the compilation. // This also helps us to not include unnecessary language variants in the APK. resConfigs "en", "es" diff --git a/ios/NewExpensify/Info.plist b/ios/NewExpensify/Info.plist index cf1fca5ee9a9..9f365ee86b56 100644 --- a/ios/NewExpensify/Info.plist +++ b/ios/NewExpensify/Info.plist @@ -40,7 +40,7 @@ </dict> </array> <key>CFBundleVersion</key> - <string>1.4.63.4</string> + <string>1.4.63.5</string> <key>ITSAppUsesNonExemptEncryption</key> <false/> <key>LSApplicationQueriesSchemes</key> diff --git a/ios/NewExpensifyTests/Info.plist b/ios/NewExpensifyTests/Info.plist index 3091d1d22b64..6fa6aa18fe52 100644 --- a/ios/NewExpensifyTests/Info.plist +++ b/ios/NewExpensifyTests/Info.plist @@ -19,6 +19,6 @@ <key>CFBundleSignature</key> <string>????</string> <key>CFBundleVersion</key> - <string>1.4.63.4</string> + <string>1.4.63.5</string> </dict> </plist> diff --git a/ios/NotificationServiceExtension/Info.plist b/ios/NotificationServiceExtension/Info.plist index de0c0b6f767c..f7960734af0d 100644 --- a/ios/NotificationServiceExtension/Info.plist +++ b/ios/NotificationServiceExtension/Info.plist @@ -13,7 +13,7 @@ <key>CFBundleShortVersionString</key> <string>1.4.63</string> <key>CFBundleVersion</key> - <string>1.4.63.4</string> + <string>1.4.63.5</string> <key>NSExtension</key> <dict> <key>NSExtensionPointIdentifier</key> diff --git a/package-lock.json b/package-lock.json index 9ba065e58828..2bc0aefb3a6d 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "new.expensify", - "version": "1.4.63-4", + "version": "1.4.63-5", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "new.expensify", - "version": "1.4.63-4", + "version": "1.4.63-5", "hasInstallScript": true, "license": "MIT", "dependencies": { diff --git a/package.json b/package.json index 32e4727f782a..eb4ce2752374 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "new.expensify", - "version": "1.4.63-4", + "version": "1.4.63-5", "author": "Expensify, Inc.", "homepage": "https://new.expensify.com", "description": "New Expensify is the next generation of Expensify: a reimagination of payments based atop a foundation of chat.", From 904a5dda5520e0e6e32b6b28cffcbd686b541bcb Mon Sep 17 00:00:00 2001 From: Jack Nam <30609178+thienlnam@users.noreply.github.com> Date: Thu, 18 Apr 2024 18:08:31 -0700 Subject: [PATCH 203/206] Revert "Fix task description update message doesn't parse the markdown" --- src/components/ReportActionItem/TaskAction.tsx | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/src/components/ReportActionItem/TaskAction.tsx b/src/components/ReportActionItem/TaskAction.tsx index e1b36713592f..e85a2e708feb 100644 --- a/src/components/ReportActionItem/TaskAction.tsx +++ b/src/components/ReportActionItem/TaskAction.tsx @@ -1,4 +1,3 @@ -import ExpensiMark from 'expensify-common/lib/ExpensiMark'; import React from 'react'; import {View} from 'react-native'; import type {OnyxEntry} from 'react-native-onyx'; @@ -16,15 +15,10 @@ type TaskActionProps = { function TaskAction({action}: TaskActionProps) { const styles = useThemeStyles(); const message = TaskUtils.getTaskReportActionMessage(action); - const parser = new ExpensiMark(); return ( <View style={[styles.flex1, styles.flexRow, styles.alignItemsCenter, styles.breakWord, styles.preWrap]}> - {message.html ? ( - <RenderHTML html={`<muted-text>${parser.replace(message.html)}</muted-text>`} /> - ) : ( - <Text style={[styles.chatItemMessage, styles.colorMuted]}>{message.text}</Text> - )} + {message.html ? <RenderHTML html={`<muted-text>${message.html}</muted-text>`} /> : <Text style={[styles.chatItemMessage, styles.colorMuted]}>{message.text}</Text>} </View> ); } From 0237f277c0d3c363ee1b20115df440f63da0b538 Mon Sep 17 00:00:00 2001 From: Fedi Rajhi <fedirjh@gmail.com> Date: Fri, 19 Apr 2024 02:01:40 +0100 Subject: [PATCH 204/206] [Revert] #36409 "Fix: three not found view" --- src/libs/Navigation/Navigation.ts | 7 - src/libs/Navigation/dismissRHP.ts | 25 ---- src/pages/ErrorPage/NotFoundPage.tsx | 5 +- .../AdminPolicyAccessOrNotFoundWrapper.tsx | 7 +- .../PaidPolicyAccessOrNotFoundWrapper.tsx | 7 +- src/pages/workspace/WorkspaceInitialPage.tsx | 14 -- .../workspace/WorkspaceInviteMessagePage.tsx | 3 - src/pages/workspace/WorkspaceMembersPage.tsx | 121 ++++++++++-------- .../workspace/WorkspacePageWithSections.tsx | 14 +- 9 files changed, 71 insertions(+), 132 deletions(-) delete mode 100644 src/libs/Navigation/dismissRHP.ts diff --git a/src/libs/Navigation/Navigation.ts b/src/libs/Navigation/Navigation.ts index 7b1960261182..b94c2c5fad4a 100644 --- a/src/libs/Navigation/Navigation.ts +++ b/src/libs/Navigation/Navigation.ts @@ -13,7 +13,6 @@ import type {Report} from '@src/types/onyx'; import type {EmptyObject} from '@src/types/utils/EmptyObject'; import originalDismissModal from './dismissModal'; import originalDismissModalWithReport from './dismissModalWithReport'; -import originalDismissRHP from './dismissRHP'; import originalGetTopmostReportActionId from './getTopmostReportActionID'; import originalGetTopmostReportId from './getTopmostReportId'; import linkingConfig from './linkingConfig'; @@ -62,11 +61,6 @@ const dismissModal = (reportID?: string, ref = navigationRef) => { originalDismissModalWithReport({reportID, ...report}, ref); }; -// Re-exporting the dismissRHP here to fill in default value for navigationRef. The dismissRHP isn't defined in this file to avoid cyclic dependencies. -const dismissRHP = (ref = navigationRef) => { - originalDismissRHP(ref); -}; - // Re-exporting the dismissModalWithReport here to fill in default value for navigationRef. The dismissModalWithReport isn't defined in this file to avoid cyclic dependencies. // This method is needed because it allows to dismiss the modal and then open the report. Within this method is checked whether the report belongs to a specific workspace. Sometimes the report we want to check, hasn't been added to the Onyx yet. // Then we can pass the report as a param without getting it from the Onyx. @@ -369,7 +363,6 @@ export default { setShouldPopAllStateOnUP, navigate, setParams, - dismissRHP, dismissModal, dismissModalWithReport, isActiveRoute, diff --git a/src/libs/Navigation/dismissRHP.ts b/src/libs/Navigation/dismissRHP.ts deleted file mode 100644 index 1c497a79600c..000000000000 --- a/src/libs/Navigation/dismissRHP.ts +++ /dev/null @@ -1,25 +0,0 @@ -import type {NavigationContainerRef} from '@react-navigation/native'; -import {StackActions} from '@react-navigation/native'; -import NAVIGATORS from '@src/NAVIGATORS'; -import type {RootStackParamList} from './types'; - -// This function is in a separate file than Navigation.ts to avoid cyclic dependency. - -/** - * Dismisses the RHP modal stack if there is any - * - * @param targetReportID - The reportID to navigate to after dismissing the modal - */ -function dismissRHP(navigationRef: NavigationContainerRef<RootStackParamList>) { - if (!navigationRef.isReady()) { - return; - } - - const state = navigationRef.getState(); - const lastRoute = state.routes.at(-1); - if (lastRoute?.name === NAVIGATORS.RIGHT_MODAL_NAVIGATOR) { - navigationRef.dispatch({...StackActions.pop(), target: state.key}); - } -} - -export default dismissRHP; diff --git a/src/pages/ErrorPage/NotFoundPage.tsx b/src/pages/ErrorPage/NotFoundPage.tsx index 4327b2cafbb7..a324b048119a 100644 --- a/src/pages/ErrorPage/NotFoundPage.tsx +++ b/src/pages/ErrorPage/NotFoundPage.tsx @@ -4,18 +4,15 @@ import ScreenWrapper from '@components/ScreenWrapper'; type NotFoundPageProps = { onBackButtonPress?: () => void; - - shouldForceFullScreen?: boolean; }; // eslint-disable-next-line rulesdir/no-negated-variables -function NotFoundPage({onBackButtonPress, shouldForceFullScreen}: NotFoundPageProps) { +function NotFoundPage({onBackButtonPress}: NotFoundPageProps) { return ( <ScreenWrapper testID={NotFoundPage.displayName}> <FullPageNotFoundView shouldShow onBackButtonPress={onBackButtonPress} - shouldForceFullScreen={shouldForceFullScreen} /> </ScreenWrapper> ); diff --git a/src/pages/workspace/AdminPolicyAccessOrNotFoundWrapper.tsx b/src/pages/workspace/AdminPolicyAccessOrNotFoundWrapper.tsx index 4e74ef3b4b20..5c8456366c6b 100644 --- a/src/pages/workspace/AdminPolicyAccessOrNotFoundWrapper.tsx +++ b/src/pages/workspace/AdminPolicyAccessOrNotFoundWrapper.tsx @@ -50,12 +50,7 @@ function AdminPolicyAccessOrNotFoundComponent(props: AdminPolicyAccessOrNotFound } if (shouldShowNotFoundPage) { - return ( - <NotFoundPage - onBackButtonPress={() => Navigation.goBack(ROUTES.WORKSPACE_PROFILE.getRoute(props.policyID))} - shouldForceFullScreen - /> - ); + return <NotFoundPage onBackButtonPress={() => Navigation.goBack(ROUTES.WORKSPACE_PROFILE.getRoute(props.policyID))} />; } return typeof props.children === 'function' ? props.children(props) : props.children; diff --git a/src/pages/workspace/PaidPolicyAccessOrNotFoundWrapper.tsx b/src/pages/workspace/PaidPolicyAccessOrNotFoundWrapper.tsx index 7361fc77536b..9b6047493561 100644 --- a/src/pages/workspace/PaidPolicyAccessOrNotFoundWrapper.tsx +++ b/src/pages/workspace/PaidPolicyAccessOrNotFoundWrapper.tsx @@ -50,12 +50,7 @@ function PaidPolicyAccessOrNotFoundComponent(props: PaidPolicyAccessOrNotFoundCo } if (shouldShowNotFoundPage) { - return ( - <NotFoundPage - onBackButtonPress={() => Navigation.goBack(ROUTES.WORKSPACE_PROFILE.getRoute(props.policyID))} - shouldForceFullScreen - /> - ); + return <NotFoundPage onBackButtonPress={() => Navigation.goBack(ROUTES.WORKSPACE_PROFILE.getRoute(props.policyID))} />; } return typeof props.children === 'function' ? props.children(props) : props.children; diff --git a/src/pages/workspace/WorkspaceInitialPage.tsx b/src/pages/workspace/WorkspaceInitialPage.tsx index 4d03eb655896..cbdacf66c548 100644 --- a/src/pages/workspace/WorkspaceInitialPage.tsx +++ b/src/pages/workspace/WorkspaceInitialPage.tsx @@ -262,20 +262,6 @@ function WorkspaceInitialPage({policyDraft, policy: policyProp, reimbursementAcc // We check isPendingDelete for both policy and prevPolicy to prevent the NotFound view from showing right after we delete the workspace (PolicyUtils.isPendingDeletePolicy(policy) && PolicyUtils.isPendingDeletePolicy(prevPolicy)); - // We are checking if the user can access the route. - // If user can't access the route, we are dismissing any modals that are open when the NotFound view is shown - const canAccessRoute = activeRoute && menuItems.some((item) => item.routeName === activeRoute); - - useEffect(() => { - if (!shouldShowNotFoundPage && canAccessRoute) { - return; - } - // We are dismissing any modals that are open when the NotFound view is shown - Navigation.isNavigationReady().then(() => { - Navigation.dismissRHP(); - }); - }, [canAccessRoute, policy, shouldShowNotFoundPage]); - const policyAvatar = useMemo(() => { if (!policy) { return {source: Expensicons.ExpensifyAppIcon, name: CONST.WORKSPACE_SWITCHER.NAME, type: CONST.ICON_TYPE_AVATAR}; diff --git a/src/pages/workspace/WorkspaceInviteMessagePage.tsx b/src/pages/workspace/WorkspaceInviteMessagePage.tsx index dd2ab151b658..30d66662b996 100644 --- a/src/pages/workspace/WorkspaceInviteMessagePage.tsx +++ b/src/pages/workspace/WorkspaceInviteMessagePage.tsx @@ -96,9 +96,6 @@ function WorkspaceInviteMessagePage({ setWelcomeNote(parser.htmlToMarkdown(getDefaultWelcomeNote())); return; } - if (isEmptyObject(policy)) { - return; - } Navigation.goBack(ROUTES.WORKSPACE_INVITE.getRoute(route.params.policyID), true); // eslint-disable-next-line react-hooks/exhaustive-deps }, []); diff --git a/src/pages/workspace/WorkspaceMembersPage.tsx b/src/pages/workspace/WorkspaceMembersPage.tsx index d475a916e0d4..619dcc54a031 100644 --- a/src/pages/workspace/WorkspaceMembersPage.tsx +++ b/src/pages/workspace/WorkspaceMembersPage.tsx @@ -7,13 +7,16 @@ import {InteractionManager, View} from 'react-native'; import type {OnyxEntry} from 'react-native-onyx'; import {withOnyx} from 'react-native-onyx'; import Badge from '@components/Badge'; +import FullPageNotFoundView from '@components/BlockingViews/FullPageNotFoundView'; import Button from '@components/Button'; import ButtonWithDropdownMenu from '@components/ButtonWithDropdownMenu'; import type {DropdownOption, WorkspaceMemberBulkActionType} from '@components/ButtonWithDropdownMenu/types'; import ConfirmModal from '@components/ConfirmModal'; +import HeaderWithBackButton from '@components/HeaderWithBackButton'; import * as Expensicons from '@components/Icon/Expensicons'; import * as Illustrations from '@components/Icon/Illustrations'; import MessagesRow from '@components/MessagesRow'; +import ScreenWrapper from '@components/ScreenWrapper'; import SelectionList from '@components/SelectionList'; import TableListItem from '@components/SelectionList/TableListItem'; import type {ListItem, SelectionListHandle} from '@components/SelectionList/types'; @@ -44,7 +47,6 @@ import type {Errors, PendingAction} from '@src/types/onyx/OnyxCommon'; import {isEmptyObject} from '@src/types/utils/EmptyObject'; import type {WithPolicyAndFullscreenLoadingProps} from './withPolicyAndFullscreenLoading'; import withPolicyAndFullscreenLoading from './withPolicyAndFullscreenLoading'; -import WorkspacePageWithSections from './WorkspacePageWithSections'; type WorkspaceMembersPageOnyxProps = { /** Session info for the currently logged in user. */ @@ -57,6 +59,7 @@ type WorkspaceMembersPageProps = WithPolicyAndFullscreenLoadingProps & WithCurrentUserPersonalDetailsProps & WorkspaceMembersPageOnyxProps & StackScreenProps<WorkspacesCentralPaneNavigatorParamList, typeof SCREENS.WORKSPACE.MEMBERS>; + /** * Inverts an object, equivalent of _.invert */ @@ -68,7 +71,7 @@ function invertObject(object: Record<string, string>): Record<string, string> { type MemberOption = Omit<ListItem, 'accountID'> & {accountID: number}; -function WorkspaceMembersPage({personalDetails, invitedEmailsToAccountIDsDraft, route, policy, session, currentUserPersonalDetails}: WorkspaceMembersPageProps) { +function WorkspaceMembersPage({personalDetails, invitedEmailsToAccountIDsDraft, route, policy, session, currentUserPersonalDetails, isLoadingReportData = true}: WorkspaceMembersPageProps) { const policyMemberEmailsToAccountIDs = useMemo(() => PolicyUtils.getMemberAccountIDsForWorkspace(policy?.employeeList), [policy?.employeeList]); const styles = useThemeStyles(); const StyleUtils = useStyleUtils(); @@ -531,63 +534,71 @@ function WorkspaceMembersPage({personalDetails, invitedEmailsToAccountIDsDraft, }; return ( - <WorkspacePageWithSections - headerText={translate('workspace.common.members')} - route={route} - guidesCallTaskID={CONST.GUIDES_CALL_TASK_IDS.WORKSPACE_MEMBERS} - headerContent={!isSmallScreenWidth && getHeaderButtons()} - icon={Illustrations.ReceiptWrangler} + <ScreenWrapper + includeSafeAreaPaddingBottom={false} + style={[styles.defaultModalContainer]} testID={WorkspaceMembersPage.displayName} - shouldShowLoading={false} shouldShowOfflineIndicatorInWideScreen - shouldShowNonAdmin > - {() => ( - <> - {isSmallScreenWidth && <View style={[styles.pl5, styles.pr5]}>{getHeaderButtons()}</View>} - <ConfirmModal - danger - title={translate('workspace.people.removeMembersTitle')} - isVisible={removeMembersConfirmModalVisible} - onConfirm={removeUsers} - onCancel={() => setRemoveMembersConfirmModalVisible(false)} - prompt={translate('workspace.people.removeMembersPrompt')} - confirmText={translate('common.remove')} - cancelText={translate('common.cancel')} - onModalHide={() => { - InteractionManager.runAfterInteractions(() => { - if (!textInputRef.current) { - return; - } - textInputRef.current.focus(); - }); - }} + <FullPageNotFoundView + shouldShow={(isEmptyObject(policy) && !isLoadingReportData) || PolicyUtils.isPendingDeletePolicy(policy)} + subtitleKey={isEmptyObject(policy) ? undefined : 'workspace.common.notAuthorized'} + onBackButtonPress={PolicyUtils.goBackFromInvalidPolicy} + onLinkPress={PolicyUtils.goBackFromInvalidPolicy} + > + <HeaderWithBackButton + title={translate('workspace.common.members')} + icon={Illustrations.ReceiptWrangler} + onBackButtonPress={() => { + Navigation.goBack(); + }} + shouldShowBackButton={isSmallScreenWidth} + guidesCallTaskID={CONST.GUIDES_CALL_TASK_IDS.WORKSPACE_MEMBERS} + > + {!isSmallScreenWidth && getHeaderButtons()} + </HeaderWithBackButton> + {isSmallScreenWidth && <View style={[styles.pl5, styles.pr5]}>{getHeaderButtons()}</View>} + <ConfirmModal + danger + title={translate('workspace.people.removeMembersTitle')} + isVisible={removeMembersConfirmModalVisible} + onConfirm={removeUsers} + onCancel={() => setRemoveMembersConfirmModalVisible(false)} + prompt={translate('workspace.people.removeMembersPrompt')} + confirmText={translate('common.remove')} + cancelText={translate('common.cancel')} + onModalHide={() => { + InteractionManager.runAfterInteractions(() => { + if (!textInputRef.current) { + return; + } + textInputRef.current.focus(); + }); + }} + /> + <View style={[styles.w100, styles.flex1]}> + <SelectionList + ref={selectionListRef} + canSelectMultiple={isPolicyAdmin} + sections={[{data, isDisabled: false}]} + ListItem={TableListItem} + disableKeyboardShortcuts={removeMembersConfirmModalVisible} + headerMessage={getHeaderMessage()} + headerContent={getHeaderContent()} + onSelectRow={openMemberDetails} + onCheckboxPress={(item) => toggleUser(item.accountID)} + onSelectAll={() => toggleAllUsers(data)} + onDismissError={dismissError} + showLoadingPlaceholder={isLoading} + showScrollIndicator + shouldPreventDefaultFocusOnSelectRow={!DeviceCapabilities.canUseTouchScreen()} + textInputRef={textInputRef} + customListHeader={getCustomListHeader()} + listHeaderWrapperStyle={[styles.ph9, styles.pv3, styles.pb5]} /> - - <View style={[styles.w100, styles.flex1]}> - <SelectionList - ref={selectionListRef} - canSelectMultiple={isPolicyAdmin} - sections={[{data, isDisabled: false}]} - ListItem={TableListItem} - disableKeyboardShortcuts={removeMembersConfirmModalVisible} - headerMessage={getHeaderMessage()} - headerContent={getHeaderContent()} - onSelectRow={openMemberDetails} - onCheckboxPress={(item) => toggleUser(item.accountID)} - onSelectAll={() => toggleAllUsers(data)} - onDismissError={dismissError} - showLoadingPlaceholder={isLoading} - showScrollIndicator - shouldPreventDefaultFocusOnSelectRow={!DeviceCapabilities.canUseTouchScreen()} - textInputRef={textInputRef} - customListHeader={getCustomListHeader()} - listHeaderWrapperStyle={[styles.ph9, styles.pv3, styles.pb5]} - /> - </View> - </> - )} - </WorkspacePageWithSections> + </View> + </FullPageNotFoundView> + </ScreenWrapper> ); } diff --git a/src/pages/workspace/WorkspacePageWithSections.tsx b/src/pages/workspace/WorkspacePageWithSections.tsx index 4b9b39458312..4889c1dbe350 100644 --- a/src/pages/workspace/WorkspacePageWithSections.tsx +++ b/src/pages/workspace/WorkspacePageWithSections.tsx @@ -82,12 +82,6 @@ type WorkspacePageWithSectionsProps = WithPolicyAndFullscreenLoadingProps & * */ icon?: IconAsset; - /** Content to be added to the header */ - headerContent?: ReactNode; - - /** TestID of the component */ - testID?: string; - /** Whether the page is loading, example any other API call in progres */ isLoading?: boolean; }; @@ -118,8 +112,6 @@ function WorkspacePageWithSections({ shouldShowLoading = true, shouldShowOfflineIndicatorInWideScreen = false, shouldShowNonAdmin = false, - headerContent, - testID, shouldShowNotFoundPage = false, isLoading: isPageLoading = false, }: WorkspacePageWithSectionsProps) { @@ -168,7 +160,7 @@ function WorkspacePageWithSections({ includeSafeAreaPaddingBottom={false} shouldEnablePickerAvoiding={false} shouldEnableMaxHeight - testID={testID ?? WorkspacePageWithSections.displayName} + testID={WorkspacePageWithSections.displayName} shouldShowOfflineIndicatorInWideScreen={shouldShowOfflineIndicatorInWideScreen && !shouldShow} > <FullPageNotFoundView @@ -185,9 +177,7 @@ function WorkspacePageWithSections({ onBackButtonPress={() => Navigation.goBack(backButtonRoute)} icon={icon ?? undefined} style={styles.headerBarDesktopHeight} - > - {headerContent} - </HeaderWithBackButton> + /> {(isLoading || firstRender.current) && shouldShowLoading && isFocused ? ( <FullScreenLoadingIndicator style={[styles.flex1, styles.pRelative]} /> ) : ( From 68e69623a8bca0dce5f384fa351d5cbb2214aeb4 Mon Sep 17 00:00:00 2001 From: OSBotify <infra+osbotify@expensify.com> Date: Fri, 19 Apr 2024 02:07:58 +0000 Subject: [PATCH 205/206] Update version to 1.4.63-6 --- android/app/build.gradle | 4 ++-- ios/NewExpensify/Info.plist | 2 +- ios/NewExpensifyTests/Info.plist | 2 +- ios/NotificationServiceExtension/Info.plist | 2 +- package-lock.json | 4 ++-- package.json | 2 +- 6 files changed, 8 insertions(+), 8 deletions(-) diff --git a/android/app/build.gradle b/android/app/build.gradle index af9ada750230..f931c9f5488f 100644 --- a/android/app/build.gradle +++ b/android/app/build.gradle @@ -98,8 +98,8 @@ android { minSdkVersion rootProject.ext.minSdkVersion targetSdkVersion rootProject.ext.targetSdkVersion multiDexEnabled rootProject.ext.multiDexEnabled - versionCode 1001046305 - versionName "1.4.63-5" + versionCode 1001046306 + versionName "1.4.63-6" // Supported language variants must be declared here to avoid from being removed during the compilation. // This also helps us to not include unnecessary language variants in the APK. resConfigs "en", "es" diff --git a/ios/NewExpensify/Info.plist b/ios/NewExpensify/Info.plist index 9f365ee86b56..923c2796c5b8 100644 --- a/ios/NewExpensify/Info.plist +++ b/ios/NewExpensify/Info.plist @@ -40,7 +40,7 @@ </dict> </array> <key>CFBundleVersion</key> - <string>1.4.63.5</string> + <string>1.4.63.6</string> <key>ITSAppUsesNonExemptEncryption</key> <false/> <key>LSApplicationQueriesSchemes</key> diff --git a/ios/NewExpensifyTests/Info.plist b/ios/NewExpensifyTests/Info.plist index 6fa6aa18fe52..c011c7e55c85 100644 --- a/ios/NewExpensifyTests/Info.plist +++ b/ios/NewExpensifyTests/Info.plist @@ -19,6 +19,6 @@ <key>CFBundleSignature</key> <string>????</string> <key>CFBundleVersion</key> - <string>1.4.63.5</string> + <string>1.4.63.6</string> </dict> </plist> diff --git a/ios/NotificationServiceExtension/Info.plist b/ios/NotificationServiceExtension/Info.plist index f7960734af0d..1faf983c0c13 100644 --- a/ios/NotificationServiceExtension/Info.plist +++ b/ios/NotificationServiceExtension/Info.plist @@ -13,7 +13,7 @@ <key>CFBundleShortVersionString</key> <string>1.4.63</string> <key>CFBundleVersion</key> - <string>1.4.63.5</string> + <string>1.4.63.6</string> <key>NSExtension</key> <dict> <key>NSExtensionPointIdentifier</key> diff --git a/package-lock.json b/package-lock.json index 2bc0aefb3a6d..74f0dfc5b47c 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "new.expensify", - "version": "1.4.63-5", + "version": "1.4.63-6", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "new.expensify", - "version": "1.4.63-5", + "version": "1.4.63-6", "hasInstallScript": true, "license": "MIT", "dependencies": { diff --git a/package.json b/package.json index eb4ce2752374..de076674723c 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "new.expensify", - "version": "1.4.63-5", + "version": "1.4.63-6", "author": "Expensify, Inc.", "homepage": "https://new.expensify.com", "description": "New Expensify is the next generation of Expensify: a reimagination of payments based atop a foundation of chat.", From 9b2c5187e2203d83bba50bfa66936691788cbd18 Mon Sep 17 00:00:00 2001 From: OSBotify <infra+osbotify@expensify.com> Date: Fri, 19 Apr 2024 07:02:26 +0000 Subject: [PATCH 206/206] Update version to 1.4.63-7 --- android/app/build.gradle | 4 ++-- ios/NewExpensify/Info.plist | 2 +- ios/NewExpensifyTests/Info.plist | 2 +- ios/NotificationServiceExtension/Info.plist | 2 +- package-lock.json | 4 ++-- package.json | 2 +- 6 files changed, 8 insertions(+), 8 deletions(-) diff --git a/android/app/build.gradle b/android/app/build.gradle index f931c9f5488f..b8350a8a0111 100644 --- a/android/app/build.gradle +++ b/android/app/build.gradle @@ -98,8 +98,8 @@ android { minSdkVersion rootProject.ext.minSdkVersion targetSdkVersion rootProject.ext.targetSdkVersion multiDexEnabled rootProject.ext.multiDexEnabled - versionCode 1001046306 - versionName "1.4.63-6" + versionCode 1001046307 + versionName "1.4.63-7" // Supported language variants must be declared here to avoid from being removed during the compilation. // This also helps us to not include unnecessary language variants in the APK. resConfigs "en", "es" diff --git a/ios/NewExpensify/Info.plist b/ios/NewExpensify/Info.plist index 923c2796c5b8..4523bf1c4418 100644 --- a/ios/NewExpensify/Info.plist +++ b/ios/NewExpensify/Info.plist @@ -40,7 +40,7 @@ </dict> </array> <key>CFBundleVersion</key> - <string>1.4.63.6</string> + <string>1.4.63.7</string> <key>ITSAppUsesNonExemptEncryption</key> <false/> <key>LSApplicationQueriesSchemes</key> diff --git a/ios/NewExpensifyTests/Info.plist b/ios/NewExpensifyTests/Info.plist index c011c7e55c85..d40d0fa27486 100644 --- a/ios/NewExpensifyTests/Info.plist +++ b/ios/NewExpensifyTests/Info.plist @@ -19,6 +19,6 @@ <key>CFBundleSignature</key> <string>????</string> <key>CFBundleVersion</key> - <string>1.4.63.6</string> + <string>1.4.63.7</string> </dict> </plist> diff --git a/ios/NotificationServiceExtension/Info.plist b/ios/NotificationServiceExtension/Info.plist index 1faf983c0c13..d472daa53ab7 100644 --- a/ios/NotificationServiceExtension/Info.plist +++ b/ios/NotificationServiceExtension/Info.plist @@ -13,7 +13,7 @@ <key>CFBundleShortVersionString</key> <string>1.4.63</string> <key>CFBundleVersion</key> - <string>1.4.63.6</string> + <string>1.4.63.7</string> <key>NSExtension</key> <dict> <key>NSExtensionPointIdentifier</key> diff --git a/package-lock.json b/package-lock.json index 74f0dfc5b47c..52a975e3a83e 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "new.expensify", - "version": "1.4.63-6", + "version": "1.4.63-7", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "new.expensify", - "version": "1.4.63-6", + "version": "1.4.63-7", "hasInstallScript": true, "license": "MIT", "dependencies": { diff --git a/package.json b/package.json index de076674723c..1cef7d94fcba 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "new.expensify", - "version": "1.4.63-6", + "version": "1.4.63-7", "author": "Expensify, Inc.", "homepage": "https://new.expensify.com", "description": "New Expensify is the next generation of Expensify: a reimagination of payments based atop a foundation of chat.",