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 @@ -232,7 +232,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 @@ -430,7 +430,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 @@ -422,7 +422,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 @@ -3346,10 +3346,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 @@ -3381,7 +3380,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 @@ -126,7 +126,7 @@ function MoneyRequestParticipantsPage({iou, selectedTab, route}) {
ref={(el) => (optionsSelectorRef.current = el)}
participants={iou.participants}
onAddParticipants={IOU.setMoneyRequestParticipants}
navigateToRequest={(option) => navigateToRequestStep(CONST.IOU.MONEY_REQUEST_TYPE.REQUEST, option)}
navigateToRequest={(option) => navigateToRequestStep(iouType.current, option)}
Copy link
Contributor

Choose a reason for hiding this comment

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

Will this be different based on who is looking at the iou?

For instance, if I try to send you money will this be a MONEY_REQUEST_TYPE.REQUEST for you and a MONEY_REQUEST_TYPE.SEND for me?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is part of the flow when a user taps on the send money button on either global create or on a DM. So it solely depends on the option you have selected in the beginning. So if a userA started the flow then it will always be a Send request for them and this page doesn't actually come into the picture for userB.

For instance, if I try to send you money will this be a MONEY_REQUEST_TYPE.REQUEST for you and a MONEY_REQUEST_TYPE.SEND for me?

I think we figure this out by the accountID and managerID, manager seems to be the payer and accountID is the payee.

Screenshot 2023-10-05 at 11 56 47 PM

navigateToSplit={() => navigateToSplitStep(CONST.IOU.MONEY_REQUEST_TYPE.SPLIT)}
safeAreaPaddingBottomStyle={safeAreaPaddingBottomStyle}
iouType={iouType.current}
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