Skip to content

Commit

Permalink
Merge pull request #41892 from tienifr/fix/39309
Browse files Browse the repository at this point in the history
Remove Track beta
  • Loading branch information
thienlnam authored May 13, 2024
2 parents e40b479 + c97fa0b commit 97097ff
Show file tree
Hide file tree
Showing 6 changed files with 8 additions and 20 deletions.
1 change: 0 additions & 1 deletion src/CONST.ts
Original file line number Diff line number Diff line change
Expand Up @@ -362,7 +362,6 @@ const CONST = {
DEFAULT_ROOMS: 'defaultRooms',
VIOLATIONS: 'violations',
REPORT_FIELDS: 'reportFields',
TRACK_EXPENSE: 'trackExpense',
P2P_DISTANCE_REQUESTS: 'p2pDistanceRequests',
WORKFLOWS_DELAYED_SUBMISSION: 'workflowsDelayedSubmission',
SPOTNANA_TRAVEL: 'spotnanaTravel',
Expand Down
4 changes: 1 addition & 3 deletions src/components/ReportWelcomeText.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import {View} from 'react-native';
import type {OnyxEntry} from 'react-native-onyx';
import {withOnyx} from 'react-native-onyx';
import useLocalize from '@hooks/useLocalize';
import usePermissions from '@hooks/usePermissions';
import useThemeStyles from '@hooks/useThemeStyles';
import Navigation from '@libs/Navigation/Navigation';
import * as OptionsListUtils from '@libs/OptionsListUtils';
Expand Down Expand Up @@ -35,7 +34,6 @@ type ReportWelcomeTextProps = ReportWelcomeTextOnyxProps & {
function ReportWelcomeText({report, policy, personalDetails}: ReportWelcomeTextProps) {
const {translate} = useLocalize();
const styles = useThemeStyles();
const {canUseTrackExpense} = usePermissions();
const isPolicyExpenseChat = ReportUtils.isPolicyExpenseChat(report);
const isChatRoom = ReportUtils.isChatRoom(report);
const isSelfDM = ReportUtils.isSelfDM(report);
Expand All @@ -46,7 +44,7 @@ function ReportWelcomeText({report, policy, personalDetails}: ReportWelcomeTextP
const displayNamesWithTooltips = ReportUtils.getDisplayNamesWithTooltips(OptionsListUtils.getPersonalDetailsForAccountIDs(participantAccountIDs, personalDetails), isMultipleParticipant);
const isUserPolicyAdmin = PolicyUtils.isPolicyAdmin(policy);
const roomWelcomeMessage = ReportUtils.getRoomWelcomeMessage(report, isUserPolicyAdmin);
const moneyRequestOptions = ReportUtils.temporary_getMoneyRequestOptions(report, policy, participantAccountIDs, canUseTrackExpense);
const moneyRequestOptions = ReportUtils.temporary_getMoneyRequestOptions(report, policy, participantAccountIDs);
const additionalText = moneyRequestOptions
.filter((item): item is Exclude<IOUType, typeof CONST.IOU.TYPE.REQUEST | typeof CONST.IOU.TYPE.SEND | typeof CONST.IOU.TYPE.INVOICE> => item !== CONST.IOU.TYPE.INVOICE)
.map((item) => translate(`reportActionsView.iouTypes.${item}`))
Expand Down
5 changes: 0 additions & 5 deletions src/libs/Permissions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,6 @@ function canUseViolations(betas: OnyxEntry<Beta[]>): boolean {
return !!betas?.includes(CONST.BETAS.VIOLATIONS) || canUseAllBetas(betas);
}

function canUseTrackExpense(betas: OnyxEntry<Beta[]>): boolean {
return !!betas?.includes(CONST.BETAS.TRACK_EXPENSE) || canUseAllBetas(betas);
}

function canUseP2PDistanceRequests(betas: OnyxEntry<Beta[]>, iouType: IOUType | undefined): boolean {
// Allow using P2P distance request for TrackExpense outside of the beta, because that project doesn't want to be limited by the more cautious P2P distance beta
return !!betas?.includes(CONST.BETAS.P2P_DISTANCE_REQUESTS) || canUseAllBetas(betas) || iouType === CONST.IOU.TYPE.TRACK;
Expand Down Expand Up @@ -60,7 +56,6 @@ export default {
canUseDefaultRooms,
canUseLinkPreviews,
canUseViolations,
canUseTrackExpense,
canUseReportFields,
canUseP2PDistanceRequests,
canUseWorkflowsDelayedSubmission,
Expand Down
9 changes: 4 additions & 5 deletions src/libs/ReportUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5470,9 +5470,9 @@ function isGroupChatAdmin(report: OnyxEntry<Report>, accountID: number) {
* None of the options should show in chat threads or if there is some special Expensify account
* as a participant of the report.
*/
function getMoneyRequestOptions(report: OnyxEntry<Report>, policy: OnyxEntry<Policy>, reportParticipants: number[], canUseTrackExpense = true, filterDeprecatedTypes = false): IOUType[] {
function getMoneyRequestOptions(report: OnyxEntry<Report>, policy: OnyxEntry<Policy>, reportParticipants: number[], filterDeprecatedTypes = false): IOUType[] {
// In any thread or task report, we do not allow any new expenses yet
if (isChatThread(report) || isTaskReport(report) || (!canUseTrackExpense && isSelfDM(report)) || isInvoiceRoom(report) || isInvoiceReport(report)) {
if (isChatThread(report) || isTaskReport(report) || isInvoiceRoom(report) || isInvoiceReport(report)) {
return [];
}

Expand Down Expand Up @@ -5511,7 +5511,7 @@ function getMoneyRequestOptions(report: OnyxEntry<Report>, policy: OnyxEntry<Pol
}

// If the user can request money from the workspace report, they can also track expenses
if (canUseTrackExpense && (isPolicyExpenseChat(report) || isExpenseReport(report))) {
if (isPolicyExpenseChat(report) || isExpenseReport(report)) {
options = [...options, CONST.IOU.TYPE.TRACK];
}
}
Expand All @@ -5536,9 +5536,8 @@ function temporary_getMoneyRequestOptions(
report: OnyxEntry<Report>,
policy: OnyxEntry<Policy>,
reportParticipants: number[],
canUseTrackExpense = true,
): Array<Exclude<IOUType, typeof CONST.IOU.TYPE.REQUEST | typeof CONST.IOU.TYPE.SEND>> {
return getMoneyRequestOptions(report, policy, reportParticipants, canUseTrackExpense, true) as Array<Exclude<IOUType, typeof CONST.IOU.TYPE.REQUEST | typeof CONST.IOU.TYPE.SEND>>;
return getMoneyRequestOptions(report, policy, reportParticipants, true) as Array<Exclude<IOUType, typeof CONST.IOU.TYPE.REQUEST | typeof CONST.IOU.TYPE.SEND>>;
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ import PressableWithFeedback from '@components/Pressable/PressableWithFeedback';
import Tooltip from '@components/Tooltip/PopoverAnchorTooltip';
import useIsReportOpenInRHP from '@hooks/useIsReportOpenInRHP';
import useLocalize from '@hooks/useLocalize';
import usePermissions from '@hooks/usePermissions';
import usePrevious from '@hooks/usePrevious';
import useTheme from '@hooks/useTheme';
import useThemeStyles from '@hooks/useThemeStyles';
Expand Down Expand Up @@ -118,7 +117,6 @@ function AttachmentPickerWithMenuItems({
const styles = useThemeStyles();
const {translate} = useLocalize();
const {windowHeight, windowWidth} = useWindowDimensions();
const {canUseTrackExpense} = usePermissions();
const {isSmallScreenWidth} = useWindowDimensions();
const isReportOpenInRHP = useIsReportOpenInRHP();
const shouldUseNarrowLayout = isReportOpenInRHP || isSmallScreenWidth;
Expand Down Expand Up @@ -155,10 +153,10 @@ function AttachmentPickerWithMenuItems({
},
};

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

/**
* Determines if we can show the task option
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,6 @@ function FloatingActionButtonAndPopover(
const {translate} = useLocalize();
const [isCreateMenuActive, setIsCreateMenuActive] = useState(false);
const fabRef = useRef<HTMLDivElement>(null);
const {canUseTrackExpense} = usePermissions();
const {isSmallScreenWidth, windowHeight} = useWindowDimensions();
const isFocused = useIsFocused();
const prevIsFocused = usePrevious(isFocused);
Expand Down Expand Up @@ -339,7 +338,7 @@ function FloatingActionButtonAndPopover(
text: translate('sidebarScreen.fabNewChat'),
onSelected: () => interceptAnonymousUser(Report.startNewChat),
},
...(canUseTrackExpense && selfDMReportID
...(selfDMReportID
? [
{
icon: getIconForAction(CONST.IOU.TYPE.TRACK),
Expand Down

0 comments on commit 97097ff

Please sign in to comment.