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

Bring back send money option for newDot #28321

Merged
merged 12 commits into from
Oct 10, 2023
1 change: 0 additions & 1 deletion src/CONST.ts
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,6 @@ const CONST = {
BETA_EXPENSIFY_WALLET: 'expensifyWallet',
BETA_COMMENT_LINKING: 'commentLinking',
INTERNATIONALIZATION: 'internationalization',
IOU_SEND: 'sendMoney',
POLICY_ROOMS: 'policyRooms',
PASSWORDLESS: 'passwordless',
TASKS: 'tasks',
Expand Down
13 changes: 4 additions & 9 deletions src/components/ReportWelcomeText.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,17 +48,13 @@ const propTypes = {
/** All of the personal details for everyone */
personalDetails: PropTypes.objectOf(personalDetailsPropTypes),

/** List of betas available to current user */
betas: PropTypes.arrayOf(PropTypes.string),

...withLocalizePropTypes,
};

const defaultProps = {
report: {},
policy: {},
personalDetails: {},
betas: [],
};

function ReportWelcomeText(props) {
Expand All @@ -73,7 +69,7 @@ function ReportWelcomeText(props) {
);
const isUserPolicyAdmin = PolicyUtils.isPolicyAdmin(props.policy);
const roomWelcomeMessage = ReportUtils.getRoomWelcomeMessage(props.report, isUserPolicyAdmin);
const moneyRequestOptions = ReportUtils.getMoneyRequestOptions(props.report, participantAccountIDs, props.betas);
const moneyRequestOptions = ReportUtils.getMoneyRequestOptions(props.report, participantAccountIDs);

return (
<>
Expand Down Expand Up @@ -137,7 +133,9 @@ function ReportWelcomeText(props) {
))}
</Text>
)}
{moneyRequestOptions.includes(CONST.IOU.MONEY_REQUEST_TYPE.REQUEST) && <Text>{props.translate('reportActionsView.usePlusButton')}</Text>}
{(moneyRequestOptions.includes(CONST.IOU.MONEY_REQUEST_TYPE.SEND) || moneyRequestOptions.includes(CONST.IOU.MONEY_REQUEST_TYPE.REQUEST)) && (
<Text>{props.translate('reportActionsView.usePlusButton')}</Text>
)}
</Text>
</>
);
Expand All @@ -150,9 +148,6 @@ ReportWelcomeText.displayName = 'ReportWelcomeText';
export default compose(
withLocalize,
withOnyx({
betas: {
key: ONYXKEYS.BETAS,
},
personalDetails: {
key: ONYXKEYS.PERSONAL_DETAILS_LIST,
},
Expand Down
2 changes: 1 addition & 1 deletion src/languages/en.ts
Original file line number Diff line number Diff line change
Expand Up @@ -441,7 +441,7 @@ export default {
chatWithAccountManager: 'Chat with your account manager here',
sayHello: 'Say hello!',
welcomeToRoom: ({roomName}: WelcomeToRoomParams) => `Welcome to ${roomName}!`,
usePlusButton: '\n\nYou can also use the + button below to request money or assign a task!',
usePlusButton: '\n\nYou can also use the + button to send money, request money, or assign a task!',
},
reportAction: {
asCopilot: 'as copilot for',
Expand Down
2 changes: 1 addition & 1 deletion src/languages/es.ts
Original file line number Diff line number Diff line change
Expand Up @@ -433,7 +433,7 @@ export default {
chatWithAccountManager: 'Chatea con tu gestor de cuenta aquí',
sayHello: '¡Saluda!',
welcomeToRoom: ({roomName}: WelcomeToRoomParams) => `¡Bienvenido a ${roomName}!`,
usePlusButton: '\n\n¡También puedes usar el botón + de abajo para pedir dinero o asignar una tarea!',
usePlusButton: '\n\n¡También puedes usar el botón + de abajo para enviar dinero, pedir dinero, o asignar una tarea!',
},
reportAction: {
asCopilot: 'como copiloto de',
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 moneyRequestType: string[] = [CONST.IOU.MONEY_REQUEST_TYPE.REQUEST, CONST.IOU.MONEY_REQUEST_TYPE.SPLIT, CONST.IOU.MONEY_REQUEST_TYPE.SEND];
return moneyRequestType.includes(iouType);
}

Expand Down
8 changes: 0 additions & 8 deletions src/libs/Permissions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,6 @@ function canUseDefaultRooms(betas: Beta[]): boolean {
return betas?.includes(CONST.BETAS.DEFAULT_ROOMS) || canUseAllBetas(betas);
}

/**
* IOU Send feature is temporarily disabled.
*/
function canUseIOUSend(): boolean {
return false;
}

function canUseWallet(betas: Beta[]): boolean {
return betas?.includes(CONST.BETAS.BETA_EXPENSIFY_WALLET) || canUseAllBetas(betas);
}
Expand Down Expand Up @@ -68,7 +61,6 @@ export default {
canUseChronos,
canUsePayWithExpensify,
canUseDefaultRooms,
canUseIOUSend,
canUseWallet,
canUseCommentLinking,
canUsePolicyRooms,
Expand Down
5 changes: 2 additions & 3 deletions src/libs/ReportUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -3367,10 +3367,9 @@ function canRequestMoney(report, participants) {
*
* @param {Object} report
* @param {Array<Number>} reportParticipants
* @param {Array} betas
* @returns {Array}
*/
function getMoneyRequestOptions(report, reportParticipants, betas) {
function getMoneyRequestOptions(report, reportParticipants) {
// In any thread or task report, we do not allow any new money requests yet
if (isChatThread(report) || isTaskReport(report)) {
return [];
Expand Down Expand Up @@ -3402,7 +3401,7 @@ function getMoneyRequestOptions(report, reportParticipants, betas) {
...(canRequestMoney(report, participants) ? [CONST.IOU.MONEY_REQUEST_TYPE.REQUEST] : []),

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

Expand Down
1 change: 0 additions & 1 deletion src/libs/__mocks__/Permissions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,5 @@ export default {
...jest.requireActual('../Permissions'),
canUseDefaultRooms: (betas: Beta[]) => betas.includes(CONST.BETAS.DEFAULT_ROOMS),
canUsePolicyRooms: (betas: Beta[]) => betas.includes(CONST.BETAS.POLICY_ROOMS),
canUseIOUSend: (betas: Beta[]) => betas.includes(CONST.BETAS.IOU_SEND),
canUseCustomStatus: (betas: Beta[]) => betas.includes(CONST.BETAS.CUSTOM_STATUS),
};
Original file line number Diff line number Diff line change
Expand Up @@ -140,11 +140,11 @@ function AttachmentPickerWithMenuItems({
},
};

return _.map(ReportUtils.getMoneyRequestOptions(report, reportParticipantIDs, betas), (option) => ({
return _.map(ReportUtils.getMoneyRequestOptions(report, reportParticipantIDs), (option) => ({
...options[option],
onSelected: () => IOU.startMoneyRequest(option, report.reportID),
}));
}, [betas, report, reportParticipantIDs, translate]);
}, [report, reportParticipantIDs, translate]);

/**
* Determines if we can show the task option
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -185,15 +185,11 @@ function FloatingActionButtonAndPopover(props) {
text: props.translate('sidebarScreen.fabNewChat'),
onSelected: () => interceptAnonymousUser(() => Navigation.navigate(ROUTES.NEW)),
},
...(Permissions.canUseIOUSend(props.betas)
? [
{
icon: Expensicons.Send,
text: props.translate('iou.sendMoney'),
onSelected: () => interceptAnonymousUser(() => IOU.startMoneyRequest(CONST.IOU.MONEY_REQUEST_TYPE.SEND)),
},
]
: []),
{
icon: Expensicons.Send,
text: props.translate('iou.sendMoney'),
onSelected: () => interceptAnonymousUser(() => IOU.startMoneyRequest(CONST.IOU.MONEY_REQUEST_TYPE.SEND)),
},
{
icon: Expensicons.MoneyCircle,
text: props.translate('iou.requestMoney'),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,12 @@ const propTypes = {
iou: iouPropTypes,

/** The current tab we have navigated to in the request modal. String that corresponds to the request type. */
selectedTab: PropTypes.oneOf([CONST.TAB.DISTANCE, CONST.TAB.MANUAL, CONST.TAB.SCAN]).isRequired,
selectedTab: PropTypes.oneOf([CONST.TAB.DISTANCE, CONST.TAB.MANUAL, CONST.TAB.SCAN]),
};

const defaultProps = {
iou: iouDefaultProps,
selectedTab: undefined,
};

function MoneyRequestParticipantsPage({iou, selectedTab, route}) {
Expand Down Expand Up @@ -113,7 +114,7 @@ function MoneyRequestParticipantsPage({iou, selectedTab, route}) {
ref={(el) => (optionsSelectorRef.current = el)}
participants={iou.participants}
onAddParticipants={IOU.setMoneyRequestParticipants}
navigateToRequest={() => navigateToConfirmationStep(CONST.IOU.MONEY_REQUEST_TYPE.REQUEST)}
navigateToRequest={() => navigateToConfirmationStep(iouType.current)}
navigateToSplit={() => navigateToConfirmationStep(CONST.IOU.MONEY_REQUEST_TYPE.SPLIT)}
safeAreaPaddingBottomStyle={safeAreaPaddingBottomStyle}
iouType={iouType.current}
Expand All @@ -126,7 +127,7 @@ function MoneyRequestParticipantsPage({iou, selectedTab, route}) {
);
}

MoneyRequestParticipantsPage.displayName = 'IOUParticipantsPage';
MoneyRequestParticipantsPage.displayName = 'MoneyRequestParticipantsPage';
MoneyRequestParticipantsPage.propTypes = propTypes;
MoneyRequestParticipantsPage.defaultProps = defaultProps;

Expand Down
2 changes: 1 addition & 1 deletion tests/unit/IOUUtilsTest.js
Original file line number Diff line number Diff line change
Expand Up @@ -118,10 +118,10 @@ describe('isValidMoneyRequestType', () => {
test('Return true for valid iou type', () => {
expect(IOUUtils.isValidMoneyRequestType('request')).toBe(true);
expect(IOUUtils.isValidMoneyRequestType('split')).toBe(true);
expect(IOUUtils.isValidMoneyRequestType('send')).toBe(true);
});

test('Return false for invalid iou type', () => {
expect(IOUUtils.isValidMoneyRequestType('send')).toBe(false);
expect(IOUUtils.isValidMoneyRequestType('money')).toBe(false);
});
});
Loading