Skip to content

Commit

Permalink
Merge pull request Expensify#50239 from pasyukevich/feature/create-ex…
Browse files Browse the repository at this point in the history
…pense-update

add create expense option to IOU actions
  • Loading branch information
grgia authored Oct 14, 2024
2 parents 4fffdd5 + d590354 commit 4a3f2da
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import PopoverMenu from '@components/PopoverMenu';
import PressableWithFeedback from '@components/Pressable/PressableWithFeedback';
import Tooltip from '@components/Tooltip/PopoverAnchorTooltip';
import useLocalize from '@hooks/useLocalize';
import usePermissions from '@hooks/usePermissions';
import usePrevious from '@hooks/usePrevious';
import useResponsiveLayout from '@hooks/useResponsiveLayout';
import useTheme from '@hooks/useTheme';
Expand Down Expand Up @@ -120,6 +121,7 @@ function AttachmentPickerWithMenuItems({
const {isDelegateAccessRestricted, delegatorEmail} = useDelegateUserDetails();
const [isNoDelegateAccessMenuVisible, setIsNoDelegateAccessMenuVisible] = useState(false);
const [policy] = useOnyx(`${ONYXKEYS.COLLECTION.POLICY}${report?.policyID}`);
const {canUseCombinedTrackSubmit} = usePermissions();

/**
* Returns the list of IOU Options
Expand All @@ -141,8 +143,8 @@ function AttachmentPickerWithMenuItems({
onSelected: () => selectOption(() => IOU.startMoneyRequest(CONST.IOU.TYPE.SPLIT, report?.reportID ?? '-1'), true),
},
[CONST.IOU.TYPE.SUBMIT]: {
icon: getIconForAction(CONST.IOU.TYPE.REQUEST),
text: translate('iou.submitExpense'),
icon: canUseCombinedTrackSubmit ? getIconForAction(CONST.IOU.TYPE.CREATE) : getIconForAction(CONST.IOU.TYPE.REQUEST),
text: canUseCombinedTrackSubmit ? translate('iou.createExpense') : translate('iou.submitExpense'),
onSelected: () => selectOption(() => IOU.startMoneyRequest(CONST.IOU.TYPE.SUBMIT, report?.reportID ?? '-1'), true),
},
[CONST.IOU.TYPE.PAY]: {
Expand All @@ -157,8 +159,8 @@ function AttachmentPickerWithMenuItems({
},
},
[CONST.IOU.TYPE.TRACK]: {
icon: getIconForAction(CONST.IOU.TYPE.TRACK),
text: translate('iou.trackExpense'),
icon: canUseCombinedTrackSubmit ? getIconForAction(CONST.IOU.TYPE.CREATE) : getIconForAction(CONST.IOU.TYPE.TRACK),
text: canUseCombinedTrackSubmit ? translate('iou.createExpense') : translate('iou.trackExpense'),
onSelected: () => selectOption(() => IOU.startMoneyRequest(CONST.IOU.TYPE.TRACK, report?.reportID ?? '-1'), true),
},
[CONST.IOU.TYPE.INVOICE]: {
Expand All @@ -168,10 +170,15 @@ function AttachmentPickerWithMenuItems({
},
};

return ReportUtils.temporary_getMoneyRequestOptions(report, policy, reportParticipantIDs ?? []).map((option) => ({
const moneyRequestOptionsList = ReportUtils.temporary_getMoneyRequestOptions(report, policy, reportParticipantIDs ?? []).map((option) => ({
...options[option],
}));
}, [translate, report, policy, reportParticipantIDs, isDelegateAccessRestricted]);

return canUseCombinedTrackSubmit
? // Removes track option for the workspace with the canUseCombinedTrackSubmit enabled
moneyRequestOptionsList.filter((item, index, self) => index === self.findIndex((t) => t.text === item.text))
: moneyRequestOptionsList;
}, [translate, canUseCombinedTrackSubmit, report, policy, reportParticipantIDs, isDelegateAccessRestricted]);

/**
* Determines if we can show the task option
Expand Down
6 changes: 3 additions & 3 deletions src/pages/iou/request/IOURequestStartPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -45,19 +45,19 @@ function IOURequestStartPage({
// eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing
const [transaction] = useOnyx(`${ONYXKEYS.COLLECTION.TRANSACTION_DRAFT}${route?.params.transactionID || -1}`);
const [allPolicies] = useOnyx(ONYXKEYS.COLLECTION.POLICY);
const {canUseP2PDistanceRequests, canUseCombinedTrackSubmit} = usePermissions(iouType);

const tabTitles = {
[CONST.IOU.TYPE.REQUEST]: translate('iou.submitExpense'),
[CONST.IOU.TYPE.SUBMIT]: translate('iou.submitExpense'),
[CONST.IOU.TYPE.SUBMIT]: canUseCombinedTrackSubmit ? translate('iou.createExpense') : translate('iou.submitExpense'),
[CONST.IOU.TYPE.SEND]: translate('iou.paySomeone', {name: ReportUtils.getPayeeName(report)}),
[CONST.IOU.TYPE.PAY]: translate('iou.paySomeone', {name: ReportUtils.getPayeeName(report)}),
[CONST.IOU.TYPE.SPLIT]: translate('iou.splitExpense'),
[CONST.IOU.TYPE.TRACK]: translate('iou.trackExpense'),
[CONST.IOU.TYPE.TRACK]: canUseCombinedTrackSubmit ? translate('iou.createExpense') : translate('iou.trackExpense'),
[CONST.IOU.TYPE.INVOICE]: translate('workspace.invoices.sendInvoice'),
[CONST.IOU.TYPE.CREATE]: translate('iou.createExpense'),
};
const transactionRequestType = useRef(TransactionUtils.getRequestType(transaction));
const {canUseP2PDistanceRequests, canUseCombinedTrackSubmit} = usePermissions(iouType);
const isFromGlobalCreate = isEmptyObject(report?.reportID);

// Clear out the temporary expense if the reportID in the URL has changed from the transaction's reportID
Expand Down

0 comments on commit 4a3f2da

Please sign in to comment.