Skip to content

Commit

Permalink
Merge branch 'Expensify:main' into krishna2323/issue/53851
Browse files Browse the repository at this point in the history
  • Loading branch information
Krishna2323 authored Dec 23, 2024
2 parents 3e5ef57 + 5f65aec commit 3facff0
Show file tree
Hide file tree
Showing 13 changed files with 141 additions and 90 deletions.
3 changes: 3 additions & 0 deletions scripts/applyPatches.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,13 @@ function patchPackage {
OS="$(uname)"
if [[ "$OS" == "Darwin" || "$OS" == "Linux" ]]; then
npx patch-package --error-on-fail --color=always
EXIT_CODE=$?
if [[ "$IS_HYBRID_APP_REPO" == "true" && "$NEW_DOT_FLAG" == "false" ]]; then
echo -e "\n${GREEN}Applying HybridApp patches!${NC}"
npx patch-package --patch-dir 'Mobile-Expensify/patches' --error-on-fail --color=always
EXIT_CODE+=$?
fi
exit $EXIT_CODE
else
error "Unsupported OS: $OS"
exit 1
Expand Down
9 changes: 5 additions & 4 deletions src/components/ReportActionItem/TaskPreview.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,8 @@ function TaskPreview({taskReportID, action, contextMenuAnchor, chatReportID, che
? taskReport?.stateNum === CONST.REPORT.STATE_NUM.APPROVED && taskReport.statusNum === CONST.REPORT.STATUS_NUM.APPROVED
: action?.childStateNum === CONST.REPORT.STATE_NUM.APPROVED && action?.childStatusNum === CONST.REPORT.STATUS_NUM.APPROVED;
const taskTitle = Str.htmlEncode(TaskUtils.getTaskTitleFromReport(taskReport, action?.childReportName ?? ''));
const taskAssigneeAccountID = Task.getTaskAssigneeAccountID(taskReport) ?? action?.childManagerAccountID ?? -1;
const taskAssigneeAccountID = Task.getTaskAssigneeAccountID(taskReport) ?? action?.childManagerAccountID ?? CONST.DEFAULT_NUMBER_ID;
const taskOwnerAccountID = taskReport?.ownerAccountID ?? action?.actorAccountID ?? CONST.DEFAULT_NUMBER_ID;
const hasAssignee = taskAssigneeAccountID > 0;
const personalDetails = usePersonalDetails();
const avatar = personalDetails?.[taskAssigneeAccountID]?.avatar ?? Expensicons.FallbackAvatar;
Expand Down Expand Up @@ -106,12 +107,12 @@ function TaskPreview({taskReportID, action, contextMenuAnchor, chatReportID, che
<Checkbox
style={[styles.mr2]}
isChecked={isTaskCompleted}
disabled={!Task.canModifyTask(taskReport, currentUserPersonalDetails.accountID) || !Task.canActionTask(taskReport, currentUserPersonalDetails.accountID)}
disabled={!Task.canActionTask(taskReport, currentUserPersonalDetails.accountID, taskOwnerAccountID, taskAssigneeAccountID)}
onPress={Session.checkIfActionIsAllowed(() => {
if (isTaskCompleted) {
Task.reopenTask(taskReport);
Task.reopenTask(taskReport, taskReportID);
} else {
Task.completeTask(taskReport);
Task.completeTask(taskReport, taskReportID);
}
})}
accessibilityLabel={translate('task.task')}
Expand Down
35 changes: 19 additions & 16 deletions src/components/ReportActionItem/TaskView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,7 @@ import OfflineWithFeedback from '@components/OfflineWithFeedback';
import {usePersonalDetails} from '@components/OnyxProvider';
import PressableWithSecondaryInteraction from '@components/PressableWithSecondaryInteraction';
import Text from '@components/Text';
import withCurrentUserPersonalDetails from '@components/withCurrentUserPersonalDetails';
import type {WithCurrentUserPersonalDetailsProps} from '@components/withCurrentUserPersonalDetails';
import useCurrentUserPersonalDetails from '@hooks/useCurrentUserPersonalDetails';
import useLocalize from '@hooks/useLocalize';
import useStyleUtils from '@hooks/useStyleUtils';
import useThemeStyles from '@hooks/useThemeStyles';
Expand All @@ -27,27 +26,28 @@ import CONST from '@src/CONST';
import ROUTES from '@src/ROUTES';
import type {Report} from '@src/types/onyx';

type TaskViewProps = WithCurrentUserPersonalDetailsProps & {
type TaskViewProps = {
/** The report currently being looked at */
report: Report;
};

function TaskView({report, ...props}: TaskViewProps) {
function TaskView({report}: TaskViewProps) {
const styles = useThemeStyles();
const StyleUtils = useStyleUtils();
const currentUserPersonalDetails = useCurrentUserPersonalDetails();
const personalDetails = usePersonalDetails();
useEffect(() => {
Task.setTaskReport(report);
}, [report]);
const personalDetails = usePersonalDetails();
const taskTitle = convertToLTR(report.reportName ?? '');
const assigneeTooltipDetails = ReportUtils.getDisplayNamesWithTooltips(
OptionsListUtils.getPersonalDetailsForAccountIDs(report.managerID ? [report.managerID] : [], personalDetails),
false,
);
const isCompleted = ReportUtils.isCompletedTaskReport(report);
const isOpen = ReportUtils.isOpenTaskReport(report);
const canModifyTask = Task.canModifyTask(report, props.currentUserPersonalDetails.accountID);
const canActionTask = Task.canActionTask(report, props.currentUserPersonalDetails.accountID);
const isCompleted = ReportUtils.isCompletedTaskReport(report);
const canModifyTask = Task.canModifyTask(report, currentUserPersonalDetails.accountID);
const canActionTask = Task.canActionTask(report, currentUserPersonalDetails.accountID);
const disableState = !canModifyTask;
const isDisableInteractive = !canModifyTask || !isOpen;
const {translate} = useLocalize();
Expand Down Expand Up @@ -77,10 +77,10 @@ function TaskView({report, ...props}: TaskViewProps) {
styles.ph5,
styles.pv2,
StyleUtils.getButtonBackgroundColorStyle(getButtonState(hovered, pressed, false, disableState, !isDisableInteractive), true),
isDisableInteractive && !disableState && styles.cursorDefault,
isDisableInteractive && styles.cursorDefault,
]}
disabled={disableState}
accessibilityLabel={taskTitle || translate('task.task')}
disabled={isDisableInteractive}
>
{({pressed}) => (
<OfflineWithFeedback pendingAction={report.pendingFields?.reportName}>
Expand All @@ -104,7 +104,7 @@ function TaskView({report, ...props}: TaskViewProps) {
containerBorderRadius={8}
caretSize={16}
accessibilityLabel={taskTitle || translate('task.task')}
disabled={!canModifyTask || !canActionTask}
disabled={!canActionTask}
/>
<View style={[styles.flexRow, styles.flex1]}>
<Text
Expand All @@ -114,7 +114,7 @@ function TaskView({report, ...props}: TaskViewProps) {
{taskTitle}
</Text>
</View>
{isOpen && (
{!isDisableInteractive && (
<View style={styles.taskRightIconContainer}>
<Icon
additionalStyles={[styles.alignItemsCenter]}
Expand All @@ -135,12 +135,13 @@ function TaskView({report, ...props}: TaskViewProps) {
description={translate('task.description')}
title={report.description ?? ''}
onPress={() => Navigation.navigate(ROUTES.REPORT_DESCRIPTION.getRoute(report.reportID, Navigation.getReportRHPActiveRoute()))}
shouldShowRightIcon={isOpen}
shouldShowRightIcon={!isDisableInteractive}
disabled={disableState}
wrapperStyle={[styles.pv2, styles.taskDescriptionMenuItem]}
shouldGreyOutWhenDisabled={false}
numberOfLinesTitle={0}
interactive={!isDisableInteractive}
shouldUseDefaultCursorWhenDisabled
/>
</OfflineWithFeedback>
<OfflineWithFeedback pendingAction={report.pendingFields?.managerID}>
Expand All @@ -153,23 +154,25 @@ function TaskView({report, ...props}: TaskViewProps) {
avatarSize={CONST.AVATAR_SIZE.SMALLER}
titleStyle={styles.assigneeTextStyle}
onPress={() => Navigation.navigate(ROUTES.TASK_ASSIGNEE.getRoute(report.reportID, Navigation.getReportRHPActiveRoute()))}
shouldShowRightIcon={isOpen}
shouldShowRightIcon={!isDisableInteractive}
disabled={disableState}
wrapperStyle={[styles.pv2]}
isSmallAvatarSubscriptMenu
shouldGreyOutWhenDisabled={false}
interactive={!isDisableInteractive}
titleWithTooltips={assigneeTooltipDetails}
shouldUseDefaultCursorWhenDisabled
/>
) : (
<MenuItemWithTopDescription
description={translate('task.assignee')}
onPress={() => Navigation.navigate(ROUTES.TASK_ASSIGNEE.getRoute(report.reportID, Navigation.getReportRHPActiveRoute()))}
shouldShowRightIcon={isOpen}
shouldShowRightIcon={!isDisableInteractive}
disabled={disableState}
wrapperStyle={[styles.pv2]}
shouldGreyOutWhenDisabled={false}
interactive={!isDisableInteractive}
shouldUseDefaultCursorWhenDisabled
/>
)}
</OfflineWithFeedback>
Expand All @@ -180,4 +183,4 @@ function TaskView({report, ...props}: TaskViewProps) {

TaskView.displayName = 'TaskView';

export default withCurrentUserPersonalDetails(TaskView);
export default TaskView;
23 changes: 7 additions & 16 deletions src/components/TaskHeaderActionButton.tsx
Original file line number Diff line number Diff line change
@@ -1,30 +1,25 @@
import React from 'react';
import {View} from 'react-native';
import type {OnyxEntry} from 'react-native-onyx';
import {withOnyx} from 'react-native-onyx';
import useLocalize from '@hooks/useLocalize';
import useThemeStyles from '@hooks/useThemeStyles';
import * as ReportUtils from '@libs/ReportUtils';
import * as TaskUtils from '@libs/TaskUtils';
import * as Session from '@userActions/Session';
import * as Task from '@userActions/Task';
import ONYXKEYS from '@src/ONYXKEYS';
import CONST from '@src/CONST';
import type * as OnyxTypes from '@src/types/onyx';
import Button from './Button';
import {useSession} from './OnyxProvider';

type TaskHeaderActionButtonOnyxProps = {
/** Current user session */
session: OnyxEntry<OnyxTypes.Session>;
};

type TaskHeaderActionButtonProps = TaskHeaderActionButtonOnyxProps & {
type TaskHeaderActionButtonProps = {
/** The report currently being looked at */
report: OnyxTypes.Report;
};

function TaskHeaderActionButton({report, session}: TaskHeaderActionButtonProps) {
function TaskHeaderActionButton({report}: TaskHeaderActionButtonProps) {
const {translate} = useLocalize();
const styles = useThemeStyles();
const session = useSession();

if (!ReportUtils.canWriteInReport(report)) {
return null;
Expand All @@ -34,7 +29,7 @@ function TaskHeaderActionButton({report, session}: TaskHeaderActionButtonProps)
<View style={[styles.flexRow, styles.alignItemsCenter, styles.justifyContentEnd]}>
<Button
success
isDisabled={!Task.canModifyTask(report, session?.accountID ?? -1) || !Task.canActionTask(report, session?.accountID ?? -1)}
isDisabled={!Task.canActionTask(report, session?.accountID ?? CONST.DEFAULT_NUMBER_ID)}
text={translate(ReportUtils.isCompletedTaskReport(report) ? 'task.markAsIncomplete' : 'task.markAsComplete')}
onPress={Session.checkIfActionIsAllowed(() => {
// If we're already navigating to these task editing pages, early return not to mark as completed, otherwise we would have not found page.
Expand All @@ -55,8 +50,4 @@ function TaskHeaderActionButton({report, session}: TaskHeaderActionButtonProps)

TaskHeaderActionButton.displayName = 'TaskHeaderActionButton';

export default withOnyx<TaskHeaderActionButtonProps, TaskHeaderActionButtonOnyxProps>({
session: {
key: ONYXKEYS.SESSION,
},
})(TaskHeaderActionButton);
export default TaskHeaderActionButton;
3 changes: 2 additions & 1 deletion src/languages/en.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3581,7 +3581,8 @@ const translations = {
cardholder: 'Cardholder',
cardName: 'Card name',
integrationExport: ({integration, type}: IntegrationExportParams) => (integration && type ? `${integration} ${type.toLowerCase()} export` : `${integration} export`),
integrationExportTitleFirstPart: ({integration}: IntegrationExportParams) => `Choose the ${integration} account where transactions should be exported. Select a different`,
integrationExportTitleFirstPart: ({integration}: IntegrationExportParams) => `Choose the ${integration} account where transactions should be exported.`,
integrationExportTitlePart: 'Select a different',
integrationExportTitleLinkPart: 'export option',
integrationExportTitleSecondPart: 'to change the available accounts.',
lastUpdated: 'Last updated',
Expand Down
4 changes: 2 additions & 2 deletions src/languages/es.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3624,9 +3624,9 @@ const translations = {
cardName: 'Nombre de la tarjeta',
integrationExport: ({integration, type}: IntegrationExportParams) =>
integration && type ? `Exportación a ${integration} ${type.toLowerCase()}` : `Exportación a ${integration}`,
integrationExportTitleFirstPart: ({integration}: IntegrationExportParams) =>
`Seleccione la cuenta ${integration} donde se deben exportar las transacciones. Seleccione una cuenta diferente`,
integrationExportTitleFirstPart: ({integration}: IntegrationExportParams) => `Seleccione la cuenta ${integration} donde se deben exportar las transacciones.`,
integrationExportTitleLinkPart: 'opción de exportación',
integrationExportTitlePart: 'Seleccione una cuenta diferente',
integrationExportTitleSecondPart: 'para cambiar las cuentas disponibles.',
lastUpdated: 'Última actualización',
transactionStartDate: 'Fecha de inicio de transacciones',
Expand Down
20 changes: 17 additions & 3 deletions src/libs/PersonalDetailsUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,8 @@ const regexMergedAccount = new RegExp(CONST.REGEX.MERGED_ACCOUNT_PREFIX);
function getDisplayNameOrDefault(passedPersonalDetails?: Partial<PersonalDetails> | null, defaultValue = '', shouldFallbackToHidden = true, shouldAddCurrentUserPostfix = false): string {
let displayName = passedPersonalDetails?.displayName ?? '';

let login = passedPersonalDetails?.login ?? '';

// If the displayName starts with the merged account prefix, remove it.
if (regexMergedAccount.test(displayName)) {
// Remove the merged account prefix from the displayName.
Expand All @@ -60,8 +62,11 @@ function getDisplayNameOrDefault(passedPersonalDetails?: Partial<PersonalDetails

// If the displayName is not set by the user, the backend sets the diplayName same as the login so
// we need to remove the sms domain from the displayName if it is an sms login.
if (displayName === passedPersonalDetails?.login && Str.isSMSLogin(passedPersonalDetails?.login)) {
displayName = Str.removeSMSDomain(displayName);
if (Str.isSMSLogin(login)) {
if (displayName === login) {
displayName = Str.removeSMSDomain(displayName);
}
login = Str.removeSMSDomain(login);
}

if (shouldAddCurrentUserPostfix && !!displayName) {
Expand All @@ -75,7 +80,16 @@ function getDisplayNameOrDefault(passedPersonalDetails?: Partial<PersonalDetails
if (displayName) {
return displayName;
}
return defaultValue || (shouldFallbackToHidden ? hiddenTranslation : '');

if (defaultValue) {
return defaultValue;
}

if (login) {
return login;
}

return shouldFallbackToHidden ? hiddenTranslation : '';
}

/**
Expand Down
Loading

0 comments on commit 3facff0

Please sign in to comment.