Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

remove MoneyRequestTagPage #35136

Merged
merged 10 commits into from
Feb 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 3 additions & 7 deletions src/ROUTES.ts
Original file line number Diff line number Diff line change
Expand Up @@ -293,10 +293,6 @@ const ROUTES = {
route: ':iouType/new/category/:reportID?',
getRoute: (iouType: string, reportID = '') => `${iouType}/new/category/${reportID}` as const,
},
MONEY_REQUEST_TAG: {
route: ':iouType/new/tag/:reportID?',
getRoute: (iouType: string, reportID = '') => `${iouType}/new/tag/${reportID}` as const,
},
MONEY_REQUEST_MERCHANT: {
route: ':iouType/new/merchant/:reportID?',
getRoute: (iouType: string, reportID = '') => `${iouType}/new/merchant/${reportID}` as const,
Expand Down Expand Up @@ -380,9 +376,9 @@ const ROUTES = {
getUrlWithBackToParam(`${action}/${iouType}/scan/${transactionID}/${reportID}`, backTo),
},
MONEY_REQUEST_STEP_TAG: {
route: 'create/:iouType/tag/:transactionID/:reportID',
getRoute: (iouType: ValueOf<typeof CONST.IOU.TYPE>, transactionID: string, reportID: string, backTo = '') =>
getUrlWithBackToParam(`create/${iouType}/tag/${transactionID}/${reportID}`, backTo),
route: ':action/:iouType/tag/:transactionID/:reportID',
getRoute: (action: ValueOf<typeof CONST.IOU.ACTION>, iouType: ValueOf<typeof CONST.IOU.TYPE>, transactionID: string, reportID: string, backTo = '') =>
getUrlWithBackToParam(`${action}/${iouType}/tag/${transactionID}/${reportID}`, backTo),
},
MONEY_REQUEST_STEP_WAYPOINT: {
route: ':action/:iouType/waypoint/:transactionID/:reportID/:pageIndex',
Expand Down
1 change: 0 additions & 1 deletion src/SCREENS.ts
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,6 @@ const SCREENS = {
DATE: 'Money_Request_Date',
DESCRIPTION: 'Money_Request_Description',
CATEGORY: 'Money_Request_Category',
TAG: 'Money_Request_Tag',
MERCHANT: 'Money_Request_Merchant',
WAYPOINT: 'Money_Request_Waypoint',
EDIT_WAYPOINT: 'Money_Request_Edit_Waypoint',
Expand Down
10 changes: 9 additions & 1 deletion src/components/MoneyRequestConfirmationList.js
Original file line number Diff line number Diff line change
Expand Up @@ -769,7 +769,15 @@ function MoneyRequestConfirmationList(props) {
numberOfLinesTitle={2}
onPress={() => {
if (props.isEditingSplitBill) {
Navigation.navigate(ROUTES.EDIT_SPLIT_BILL.getRoute(props.reportID, props.reportActionID, CONST.EDIT_REQUEST_FIELD.TAG));
Navigation.navigate(
ROUTES.MONEY_REQUEST_STEP_TAG.getRoute(
CONST.IOU.ACTION.EDIT,
CONST.IOU.TYPE.SPLIT,
props.transaction.transactionID,
props.reportID,
Navigation.getActiveRouteWithoutParams(),
),
);
return;
}
Navigation.navigate(ROUTES.MONEY_REQUEST_TAG.getRoute(props.iouType, props.reportID));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @dukenv0307, I saw that we removed ROUTES.MONEY_REQUEST_TAG in this PR, but this line of code is still using it. Is it something we missed?

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -817,12 +817,14 @@ function MoneyTemporaryForRefactorRequestConfirmationList({
description={policyTagListName}
numberOfLinesTitle={2}
onPress={() =>
Navigation.navigate(ROUTES.MONEY_REQUEST_STEP_TAG.getRoute(iouType, transaction.transactionID, reportID, Navigation.getActiveRouteWithoutParams()))
Navigation.navigate(
ROUTES.MONEY_REQUEST_STEP_TAG.getRoute(CONST.IOU.ACTION.CREATE, iouType, transaction.transactionID, reportID, Navigation.getActiveRouteWithoutParams()),
)
}
style={[styles.moneyRequestMenuItem]}
disabled={didConfirm}
interactive={!isReadOnly}
rightLabel={canUseViolations && Boolean(policy.requiresTag) ? translate('common.required') : ''}
rightLabel={canUseViolations && lodashGet(policy, 'requiresTag', false) ? translate('common.required') : ''}
/>
)}
{shouldShowTax && (
Expand Down
4 changes: 3 additions & 1 deletion src/components/ReportActionItem/MoneyRequestView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -336,7 +336,9 @@ function MoneyRequestView({
interactive={canEdit}
shouldShowRightIcon={canEdit}
titleStyle={styles.flex1}
onPress={() => Navigation.navigate(ROUTES.EDIT_REQUEST.getRoute(report.reportID, CONST.EDIT_REQUEST_FIELD.TAG))}
onPress={() =>
Navigation.navigate(ROUTES.MONEY_REQUEST_STEP_TAG.getRoute(CONST.IOU.ACTION.EDIT, CONST.IOU.TYPE.REQUEST, transaction?.transactionID ?? '', report.reportID))
}
brickRoadIndicator={hasViolations('tag') ? CONST.BRICK_ROAD_INDICATOR_STATUS.ERROR : undefined}
/>
{canUseViolations && <ViolationMessages violations={getViolationsForField('tag')} />}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,6 @@ const MoneyRequestModalStackNavigator = createModalStackNavigator<MoneyRequestNa
[SCREENS.MONEY_REQUEST.DATE]: () => require('../../../pages/iou/MoneyRequestDatePage').default as React.ComponentType,
[SCREENS.MONEY_REQUEST.DESCRIPTION]: () => require('../../../pages/iou/MoneyRequestDescriptionPage').default as React.ComponentType,
[SCREENS.MONEY_REQUEST.CATEGORY]: () => require('../../../pages/iou/MoneyRequestCategoryPage').default as React.ComponentType,
[SCREENS.MONEY_REQUEST.TAG]: () => require('../../../pages/iou/MoneyRequestTagPage').default as React.ComponentType,
[SCREENS.MONEY_REQUEST.MERCHANT]: () => require('../../../pages/iou/MoneyRequestMerchantPage').default as React.ComponentType,
[SCREENS.IOU_SEND.ADD_BANK_ACCOUNT]: () => require('../../../pages/AddPersonalBankAccountPage').default as React.ComponentType,
[SCREENS.IOU_SEND.ADD_DEBIT_CARD]: () => require('../../../pages/settings/Wallet/AddDebitCardPage').default as React.ComponentType,
Expand Down
1 change: 0 additions & 1 deletion src/libs/Navigation/linkingConfig/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -406,7 +406,6 @@ const config: LinkingOptions<RootStackParamList>['config'] = {
[SCREENS.MONEY_REQUEST.CURRENCY]: ROUTES.MONEY_REQUEST_CURRENCY.route,
[SCREENS.MONEY_REQUEST.DESCRIPTION]: ROUTES.MONEY_REQUEST_DESCRIPTION.route,
[SCREENS.MONEY_REQUEST.CATEGORY]: ROUTES.MONEY_REQUEST_CATEGORY.route,
[SCREENS.MONEY_REQUEST.TAG]: ROUTES.MONEY_REQUEST_TAG.route,
[SCREENS.MONEY_REQUEST.MERCHANT]: ROUTES.MONEY_REQUEST_MERCHANT.route,
[SCREENS.MONEY_REQUEST.RECEIPT]: ROUTES.MONEY_REQUEST_RECEIPT.route,
[SCREENS.MONEY_REQUEST.DISTANCE]: ROUTES.MONEY_REQUEST_DISTANCE.route,
Expand Down
9 changes: 6 additions & 3 deletions src/libs/Navigation/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -225,12 +225,15 @@ type MoneyRequestNavigatorParamList = {
iouType: string;
reportID: string;
};
[SCREENS.MONEY_REQUEST.TAG]: {
[SCREENS.MONEY_REQUEST.STEP_TAX_AMOUNT]: {
iouType: string;
transactionID: string;
reportID: string;
backTo: string;
};
[SCREENS.MONEY_REQUEST.STEP_TAX_AMOUNT]: {
iouType: string;
[SCREENS.MONEY_REQUEST.STEP_TAG]: {
action: ValueOf<typeof CONST.IOU.ACTION>;
iouType: ValueOf<typeof CONST.IOU.TYPE>;
transactionID: string;
reportID: string;
backTo: string;
Expand Down
24 changes: 1 addition & 23 deletions src/libs/actions/IOU.js
Original file line number Diff line number Diff line change
Expand Up @@ -234,17 +234,10 @@ function resetMoneyRequestCategory_temporaryForRefactor(transactionID) {
* @param {String} transactionID
* @param {String} tag
*/
function setMoneyRequestTag_temporaryForRefactor(transactionID, tag) {
function setMoneyRequestTag(transactionID, tag) {
Onyx.merge(`${ONYXKEYS.COLLECTION.TRANSACTION_DRAFT}${transactionID}`, {tag});
}

/*
* @param {String} transactionID
*/
function resetMoneyRequestTag_temporaryForRefactor(transactionID) {
Onyx.merge(`${ONYXKEYS.COLLECTION.TRANSACTION_DRAFT}${transactionID}`, {tag: null});
}

/**
* @param {String} transactionID
* @param {Boolean} billable
Expand Down Expand Up @@ -3635,17 +3628,6 @@ function resetMoneyRequestCategory() {
Onyx.merge(ONYXKEYS.IOU, {category: ''});
}

/*
* @param {String} tag
*/
function setMoneyRequestTag(tag) {
Onyx.merge(ONYXKEYS.IOU, {tag});
}

function resetMoneyRequestTag() {
Onyx.merge(ONYXKEYS.IOU, {tag: ''});
}

/**
* @param {String} transactionID
* @param {Object} taxRate
Expand Down Expand Up @@ -3726,7 +3708,6 @@ function navigateToNextPage(iou, iouType, report, path = '') {
.value();
setMoneyRequestParticipants(participants);
resetMoneyRequestCategory();
resetMoneyRequestTag();
}
Navigation.navigate(ROUTES.MONEY_REQUEST_CONFIRMATION.getRoute(iouType, report.reportID));
return;
Expand Down Expand Up @@ -3804,8 +3785,6 @@ export {
resetMoneyRequestCategory,
resetMoneyRequestCategory_temporaryForRefactor,
resetMoneyRequestInfo,
resetMoneyRequestTag,
resetMoneyRequestTag_temporaryForRefactor,
clearMoneyRequest,
setMoneyRequestAmount_temporaryForRefactor,
setMoneyRequestBillable_temporaryForRefactor,
Expand All @@ -3816,7 +3795,6 @@ export {
setMoneyRequestMerchant_temporaryForRefactor,
setMoneyRequestParticipants_temporaryForRefactor,
setMoneyRequestReceipt,
setMoneyRequestTag_temporaryForRefactor,
setMoneyRequestAmount,
setMoneyRequestBillable,
setMoneyRequestCategory,
Expand Down
127 changes: 0 additions & 127 deletions src/pages/iou/MoneyRequestTagPage.js

This file was deleted.

2 changes: 1 addition & 1 deletion src/pages/iou/request/step/IOURequestStepParticipants.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ function IOURequestStepParticipants({

const goToNextStep = useCallback(() => {
const nextStepIOUType = numberOfParticipants.current === 1 ? iouType : CONST.IOU.TYPE.SPLIT;
IOU.resetMoneyRequestTag_temporaryForRefactor(transactionID);
IOU.setMoneyRequestTag(transactionID, '');
IOU.resetMoneyRequestCategory_temporaryForRefactor(transactionID);
Navigation.navigate(ROUTES.MONEY_REQUEST_STEP_CONFIRMATION.getRoute(nextStepIOUType, transactionID, selectedReportID.current || reportID));
}, [iouType, transactionID, reportID]);
Expand Down
40 changes: 28 additions & 12 deletions src/pages/iou/request/step/IOURequestStepTag.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import Navigation from '@libs/Navigation/Navigation';
import * as PolicyUtils from '@libs/PolicyUtils';
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 IOURequestStepRoutePropTypes from './IOURequestStepRoutePropTypes';
Expand Down Expand Up @@ -44,7 +45,7 @@ function IOURequestStepTag({
policyTags,
report,
route: {
params: {transactionID, backTo},
params: {action, transactionID, backTo, iouType},
},
transaction: {tag},
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In split bill requests, we save the draft data in splitDraftTransaction field instead of transaction field. But in here, we always get tag from transaction field. It causes this regression

}) {
Expand All @@ -54,6 +55,8 @@ function IOURequestStepTag({
// Fetches the first tag list of the policy
const tagListKey = _.first(_.keys(policyTags));
const policyTagListName = PolicyUtils.getTagListName(policyTags) || translate('common.tag');
const isEditing = action === CONST.IOU.ACTION.EDIT;
const isSplitBill = iouType === CONST.IOU.TYPE.SPLIT;

const navigateBack = () => {
Navigation.goBack(backTo || ROUTES.HOME);
Expand All @@ -64,11 +67,19 @@ function IOURequestStepTag({
* @param {String} selectedTag.searchText
*/
const updateTag = (selectedTag) => {
if (selectedTag.searchText === tag) {
IOU.resetMoneyRequestTag_temporaryForRefactor(transactionID);
} else {
IOU.setMoneyRequestTag_temporaryForRefactor(transactionID, selectedTag.searchText);
const isSelectedTag = selectedTag.searchText === tag;
const updatedTag = !isSelectedTag ? selectedTag.searchText : '';
if (isSplitBill) {
Copy link
Contributor

@jjcoffee jjcoffee Feb 16, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Coming from #35836. This uses the SPLIT_TRANSACTION_DRAFT Onyx key, whereas we use the TRANSACTION_DRAFT key when creating a request, so we end up updating the wrong key here.

IOU.setDraftSplitTransaction(transactionID, {tag: selectedTag.searchText});
navigateBack();
return;
}
if (isEditing) {
IOU.updateMoneyRequestTag(transactionID, report.reportID, updatedTag);
Navigation.dismissModal();
return;
}
IOU.setMoneyRequestTag(transactionID, updatedTag);
navigateBack();
};

Expand All @@ -79,13 +90,18 @@ function IOURequestStepTag({
shouldShowWrapper
testID={IOURequestStepTag.displayName}
>
<Text style={[styles.ph5, styles.pv3]}>{translate('iou.tagSelection', {tagName: policyTagListName})}</Text>
<TagPicker
policyID={report.policyID}
tag={tagListKey}
selectedTag={tag || ''}
onSubmit={updateTag}
/>
{({insets}) => (
<>
<Text style={[styles.ph5, styles.pv3]}>{translate('iou.tagSelection', {tagName: policyTagListName})}</Text>
<TagPicker
policyID={report.policyID}
tag={tagListKey}
selectedTag={tag || ''}
onSubmit={updateTag}
insets={insets}
/>
</>
)}
</StepScreenWrapper>
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,6 @@ function MoneyRequestParticipantsPage({iou, selectedTab, route, transaction}) {
const navigateToConfirmationStep = (moneyRequestType) => {
IOU.setMoneyRequestId(moneyRequestType);
IOU.resetMoneyRequestCategory();
IOU.resetMoneyRequestTag();
Navigation.navigate(ROUTES.MONEY_REQUEST_CONFIRMATION.getRoute(moneyRequestType, reportID));
};

Expand Down
Loading