Skip to content

Commit

Permalink
Merge pull request #29696 from Expensify/tgolen-rename-constioutype
Browse files Browse the repository at this point in the history
Rename const from MONEY_REQUEST_TYPE to TYPE
  • Loading branch information
Hayata Suenaga authored Oct 18, 2023
2 parents 830feaf + 05ed9f2 commit 39d2a84
Show file tree
Hide file tree
Showing 20 changed files with 55 additions and 55 deletions.
2 changes: 1 addition & 1 deletion src/CONST.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1098,7 +1098,7 @@ const CONST = {
EXPENSIFY: 'Expensify',
VBBA: 'ACH',
},
MONEY_REQUEST_TYPE: {
TYPE: {
SEND: 'send',
SPLIT: 'split',
REQUEST: 'request',
Expand Down
2 changes: 1 addition & 1 deletion src/ROUTES.ts
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ export default {
getRoute: (reportID: string, accountID: string | number) => `r/${reportID}/notes/${accountID}/edit`,
},

// To see the available iouType, please refer to CONST.IOU.MONEY_REQUEST_TYPE
// To see the available iouType, please refer to CONST.IOU.TYPE
MONEY_REQUEST: {
route: ':iouType/new/:reportID?',
getRoute: (iouType: string, reportID = '') => `${iouType}/new/${reportID}`,
Expand Down
12 changes: 6 additions & 6 deletions src/components/MoneyRequestConfirmationList.js
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ const defaultProps = {
onConfirm: () => {},
onSendMoney: () => {},
onSelectParticipant: () => {},
iouType: CONST.IOU.MONEY_REQUEST_TYPE.REQUEST,
iouType: CONST.IOU.TYPE.REQUEST,
iouCategory: '',
iouTag: '',
iouIsBillable: false,
Expand Down Expand Up @@ -208,9 +208,9 @@ function MoneyRequestConfirmationList(props) {
const {translate, toLocaleDigit} = useLocalize();
const transaction = props.isEditingSplitBill ? props.draftTransaction || props.transaction : props.transaction;

const isTypeRequest = props.iouType === CONST.IOU.MONEY_REQUEST_TYPE.REQUEST;
const isSplitBill = props.iouType === CONST.IOU.MONEY_REQUEST_TYPE.SPLIT;
const isTypeSend = props.iouType === CONST.IOU.MONEY_REQUEST_TYPE.SEND;
const isTypeRequest = props.iouType === CONST.IOU.TYPE.REQUEST;
const isSplitBill = props.iouType === CONST.IOU.TYPE.SPLIT;
const isTypeSend = props.iouType === CONST.IOU.TYPE.SEND;

const isSplitWithScan = isSplitBill && props.isScanRequest;

Expand Down Expand Up @@ -445,7 +445,7 @@ function MoneyRequestConfirmationList(props) {
return;
}

if (props.iouType === CONST.IOU.MONEY_REQUEST_TYPE.SEND) {
if (props.iouType === CONST.IOU.TYPE.SEND) {
if (!paymentMethod) {
return;
}
Expand Down Expand Up @@ -491,7 +491,7 @@ function MoneyRequestConfirmationList(props) {
return;
}

const shouldShowSettlementButton = props.iouType === CONST.IOU.MONEY_REQUEST_TYPE.SEND;
const shouldShowSettlementButton = props.iouType === CONST.IOU.TYPE.SEND;
const shouldDisableButton = selectedParticipants.length === 0;

const button = shouldShowSettlementButton ? (
Expand Down
2 changes: 1 addition & 1 deletion src/components/ReportWelcomeText.js
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ function ReportWelcomeText(props) {
))}
</Text>
)}
{(moneyRequestOptions.includes(CONST.IOU.MONEY_REQUEST_TYPE.SEND) || moneyRequestOptions.includes(CONST.IOU.MONEY_REQUEST_TYPE.REQUEST)) && (
{(moneyRequestOptions.includes(CONST.IOU.TYPE.SEND) || moneyRequestOptions.includes(CONST.IOU.TYPE.REQUEST)) && (
<Text>{props.translate('reportActionsView.usePlusButton')}</Text>
)}
</Text>
Expand Down
2 changes: 1 addition & 1 deletion src/libs/IOUUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ function isIOUReportPendingCurrencyConversion(iouReport: Report): boolean {
* Checks if the iou type is one of request, send, or split.
*/
function isValidMoneyRequestType(iouType: string): boolean {
const moneyRequestType: string[] = [CONST.IOU.MONEY_REQUEST_TYPE.REQUEST, CONST.IOU.MONEY_REQUEST_TYPE.SPLIT, CONST.IOU.MONEY_REQUEST_TYPE.SEND];
const moneyRequestType: string[] = [CONST.IOU.TYPE.REQUEST, CONST.IOU.TYPE.SPLIT, CONST.IOU.TYPE.SEND];
return moneyRequestType.includes(iouType);
}

Expand Down
4 changes: 2 additions & 2 deletions src/libs/MoneyRequestUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,8 @@ function replaceAllDigits(text: string, convertFn: (char: string) => string): st
/**
* Check if distance request or not
*/
function isDistanceRequest(iouType: ValueOf<typeof CONST.IOU.MONEY_REQUEST_TYPE>, selectedTab: ValueOf<typeof CONST.TAB>): boolean {
return iouType === CONST.IOU.MONEY_REQUEST_TYPE.REQUEST && selectedTab === CONST.TAB.DISTANCE;
function isDistanceRequest(iouType: ValueOf<typeof CONST.IOU.TYPE>, selectedTab: ValueOf<typeof CONST.TAB>): boolean {
return iouType === CONST.IOU.TYPE.REQUEST && selectedTab === CONST.TAB.DISTANCE;
}

/**
Expand Down
6 changes: 3 additions & 3 deletions src/libs/ReportUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -3520,17 +3520,17 @@ function getMoneyRequestOptions(report, reportParticipants) {
(hasMultipleParticipants && !isPolicyExpenseChat(report) && !isMoneyRequestReport(report)) ||
(isControlPolicyExpenseChat(report) && report.isOwnPolicyExpenseChat)
) {
return [CONST.IOU.MONEY_REQUEST_TYPE.SPLIT];
return [CONST.IOU.TYPE.SPLIT];
}

// DM chats that only have 2 people will see the Send / Request money options.
// IOU and open or processing expense reports should show the Request option.
// Workspace chats should only see the Request money option or Split option in case of Control policies
return [
...(canRequestMoney(report, participants) ? [CONST.IOU.MONEY_REQUEST_TYPE.REQUEST] : []),
...(canRequestMoney(report, participants) ? [CONST.IOU.TYPE.REQUEST] : []),

// Send money option should be visible only in DMs
...(isChatReport(report) && !isPolicyExpenseChat(report) && hasSingleParticipantInReport ? [CONST.IOU.MONEY_REQUEST_TYPE.SEND] : []),
...(isChatReport(report) && !isPolicyExpenseChat(report) && hasSingleParticipantInReport ? [CONST.IOU.TYPE.SEND] : []),
];
}

Expand Down
4 changes: 2 additions & 2 deletions src/libs/actions/IOU.js
Original file line number Diff line number Diff line change
Expand Up @@ -1106,7 +1106,7 @@ function createSplitsAndOnyxData(participants, currentUserLogin, currentUserAcco
oneOnOneIOUReport.reportID,
comment,
'',
CONST.IOU.MONEY_REQUEST_TYPE.SPLIT,
CONST.IOU.TYPE.SPLIT,
splitTransaction.transactionID,
undefined,
undefined,
Expand Down Expand Up @@ -1641,7 +1641,7 @@ function completeSplitBill(chatReportID, reportAction, updatedTransaction, sessi
oneOnOneIOUReport.reportID,
updatedTransaction.comment.comment,
updatedTransaction.modifiedCreated,
CONST.IOU.MONEY_REQUEST_TYPE.SPLIT,
CONST.IOU.TYPE.SPLIT,
transactionID,
updatedTransaction.modifiedMerchant,
{...updatedTransaction.receipt, state: CONST.IOU.RECEIPT_STATE.OPEN},
Expand Down
2 changes: 1 addition & 1 deletion src/pages/EditRequestDistancePage.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ const propTypes = {
/** Parameters the route gets */
params: PropTypes.shape({
/** Type of IOU */
iouType: PropTypes.oneOf(_.values(CONST.IOU.MONEY_REQUEST_TYPE)),
iouType: PropTypes.oneOf(_.values(CONST.IOU.TYPE)),

/** Id of the report on which the distance request is being created */
reportID: PropTypes.string,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -126,15 +126,15 @@ function AttachmentPickerWithMenuItems({
*/
const moneyRequestOptions = useMemo(() => {
const options = {
[CONST.IOU.MONEY_REQUEST_TYPE.SPLIT]: {
[CONST.IOU.TYPE.SPLIT]: {
icon: Expensicons.Receipt,
text: translate('iou.splitBill'),
},
[CONST.IOU.MONEY_REQUEST_TYPE.REQUEST]: {
[CONST.IOU.TYPE.REQUEST]: {
icon: Expensicons.MoneyCircle,
text: translate('iou.requestMoney'),
},
[CONST.IOU.MONEY_REQUEST_TYPE.SEND]: {
[CONST.IOU.TYPE.SEND]: {
icon: Expensicons.Send,
text: translate('iou.sendMoney'),
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -199,12 +199,12 @@ function FloatingActionButtonAndPopover(props) {
{
icon: Expensicons.MoneyCircle,
text: props.translate('iou.requestMoney'),
onSelected: () => interceptAnonymousUser(() => IOU.startMoneyRequest(CONST.IOU.MONEY_REQUEST_TYPE.REQUEST)),
onSelected: () => interceptAnonymousUser(() => IOU.startMoneyRequest(CONST.IOU.TYPE.REQUEST)),
},
{
icon: Expensicons.Send,
text: props.translate('iou.sendMoney'),
onSelected: () => interceptAnonymousUser(() => IOU.startMoneyRequest(CONST.IOU.MONEY_REQUEST_TYPE.SEND)),
onSelected: () => interceptAnonymousUser(() => IOU.startMoneyRequest(CONST.IOU.TYPE.SEND)),
},
...(Permissions.canUseTasks(props.betas)
? [
Expand Down
2 changes: 1 addition & 1 deletion src/pages/iou/IOUCurrencySelection.js
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ function IOUCurrencySelection(props) {
const [searchValue, setSearchValue] = useState('');
const optionsSelectorRef = useRef();
const selectedCurrencyCode = (lodashGet(props.route, 'params.currency', props.iou.currency) || CONST.CURRENCY.USD).toUpperCase();
const iouType = lodashGet(props.route, 'params.iouType', CONST.IOU.MONEY_REQUEST_TYPE.REQUEST);
const iouType = lodashGet(props.route, 'params.iouType', CONST.IOU.TYPE.REQUEST);
const reportID = lodashGet(props.route, 'params.reportID', '');

const confirmCurrencySelection = useCallback(
Expand Down
8 changes: 4 additions & 4 deletions src/pages/iou/MoneyRequestSelectorPage.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,9 @@ function MoneyRequestSelectorPage(props) {
const {translate} = useLocalize();

const title = {
[CONST.IOU.MONEY_REQUEST_TYPE.REQUEST]: translate('iou.requestMoney'),
[CONST.IOU.MONEY_REQUEST_TYPE.SEND]: translate('iou.sendMoney'),
[CONST.IOU.MONEY_REQUEST_TYPE.SPLIT]: translate('iou.splitBill'),
[CONST.IOU.TYPE.REQUEST]: translate('iou.requestMoney'),
[CONST.IOU.TYPE.SEND]: translate('iou.sendMoney'),
[CONST.IOU.TYPE.SPLIT]: translate('iou.splitBill'),
};
const isFromGlobalCreate = !reportID;
const isExpenseRequest = ReportUtils.isPolicyExpenseChat(props.report);
Expand Down Expand Up @@ -99,7 +99,7 @@ function MoneyRequestSelectorPage(props) {
title={title[iouType]}
onBackButtonPress={Navigation.dismissModal}
/>
{iouType === CONST.IOU.MONEY_REQUEST_TYPE.REQUEST || iouType === CONST.IOU.MONEY_REQUEST_TYPE.SPLIT ? (
{iouType === CONST.IOU.TYPE.REQUEST || iouType === CONST.IOU.TYPE.SPLIT ? (
<OnyxTabNavigator
id={CONST.TAB.RECEIPT_TAB_ID}
selectedTab={props.selectedTab}
Expand Down
2 changes: 1 addition & 1 deletion src/pages/iou/NewDistanceRequestPage.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ const propTypes = {
/** Parameters the route gets */
params: PropTypes.shape({
/** Type of IOU */
iouType: PropTypes.oneOf(_.values(CONST.IOU.MONEY_REQUEST_TYPE)),
iouType: PropTypes.oneOf(_.values(CONST.IOU.TYPE)),
/** Id of the report on which the distance request is being created */
reportID: PropTypes.string,
}),
Expand Down
2 changes: 1 addition & 1 deletion src/pages/iou/SplitBillDetailsPage.js
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ function SplitBillDetailsPage(props) {
iouCreated={splitCreated}
iouMerchant={splitMerchant}
iouCategory={splitCategory}
iouType={CONST.IOU.MONEY_REQUEST_TYPE.SPLIT}
iouType={CONST.IOU.TYPE.SPLIT}
isReadOnly={!isEditingSplitBill}
shouldShowSmartScanFields
receiptPath={props.transaction.receipt && props.transaction.receipt.source}
Expand Down
14 changes: 7 additions & 7 deletions src/pages/iou/steps/MoneyRequestConfirmPage.js
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ function MoneyRequestConfirmPage(props) {
[props.iou.participants, props.personalDetails],
);
const isPolicyExpenseChat = useMemo(() => ReportUtils.isPolicyExpenseChat(ReportUtils.getRootParentReport(props.report)), [props.report]);
const isManualRequestDM = props.selectedTab === CONST.TAB.MANUAL && iouType.current === CONST.IOU.MONEY_REQUEST_TYPE.REQUEST;
const isManualRequestDM = props.selectedTab === CONST.TAB.MANUAL && iouType.current === CONST.IOU.TYPE.REQUEST;

useEffect(() => {
IOU.resetMoneyRequestCategory();
Expand Down Expand Up @@ -211,7 +211,7 @@ function MoneyRequestConfirmPage(props) {
const trimmedComment = props.iou.comment.trim();

// 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.current === CONST.IOU.MONEY_REQUEST_TYPE.SPLIT && props.iou.receiptPath) {
if (iouType.current === CONST.IOU.TYPE.SPLIT && props.iou.receiptPath) {
const existingSplitChatReportID = CONST.REGEX.NUMBER.test(reportID.current) ? reportID.current : '';
FileUtils.readFileAsync(props.iou.receiptPath, props.iou.receiptFilename).then((receipt) => {
IOU.startSplitBill(
Expand All @@ -228,7 +228,7 @@ function MoneyRequestConfirmPage(props) {

// IOUs created from a group report will have a reportID param in the route.
// Since the user is already viewing the report, we don't need to navigate them to the report
if (iouType.current === CONST.IOU.MONEY_REQUEST_TYPE.SPLIT && CONST.REGEX.NUMBER.test(reportID.current)) {
if (iouType.current === CONST.IOU.TYPE.SPLIT && CONST.REGEX.NUMBER.test(reportID.current)) {
IOU.splitBill(
selectedParticipants,
props.currentUserPersonalDetails.login,
Expand All @@ -243,7 +243,7 @@ function MoneyRequestConfirmPage(props) {
}

// If the request is created from the global create menu, we also navigate the user to the group report
if (iouType.current === CONST.IOU.MONEY_REQUEST_TYPE.SPLIT) {
if (iouType.current === CONST.IOU.TYPE.SPLIT) {
IOU.splitBillAndOpenReport(
selectedParticipants,
props.currentUserPersonalDetails.login,
Expand Down Expand Up @@ -312,11 +312,11 @@ function MoneyRequestConfirmPage(props) {
return props.translate('common.distance');
}

if (iouType.current === CONST.IOU.MONEY_REQUEST_TYPE.SPLIT) {
if (iouType.current === CONST.IOU.TYPE.SPLIT) {
return props.translate('iou.split');
}

if (iouType.current === CONST.IOU.MONEY_REQUEST_TYPE.SEND) {
if (iouType.current === CONST.IOU.TYPE.SEND) {
return props.translate('common.send');
}

Expand Down Expand Up @@ -345,7 +345,7 @@ function MoneyRequestConfirmPage(props) {
/>
<MoneyRequestConfirmationList
transactionID={props.iou.transactionID}
hasMultipleParticipants={iouType.current === CONST.IOU.MONEY_REQUEST_TYPE.SPLIT}
hasMultipleParticipants={iouType.current === CONST.IOU.TYPE.SPLIT}
selectedParticipants={participants}
iouAmount={props.iou.amount}
iouComment={props.iou.comment}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,9 @@ function MoneyRequestParticipantsPage({iou, selectedTab, route}) {
const iouType = useRef(lodashGet(route, 'params.iouType', ''));
const reportID = useRef(lodashGet(route, 'params.reportID', ''));
const isDistanceRequest = MoneyRequestUtils.isDistanceRequest(iouType.current, selectedTab);
const isSendRequest = iouType.current === CONST.IOU.MONEY_REQUEST_TYPE.SEND;
const isSendRequest = iouType.current === CONST.IOU.TYPE.SEND;
const isScanRequest = MoneyRequestUtils.isScanRequest(selectedTab);
const isSplitRequest = iou.id === CONST.IOU.MONEY_REQUEST_TYPE.SPLIT;
const isSplitRequest = iou.id === CONST.IOU.TYPE.SPLIT;
const [headerTitle, setHeaderTitle] = useState();

useEffect(() => {
Expand Down Expand Up @@ -121,7 +121,7 @@ function MoneyRequestParticipantsPage({iou, selectedTab, route}) {
participants={iou.participants}
onAddParticipants={IOU.setMoneyRequestParticipants}
navigateToRequest={() => navigateToConfirmationStep(iouType.current)}
navigateToSplit={() => navigateToConfirmationStep(CONST.IOU.MONEY_REQUEST_TYPE.SPLIT)}
navigateToSplit={() => navigateToConfirmationStep(CONST.IOU.TYPE.SPLIT)}
safeAreaPaddingBottomStyle={safeAreaPaddingBottomStyle}
iouType={iouType.current}
isDistanceRequest={isDistanceRequest}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,7 @@ function MoneyRequestParticipantsSelector({

// 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.MONEY_REQUEST_TYPE.REQUEST,
iouType === CONST.IOU.TYPE.REQUEST,

// We don't want to include any P2P options like personal details or reports that are not workspace chats for certain features.
!isDistanceRequest,
Expand All @@ -240,7 +240,7 @@ function MoneyRequestParticipantsSelector({
// the app from crashing on native when you try to do this, we'll going to hide the button if you have a workspace and other participants
const hasPolicyExpenseChatParticipant = _.some(participants, (participant) => participant.isPolicyExpenseChat);
const shouldShowConfirmButton = !(participants.length > 1 && hasPolicyExpenseChatParticipant);
const isAllowedToSplit = !isDistanceRequest && iouType !== CONST.IOU.MONEY_REQUEST_TYPE.SEND;
const isAllowedToSplit = !isDistanceRequest && iouType !== CONST.IOU.TYPE.SEND;

return (
<View style={[styles.flex1, styles.w100, participants.length > 0 ? safeAreaPaddingBottomStyle : {}]}>
Expand Down
6 changes: 3 additions & 3 deletions tests/actions/IOUTest.js
Original file line number Diff line number Diff line change
Expand Up @@ -1105,9 +1105,9 @@ describe('actions/IOU', () => {
`Split bill with ${RORY_EMAIL}, ${CARLOS_EMAIL}, ${JULES_EMAIL}, and ${VIT_EMAIL} [${DateUtils.getDBTime().slice(0, 10)}]`,
);

expect(carlosTransaction.comment.source).toBe(CONST.IOU.MONEY_REQUEST_TYPE.SPLIT);
expect(julesTransaction.comment.source).toBe(CONST.IOU.MONEY_REQUEST_TYPE.SPLIT);
expect(vitTransaction.comment.source).toBe(CONST.IOU.MONEY_REQUEST_TYPE.SPLIT);
expect(carlosTransaction.comment.source).toBe(CONST.IOU.TYPE.SPLIT);
expect(julesTransaction.comment.source).toBe(CONST.IOU.TYPE.SPLIT);
expect(vitTransaction.comment.source).toBe(CONST.IOU.TYPE.SPLIT);

expect(carlosTransaction.comment.originalTransactionID).toBe(groupTransaction.transactionID);
expect(julesTransaction.comment.originalTransactionID).toBe(groupTransaction.transactionID);
Expand Down
Loading

0 comments on commit 39d2a84

Please sign in to comment.