Skip to content

Commit

Permalink
Merge pull request #47214 from daledah/fix/46739
Browse files Browse the repository at this point in the history
fix: remove Expensify employee from list participants
  • Loading branch information
Gonals authored Aug 26, 2024
2 parents f7c9fa8 + 34cd658 commit 1a6d5e4
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 30 deletions.
56 changes: 29 additions & 27 deletions src/components/MoneyRequestConfirmationList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -528,33 +528,35 @@ function MoneyRequestConfirmationList({
const currencySymbol = currencyList?.[iouCurrencyCode ?? '']?.symbol ?? iouCurrencyCode;
const formattedTotalAmount = CurrencyUtils.convertToDisplayStringWithoutCurrency(iouAmount, iouCurrencyCode);

return [payeeOption, ...selectedParticipants].map((participantOption: Participant) => ({
...participantOption,
tabIndex: -1,
isSelected: false,
isInteractive: !shouldDisableParticipant(participantOption),
rightElement: (
<MoneyRequestAmountInput
autoGrow={false}
amount={transaction?.splitShares?.[participantOption.accountID ?? -1]?.amount}
currency={iouCurrencyCode}
prefixCharacter={currencySymbol}
disableKeyboard={false}
isCurrencyPressable={false}
hideFocusedState={false}
hideCurrencySymbol
formatAmountOnBlur
prefixContainerStyle={[styles.pv0]}
inputStyle={[styles.optionRowAmountInput]}
containerStyle={[styles.textInputContainer]}
touchableInputWrapperStyle={[styles.ml3]}
onFormatAmount={CurrencyUtils.convertToDisplayStringWithoutCurrency}
onAmountChange={(value: string) => onSplitShareChange(participantOption.accountID ?? -1, Number(value))}
maxLength={formattedTotalAmount.length}
contentWidth={formattedTotalAmount.length * 8}
/>
),
}));
return [payeeOption, ...selectedParticipants]
.filter((participantOption) => !PolicyUtils.isExpensifyTeam(participantOption.login))
.map((participantOption: Participant) => ({
...participantOption,
tabIndex: -1,
isSelected: false,
isInteractive: !shouldDisableParticipant(participantOption),
rightElement: (
<MoneyRequestAmountInput
autoGrow={false}
amount={transaction?.splitShares?.[participantOption.accountID ?? -1]?.amount}
currency={iouCurrencyCode}
prefixCharacter={currencySymbol}
disableKeyboard={false}
isCurrencyPressable={false}
hideFocusedState={false}
hideCurrencySymbol
formatAmountOnBlur
prefixContainerStyle={[styles.pv0]}
inputStyle={[styles.optionRowAmountInput]}
containerStyle={[styles.textInputContainer]}
touchableInputWrapperStyle={[styles.ml3]}
onFormatAmount={CurrencyUtils.convertToDisplayStringWithoutCurrency}
onAmountChange={(value: string) => onSplitShareChange(participantOption.accountID ?? -1, Number(value))}
maxLength={formattedTotalAmount.length}
contentWidth={formattedTotalAmount.length * 8}
/>
),
}));
}, [
isTypeSplit,
payeePersonalDetails,
Expand Down
4 changes: 3 additions & 1 deletion src/libs/ReportUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6374,7 +6374,9 @@ function getMoneyRequestOptions(report: OnyxEntry<Report>, policy: OnyxEntry<Pol
return [];
}

const otherParticipants = reportParticipants.filter((accountID) => currentUserPersonalDetails?.accountID !== accountID);
const otherParticipants = reportParticipants.filter(
(accountID) => currentUserPersonalDetails?.accountID !== accountID && !PolicyUtils.isExpensifyTeam(allPersonalDetails?.[accountID]?.login),
);
const hasSingleParticipantInReport = otherParticipants.length === 1;
let options: IOUType[] = [];

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import type {FileObject} from '@components/AttachmentModal';
import AttachmentPicker from '@components/AttachmentPicker';
import Icon from '@components/Icon';
import * as Expensicons from '@components/Icon/Expensicons';
import {usePersonalDetails} from '@components/OnyxProvider';
import type {PopoverMenuItem} from '@components/PopoverMenu';
import PopoverMenu from '@components/PopoverMenu';
import PressableWithFeedback from '@components/Pressable/PressableWithFeedback';
Expand Down Expand Up @@ -122,6 +123,7 @@ function AttachmentPickerWithMenuItems({
const {translate} = useLocalize();
const {windowHeight, windowWidth} = useWindowDimensions();
const {shouldUseNarrowLayout} = useResponsiveLayout();
const allPersonalDetails = usePersonalDetails();

/**
* Returns the list of IOU Options
Expand Down Expand Up @@ -167,7 +169,8 @@ function AttachmentPickerWithMenuItems({
return ReportUtils.temporary_getMoneyRequestOptions(report, policy, reportParticipantIDs ?? []).map((option) => ({
...options[option],
}));
}, [translate, report, policy, reportParticipantIDs]);
// eslint-disable-next-line react-compiler/react-compiler, react-hooks/exhaustive-deps
}, [translate, report, policy, reportParticipantIDs, allPersonalDetails]);

/**
* Determines if we can show the task option
Expand Down
6 changes: 5 additions & 1 deletion src/pages/iou/request/step/IOURequestStepAmount.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import * as TransactionEdit from '@libs/actions/TransactionEdit';
import * as CurrencyUtils from '@libs/CurrencyUtils';
import Navigation from '@libs/Navigation/Navigation';
import * as OptionsListUtils from '@libs/OptionsListUtils';
import * as PolicyUtils from '@libs/PolicyUtils';
import * as ReportUtils from '@libs/ReportUtils';
import * as TransactionUtils from '@libs/TransactionUtils';
import {getRequestType} from '@libs/TransactionUtils';
Expand Down Expand Up @@ -79,6 +80,7 @@ function IOURequestStepAmount({
const isSaveButtonPressed = useRef(false);
const iouRequestType = getRequestType(transaction);
const [reportNameValuePairs] = useOnyx(`${ONYXKEYS.COLLECTION.REPORT_NAME_VALUE_PAIRS}${report?.reportID ?? -1}`);
const [allPersonalDetails] = useOnyx(ONYXKEYS.PERSONAL_DETAILS_LIST);

const isEditing = action === CONST.IOU.ACTION.EDIT;
const isSplitBill = iouType === CONST.IOU.TYPE.SPLIT;
Expand Down Expand Up @@ -253,7 +255,9 @@ function IOURequestStepAmount({
}
IOU.setMoneyRequestParticipantsFromReport(transactionID, report);
if (isSplitBill && !report.isOwnPolicyExpenseChat && report.participants) {
const participantAccountIDs = Object.keys(report.participants).map((accountID) => Number(accountID));
const participantAccountIDs = Object.keys(report.participants)
.map((accountID) => Number(accountID))
.filter((accountID) => !PolicyUtils.isExpensifyTeam(allPersonalDetails?.[accountID]?.login));
IOU.setSplitShares(transaction, amountInSmallestCurrencyUnits, currency || CONST.CURRENCY.USD, participantAccountIDs);
}
navigateToConfirmationPage();
Expand Down

0 comments on commit 1a6d5e4

Please sign in to comment.