From 8ea6ebcc0090a2db304011297e43af3edc7ecc59 Mon Sep 17 00:00:00 2001 From: VickyStash Date: Fri, 9 Feb 2024 13:27:09 +0100 Subject: [PATCH 001/170] [TS migration] Migrate 'format.js' test --- .../compare/output/{format.js => format.ts} | 32 ++++++++++++++----- 1 file changed, 24 insertions(+), 8 deletions(-) rename tests/e2e/compare/output/{format.js => format.ts} (71%) diff --git a/tests/e2e/compare/output/format.js b/tests/e2e/compare/output/format.ts similarity index 71% rename from tests/e2e/compare/output/format.js rename to tests/e2e/compare/output/format.ts index c31ac547b41d..e0f503f12187 100644 --- a/tests/e2e/compare/output/format.js +++ b/tests/e2e/compare/output/format.ts @@ -3,12 +3,28 @@ * from: https://github.com/callstack/reassure/blob/main/packages/reassure-compare/src/utils/format.ts */ -const formatPercent = (value) => { +type Stats = { + mean: number; + stdev: number; + runs: number; + entries: Record; +}; + +type CompareEntry = { + name: string; + baseline: Stats; + current: Stats; + diff: number; + relativeDurationDiff: number; + isDurationDiffOfSignificance: boolean; +}; + +const formatPercent = (value: number): string => { const valueAsPercent = value * 100; return `${valueAsPercent.toFixed(1)}%`; }; -const formatPercentChange = (value) => { +const formatPercentChange = (value: number): string => { const absValue = Math.abs(value); // Round to zero @@ -19,9 +35,9 @@ const formatPercentChange = (value) => { return `${value >= 0 ? '+' : '-'}${formatPercent(absValue)}`; }; -const formatDuration = (duration) => `${duration.toFixed(3)} ms`; +const formatDuration = (duration: number): string => `${duration.toFixed(3)} ms`; -const formatDurationChange = (value) => { +const formatDurationChange = (value: number): string => { if (value > 0) { return `+${formatDuration(value)}`; } @@ -31,7 +47,7 @@ const formatDurationChange = (value) => { return '0 ms'; }; -const formatChange = (value) => { +const formatChange = (value: number): string => { if (value > 0) { return `+${value}`; } @@ -41,7 +57,7 @@ const formatChange = (value) => { return '0'; }; -const getDurationSymbols = (entry) => { +const getDurationSymbols = (entry: CompareEntry): string => { if (!entry.isDurationDiffOfSignificance) { if (entry.relativeDurationDiff > 0.15) { return '🟡'; @@ -68,7 +84,7 @@ const getDurationSymbols = (entry) => { return ''; }; -const formatDurationDiffChange = (entry) => { +const formatDurationDiffChange = (entry: CompareEntry): string => { const {baseline, current} = entry; let output = `${formatDuration(baseline.mean)} → ${formatDuration(current.mean)}`; @@ -82,7 +98,7 @@ const formatDurationDiffChange = (entry) => { return output; }; -module.exports = { +export default { formatPercent, formatPercentChange, formatDuration, From 500f458c11ba647ff133a65fa9412420229d7ced Mon Sep 17 00:00:00 2001 From: Ishpaul Singh Date: Thu, 15 Feb 2024 17:23:24 +0530 Subject: [PATCH 002/170] added v1 changes --- src/CONST.ts | 1 + .../DisplayNames/DisplayNamesWithTooltip.tsx | 2 ++ src/components/ReportWelcomeText.tsx | 27 ++++++++++++++++--- src/languages/en.ts | 3 +++ src/languages/es.ts | 4 +++ src/libs/OptionsListUtils.ts | 9 +++++++ src/libs/ReportUtils.ts | 13 ++++++--- src/pages/ProfilePage.js | 5 ++-- src/pages/home/HeaderView.js | 4 +++ ...yForRefactorRequestParticipantsSelector.js | 4 +++ 10 files changed, 63 insertions(+), 9 deletions(-) diff --git a/src/CONST.ts b/src/CONST.ts index 5c99c5877559..026d0b3ce35e 100755 --- a/src/CONST.ts +++ b/src/CONST.ts @@ -683,6 +683,7 @@ const CONST = { DOMAIN_ALL: 'domainAll', POLICY_ROOM: 'policyRoom', POLICY_EXPENSE_CHAT: 'policyExpenseChat', + SELF_DM: 'selfDM', }, WORKSPACE_CHAT_ROOMS: { ANNOUNCE: '#announce', diff --git a/src/components/DisplayNames/DisplayNamesWithTooltip.tsx b/src/components/DisplayNames/DisplayNamesWithTooltip.tsx index 91b8b0fc4483..9af9b362197f 100644 --- a/src/components/DisplayNames/DisplayNamesWithTooltip.tsx +++ b/src/components/DisplayNames/DisplayNamesWithTooltip.tsx @@ -47,6 +47,8 @@ function DisplayNamesWithToolTip({shouldUseFullTitle, fullTitle, displayNamesWit return textNodeRight > containerRight ? -(tooltipX - newToolX) : 0; }, []); + console.log('DisplayNamesWithToolTip', {shouldUseFullTitle, fullTitle, displayNamesWithTooltips, textStyles, numberOfLines, renderAdditionalText}); + return ( // Tokenization of string only support prop numberOfLines on Web 1; const displayNamesWithTooltips = ReportUtils.getDisplayNamesWithTooltips(OptionsListUtils.getPersonalDetailsForAccountIDs(participantAccountIDs, personalDetails), isMultipleParticipant); @@ -44,6 +45,7 @@ function ReportWelcomeText({report, policy, personalDetails}: ReportWelcomeTextP const moneyRequestOptions = ReportUtils.getMoneyRequestOptions(report, policy, participantAccountIDs); const additionalText = moneyRequestOptions.map((item) => translate(`reportActionsView.iouTypes.${item}`)).join(', '); const canEditPolicyDescription = ReportUtils.canEditPolicyDescription(policy); + const reportName = ReportUtils.getReportName(report); const navigateToReport = () => { if (!report?.reportID) { @@ -53,11 +55,23 @@ function ReportWelcomeText({report, policy, personalDetails}: ReportWelcomeTextP Navigation.navigate(ROUTES.REPORT_WITH_ID_DETAILS.getRoute(report.reportID)); }; + const getWelcomeHeroText = useMemo(() => { + if(isChatRoom) { + return translate('reportActionsView.welcomeToRoom', {roomName: reportName}); + } + + if (isSelfDM) { + return translate('reportActionsView.yourSpace'); + } + + return translate('reportActionsView.sayHello'); + }, [isChatRoom, isSelfDM, translate, reportName]); + return ( <> - {isChatRoom ? translate('reportActionsView.welcomeToRoom', {roomName: ReportUtils.getReportName(report)}) : translate('reportActionsView.sayHello')} + {getWelcomeHeroText} @@ -120,6 +134,13 @@ function ReportWelcomeText({report, policy, personalDetails}: ReportWelcomeTextP )} )} + { + isSelfDM && ( + + {translate('reportActionsView.beginningOfChatHistorySelfDM')} + + ) + } {isDefault && ( {translate('reportActionsView.beginningOfChatHistory')} diff --git a/src/languages/en.ts b/src/languages/en.ts index 0baaee4c07a8..cd0dfb6921a0 100755 --- a/src/languages/en.ts +++ b/src/languages/en.ts @@ -487,8 +487,11 @@ export default { beginningOfChatHistoryPolicyExpenseChatPartOne: 'Collaboration between ', beginningOfChatHistoryPolicyExpenseChatPartTwo: ' and ', beginningOfChatHistoryPolicyExpenseChatPartThree: ' starts here! 🎉 This is the place to chat, request money and settle up.', + // todo: confirm this copy + beginningOfChatHistorySelfDM: 'This is your personal space. Use it to chat with yourself, take notes, or save links.', chatWithAccountManager: 'Chat with your account manager here', sayHello: 'Say hello!', + yourSpace: 'Your space', welcomeToRoom: ({roomName}: WelcomeToRoomParams) => `Welcome to ${roomName}!`, usePlusButton: ({additionalText}: UsePlusButtonParams) => `\nYou can also use the + button to ${additionalText}, or assign a task!`, iouTypes: { diff --git a/src/languages/es.ts b/src/languages/es.ts index ae566f3033f0..53e95032f508 100644 --- a/src/languages/es.ts +++ b/src/languages/es.ts @@ -480,8 +480,12 @@ export default { beginningOfChatHistoryPolicyExpenseChatPartOne: '¡La colaboración entre ', beginningOfChatHistoryPolicyExpenseChatPartTwo: ' y ', beginningOfChatHistoryPolicyExpenseChatPartThree: ' empieza aquí! 🎉 Este es el lugar donde chatear, pedir dinero y pagar.', + // todo: confirm this copy and ask for the correct translation + beginningOfChatHistorySelfDM: 'This is your personal space. Use it to chat with yourself, take notes, or save links.', chatWithAccountManager: 'Chatea con tu gestor de cuenta aquí', sayHello: '¡Saluda!', + // todo: ask for the correct translation + yourSpace: 'Your space', welcomeToRoom: ({roomName}: WelcomeToRoomParams) => `¡Bienvenido a ${roomName}!`, usePlusButton: ({additionalText}: UsePlusButtonParams) => `\n¡También puedes usar el botón + de abajo para ${additionalText}, o asignar una tarea!`, iouTypes: { diff --git a/src/libs/OptionsListUtils.ts b/src/libs/OptionsListUtils.ts index e2af10649bad..8ec84217db28 100644 --- a/src/libs/OptionsListUtils.ts +++ b/src/libs/OptionsListUtils.ts @@ -91,6 +91,7 @@ type GetOptionsConfig = { includeMultipleParticipantReports?: boolean; includePersonalDetails?: boolean; includeRecentReports?: boolean; + includeSelfDM?: boolean; sortByReportTypeInSearch?: boolean; searchInputValue?: string; showChatPreviewLine?: boolean; @@ -1350,6 +1351,7 @@ function getOptions( transactionViolations = {}, includePolicyTaxRates, policyTaxRates, + includeSelfDM = true, }: GetOptionsConfig, ): GetOptions { if (includeCategories) { @@ -1454,6 +1456,7 @@ function getOptions( const isTaskReport = ReportUtils.isTaskReport(report); const isPolicyExpenseChat = ReportUtils.isPolicyExpenseChat(report); const isMoneyRequestReport = ReportUtils.isMoneyRequestReport(report); + const isSelfDM = ReportUtils.isSelfDM(report); const accountIDs = report.visibleChatMemberAccountIDs ?? []; if (isPolicyExpenseChat && report.isOwnPolicyExpenseChat && !includeOwnedWorkspaceChats) { @@ -1465,6 +1468,10 @@ function getOptions( return; } + if (isSelfDM && !includeSelfDM) { + return; + } + if (isThread && !includeThreads) { return; } @@ -1786,6 +1793,7 @@ function getFilteredOptions( includeSelectedOptions = false, includePolicyTaxRates = false, policyTaxRates: PolicyTaxRateWithDefault = {} as PolicyTaxRateWithDefault, + includeSelfDM = true, ) { return getOptions(reports, personalDetails, { betas, @@ -1807,6 +1815,7 @@ function getFilteredOptions( includeSelectedOptions, includePolicyTaxRates, policyTaxRates, + includeSelfDM, }); } diff --git a/src/libs/ReportUtils.ts b/src/libs/ReportUtils.ts index ebde1b1bf8ab..c4017229322c 100644 --- a/src/libs/ReportUtils.ts +++ b/src/libs/ReportUtils.ts @@ -901,6 +901,10 @@ function isDM(report: OnyxEntry): boolean { return isChatReport(report) && !getChatType(report); } +function isSelfDM(report: OnyxEntry): boolean { + return getChatType(report) === CONST.REPORT.CHAT_TYPE.SELF_DM; +} + /** * Only returns true if this is our main 1:1 DM report with Concierge */ @@ -2630,7 +2634,7 @@ function getParentNavigationSubtitle(report: OnyxEntry): ParentNavigatio function navigateToDetailsPage(report: OnyxEntry) { const participantAccountIDs = report?.participantAccountIDs ?? []; - if (isOneOnOneChat(report)) { + if (isOneOnOneChat(report) || isSelfDM(report)) { Navigation.navigate(ROUTES.PROFILE.getRoute(participantAccountIDs[0])); return; } @@ -4133,7 +4137,7 @@ function hasIOUWaitingOnCurrentUserBankAccount(chatReport: OnyxEntry): b */ function canRequestMoney(report: OnyxEntry, policy: OnyxEntry, otherParticipants: number[]): boolean { // User cannot request money in chat thread or in task report or in chat room - if (isChatThread(report) || isTaskReport(report) || isChatRoom(report)) { + if (isChatThread(report) || isTaskReport(report) || isChatRoom(report) || isSelfDM(report)) { return false; } @@ -4213,7 +4217,7 @@ function getMoneyRequestOptions(report: OnyxEntry, policy: OnyxEntry 0) || (isDM(report) && hasMultipleOtherParticipants) || (isPolicyExpenseChat(report) && report?.isOwnPolicyExpenseChat)) { + if ((isChatRoom(report) && otherParticipants.length > 0) || (isDM(report) && hasMultipleOtherParticipants) || (isPolicyExpenseChat(report) && report?.isOwnPolicyExpenseChat) && !isSelfDM(report)) { options = [CONST.IOU.TYPE.SPLIT]; } @@ -4222,7 +4226,7 @@ function getMoneyRequestOptions(report: OnyxEntry, policy: OnyxEntry )} - {!isCurrentUser && !Session.isAnonymousUser() && ( + {!isCurrentUser && !Session.isAnonymousUser() && !isSelfDM && ( 1; const displayNamesWithTooltips = ReportUtils.getDisplayNamesWithTooltips(participantPersonalDetails, isMultipleParticipant); + + if(ReportUtils.isSelfDM(props.report)){ + displayNamesWithTooltips[0].displayName += ` (${translate('common.you')})` + } const isChatThread = ReportUtils.isChatThread(props.report); const isChatRoom = ReportUtils.isChatRoom(props.report); const isPolicyExpenseChat = ReportUtils.isPolicyExpenseChat(props.report); diff --git a/src/pages/iou/request/MoneyTemporaryForRefactorRequestParticipantsSelector.js b/src/pages/iou/request/MoneyTemporaryForRefactorRequestParticipantsSelector.js index d6c088c23e95..74efce705e1a 100644 --- a/src/pages/iou/request/MoneyTemporaryForRefactorRequestParticipantsSelector.js +++ b/src/pages/iou/request/MoneyTemporaryForRefactorRequestParticipantsSelector.js @@ -132,6 +132,9 @@ function MoneyTemporaryForRefactorRequestParticipantsSelector({ // This functionality is being built here: https://github.com/Expensify/App/issues/23291 iouRequestType !== CONST.IOU.REQUEST_TYPE.DISTANCE, false, + undefined, + undefined, + false, ); const formatResults = OptionsListUtils.formatSectionsFromSearchTerm( @@ -144,6 +147,7 @@ function MoneyTemporaryForRefactorRequestParticipantsSelector({ personalDetails, true, ); + newSections.push(formatResults.section); indexOffset = formatResults.newIndexOffset; From 03edfe10c37a4e8c3d51be4f48d9d46629a0f4b3 Mon Sep 17 00:00:00 2001 From: rayane-djouah <77965000+rayane-djouah@users.noreply.github.com> Date: Sat, 17 Feb 2024 19:41:59 +0100 Subject: [PATCH 003/170] Migrate Components Group 1 to TypeScript --- ...ification.js => FocusModeNotification.tsx} | 1 - ...gIndicator.js => SAMLLoadingIndicator.tsx} | 10 ++++++-- .../{TaxPicker/index.js => TaxPicker.tsx} | 25 +++++++++++++------ .../TaxPicker/taxPickerPropTypes.js | 21 ---------------- src/libs/OptionsListUtils.ts | 2 +- 5 files changed, 27 insertions(+), 32 deletions(-) rename src/components/{FocusModeNotification.js => FocusModeNotification.tsx} (97%) rename src/components/{SAMLLoadingIndicator.js => SAMLLoadingIndicator.tsx} (79%) rename src/components/{TaxPicker/index.js => TaxPicker.tsx} (77%) delete mode 100644 src/components/TaxPicker/taxPickerPropTypes.js diff --git a/src/components/FocusModeNotification.js b/src/components/FocusModeNotification.tsx similarity index 97% rename from src/components/FocusModeNotification.js rename to src/components/FocusModeNotification.tsx index e846c1f188e2..c4fcbae33224 100644 --- a/src/components/FocusModeNotification.js +++ b/src/components/FocusModeNotification.tsx @@ -27,7 +27,6 @@ function FocusModeNotification() { {translate('focusModeUpdateModal.prompt')} { User.clearFocusModeNotification(); diff --git a/src/components/SAMLLoadingIndicator.js b/src/components/SAMLLoadingIndicator.tsx similarity index 79% rename from src/components/SAMLLoadingIndicator.js rename to src/components/SAMLLoadingIndicator.tsx index 84f9098e564f..2be7b76e6cae 100644 --- a/src/components/SAMLLoadingIndicator.js +++ b/src/components/SAMLLoadingIndicator.tsx @@ -3,6 +3,7 @@ import {StyleSheet, View} from 'react-native'; import useLocalize from '@hooks/useLocalize'; import useTheme from '@hooks/useTheme'; import useThemeStyles from '@hooks/useThemeStyles'; +import variables from '@styles/variables'; import Icon from './Icon'; import * as Expensicons from './Icon/Expensicons'; import * as Illustrations from './Icon/Illustrations'; @@ -23,8 +24,13 @@ function SAMLLoadingIndicator() { /> {translate('samlSignIn.launching')} - - {translate('samlSignIn.oneMoment')} + + + {translate('samlSignIn.oneMoment')} + diff --git a/src/components/TaxPicker/index.js b/src/components/TaxPicker.tsx similarity index 77% rename from src/components/TaxPicker/index.js rename to src/components/TaxPicker.tsx index f25a1b84bf64..86d9581d0798 100644 --- a/src/components/TaxPicker/index.js +++ b/src/components/TaxPicker.tsx @@ -1,5 +1,5 @@ -import lodashGet from 'lodash/get'; import React, {useMemo, useState} from 'react'; +import type {EdgeInsets} from 'react-native-safe-area-context'; import _ from 'underscore'; import OptionsSelector from '@components/OptionsSelector'; import useLocalize from '@hooks/useLocalize'; @@ -8,9 +8,22 @@ import useThemeStyles from '@hooks/useThemeStyles'; import * as OptionsListUtils from '@libs/OptionsListUtils'; import * as TransactionUtils from '@libs/TransactionUtils'; import CONST from '@src/CONST'; -import {defaultProps, propTypes} from './taxPickerPropTypes'; -function TaxPicker({selectedTaxRate, policyTaxRates, insets, onSubmit}) { +type TaxPickerProps = { + /** Collection of tax rates attached to a policy */ + policyTaxRates?: OptionsListUtils.PolicyTaxRateWithDefault; + + /** The selected tax rate of an expense */ + selectedTaxRate?: string; + + /** Safe area insets */ + insets?: EdgeInsets; + + /** Callback to fire when a tax is pressed */ + onSubmit: () => void; +}; + +function TaxPicker({selectedTaxRate = '', policyTaxRates = {} as OptionsListUtils.PolicyTaxRateWithDefault, insets, onSubmit}: TaxPickerProps) { const styles = useThemeStyles(); const StyleUtils = useStyleUtils(); const {translate} = useLocalize(); @@ -58,11 +71,11 @@ function TaxPicker({selectedTaxRate, policyTaxRates, insets, onSubmit}) { ); return policyTaxRatesOptions; }, [policyTaxRates, searchValue, selectedOptions]); - - const selectedOptionKey = lodashGet(_.filter(lodashGet(sections, '[0].data', []), (taxRate) => taxRate.searchText === selectedTaxRate)[0], 'keyForList'); + const selectedOptionKey = sections?.[0]?.data?.filter((taxRate) => taxRate.searchText === selectedTaxRate)[0]?.keyForList; return ( Date: Sat, 17 Feb 2024 20:08:05 +0100 Subject: [PATCH 004/170] Migrate ShowMoreButton component to TypeScript --- .../index.js => ShowMoreButton.tsx} | 27 ++++++------------- 1 file changed, 8 insertions(+), 19 deletions(-) rename src/components/{ShowMoreButton/index.js => ShowMoreButton.tsx} (75%) diff --git a/src/components/ShowMoreButton/index.js b/src/components/ShowMoreButton.tsx similarity index 75% rename from src/components/ShowMoreButton/index.js rename to src/components/ShowMoreButton.tsx index 28c33d185cff..178b122830d4 100644 --- a/src/components/ShowMoreButton/index.js +++ b/src/components/ShowMoreButton.tsx @@ -1,7 +1,5 @@ -import PropTypes from 'prop-types'; import React from 'react'; -import {View} from 'react-native'; -import _ from 'underscore'; +import {View, ViewStyle} from 'react-native'; import Button from '@components/Button'; import * as Expensicons from '@components/Icon/Expensicons'; import Text from '@components/Text'; @@ -9,34 +7,27 @@ import useLocalize from '@hooks/useLocalize'; import useTheme from '@hooks/useTheme'; import useThemeStyles from '@hooks/useThemeStyles'; import * as NumberFormatUtils from '@libs/NumberFormatUtils'; -import stylePropTypes from '@styles/stylePropTypes'; -const propTypes = { +type ShowMoreButtonProps = { /** Additional styles for container */ - containerStyle: stylePropTypes, + containerStyle?: ViewStyle; /** The number of currently shown items */ - currentCount: PropTypes.number, + currentCount?: number; /** The total number of items that could be shown */ - totalCount: PropTypes.number, + totalCount?: number; /** A handler that fires when button has been pressed */ - onPress: PropTypes.func.isRequired, + onPress: () => void; }; -const defaultProps = { - containerStyle: {}, - currentCount: undefined, - totalCount: undefined, -}; - -function ShowMoreButton({containerStyle, currentCount, totalCount, onPress}) { +function ShowMoreButton({containerStyle = {}, currentCount, totalCount, onPress}: ShowMoreButtonProps) { const {translate, preferredLocale} = useLocalize(); const theme = useTheme(); const styles = useThemeStyles(); - const shouldShowCounter = _.isNumber(currentCount) && _.isNumber(totalCount); + const shouldShowCounter = typeof currentCount === 'number' && typeof totalCount === 'number'; return ( @@ -67,7 +58,5 @@ function ShowMoreButton({containerStyle, currentCount, totalCount, onPress}) { } ShowMoreButton.displayName = 'ShowMoreButton'; -ShowMoreButton.propTypes = propTypes; -ShowMoreButton.defaultProps = defaultProps; export default ShowMoreButton; From 2918adc8609dfb6291a9cc194fb392a3fca2c8fa Mon Sep 17 00:00:00 2001 From: rayane-djouah <77965000+rayane-djouah@users.noreply.github.com> Date: Sat, 17 Feb 2024 20:18:30 +0100 Subject: [PATCH 005/170] fix lint errors --- src/components/ShowMoreButton.tsx | 9 +++++---- src/components/TaxPicker.tsx | 3 +-- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/components/ShowMoreButton.tsx b/src/components/ShowMoreButton.tsx index 178b122830d4..c0b99a76e5bf 100644 --- a/src/components/ShowMoreButton.tsx +++ b/src/components/ShowMoreButton.tsx @@ -1,12 +1,13 @@ import React from 'react'; -import {View, ViewStyle} from 'react-native'; -import Button from '@components/Button'; -import * as Expensicons from '@components/Icon/Expensicons'; -import Text from '@components/Text'; +import {View} from 'react-native'; +import type {ViewStyle} from 'react-native'; import useLocalize from '@hooks/useLocalize'; import useTheme from '@hooks/useTheme'; import useThemeStyles from '@hooks/useThemeStyles'; import * as NumberFormatUtils from '@libs/NumberFormatUtils'; +import Button from './Button'; +import * as Expensicons from './Icon/Expensicons'; +import Text from './Text'; type ShowMoreButtonProps = { /** Additional styles for container */ diff --git a/src/components/TaxPicker.tsx b/src/components/TaxPicker.tsx index 86d9581d0798..1b192212b203 100644 --- a/src/components/TaxPicker.tsx +++ b/src/components/TaxPicker.tsx @@ -1,13 +1,12 @@ import React, {useMemo, useState} from 'react'; import type {EdgeInsets} from 'react-native-safe-area-context'; -import _ from 'underscore'; -import OptionsSelector from '@components/OptionsSelector'; import useLocalize from '@hooks/useLocalize'; import useStyleUtils from '@hooks/useStyleUtils'; import useThemeStyles from '@hooks/useThemeStyles'; import * as OptionsListUtils from '@libs/OptionsListUtils'; import * as TransactionUtils from '@libs/TransactionUtils'; import CONST from '@src/CONST'; +import OptionsSelector from './OptionsSelector'; type TaxPickerProps = { /** Collection of tax rates attached to a policy */ From 5ab68a59526b4dd3dba31e0f3d0a0b3300307477 Mon Sep 17 00:00:00 2001 From: VickyStash Date: Tue, 20 Feb 2024 08:45:15 +0100 Subject: [PATCH 006/170] Update export --- tests/e2e/compare/output/format.ts | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/tests/e2e/compare/output/format.ts b/tests/e2e/compare/output/format.ts index e0f503f12187..cbed4a8a6365 100644 --- a/tests/e2e/compare/output/format.ts +++ b/tests/e2e/compare/output/format.ts @@ -98,12 +98,4 @@ const formatDurationDiffChange = (entry: CompareEntry): string => { return output; }; -export default { - formatPercent, - formatPercentChange, - formatDuration, - formatDurationChange, - formatChange, - getDurationSymbols, - formatDurationDiffChange, -}; +export {formatPercent, formatPercentChange, formatDuration, formatDurationChange, formatChange, getDurationSymbols, formatDurationDiffChange}; From bb1e907937ac7298fd2830f10a7410a2d3251e3e Mon Sep 17 00:00:00 2001 From: rayane-djouah <77965000+rayane-djouah@users.noreply.github.com> Date: Tue, 20 Feb 2024 14:24:04 +0100 Subject: [PATCH 007/170] address review comments --- src/components/ShowMoreButton.tsx | 8 ++++---- src/components/TaxPicker.tsx | 7 ++++--- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/src/components/ShowMoreButton.tsx b/src/components/ShowMoreButton.tsx index c0b99a76e5bf..3411066a5376 100644 --- a/src/components/ShowMoreButton.tsx +++ b/src/components/ShowMoreButton.tsx @@ -1,6 +1,6 @@ import React from 'react'; import {View} from 'react-native'; -import type {ViewStyle} from 'react-native'; +import type {StyleProp, ViewStyle} from 'react-native'; import useLocalize from '@hooks/useLocalize'; import useTheme from '@hooks/useTheme'; import useThemeStyles from '@hooks/useThemeStyles'; @@ -11,7 +11,7 @@ import Text from './Text'; type ShowMoreButtonProps = { /** Additional styles for container */ - containerStyle?: ViewStyle; + containerStyle?: StyleProp; /** The number of currently shown items */ currentCount?: number; @@ -23,12 +23,12 @@ type ShowMoreButtonProps = { onPress: () => void; }; -function ShowMoreButton({containerStyle = {}, currentCount, totalCount, onPress}: ShowMoreButtonProps) { +function ShowMoreButton({containerStyle, currentCount, totalCount, onPress}: ShowMoreButtonProps) { const {translate, preferredLocale} = useLocalize(); const theme = useTheme(); const styles = useThemeStyles(); - const shouldShowCounter = typeof currentCount === 'number' && typeof totalCount === 'number'; + const shouldShowCounter = !!(currentCount && totalCount); return ( diff --git a/src/components/TaxPicker.tsx b/src/components/TaxPicker.tsx index 1b192212b203..be3e3ff6dc9d 100644 --- a/src/components/TaxPicker.tsx +++ b/src/components/TaxPicker.tsx @@ -4,13 +4,14 @@ import useLocalize from '@hooks/useLocalize'; import useStyleUtils from '@hooks/useStyleUtils'; import useThemeStyles from '@hooks/useThemeStyles'; import * as OptionsListUtils from '@libs/OptionsListUtils'; +import type {PolicyTaxRateWithDefault} from '@libs/OptionsListUtils'; import * as TransactionUtils from '@libs/TransactionUtils'; import CONST from '@src/CONST'; import OptionsSelector from './OptionsSelector'; type TaxPickerProps = { /** Collection of tax rates attached to a policy */ - policyTaxRates?: OptionsListUtils.PolicyTaxRateWithDefault; + policyTaxRates: PolicyTaxRateWithDefault; /** The selected tax rate of an expense */ selectedTaxRate?: string; @@ -70,11 +71,11 @@ function TaxPicker({selectedTaxRate = '', policyTaxRates = {} as OptionsListUtil ); return policyTaxRatesOptions; }, [policyTaxRates, searchValue, selectedOptions]); - const selectedOptionKey = sections?.[0]?.data?.filter((taxRate) => taxRate.searchText === selectedTaxRate)[0]?.keyForList; + const selectedOptionKey = sections?.[0]?.data?.find((taxRate) => taxRate.searchText === selectedTaxRate)?.keyForList; return ( Date: Tue, 20 Feb 2024 23:53:52 +0100 Subject: [PATCH 008/170] Update src/components/TaxPicker.tsx Co-authored-by: Abdelhafidh Belalia <16493223+s77rt@users.noreply.github.com> --- src/components/TaxPicker.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/TaxPicker.tsx b/src/components/TaxPicker.tsx index be3e3ff6dc9d..faa3508a3cb4 100644 --- a/src/components/TaxPicker.tsx +++ b/src/components/TaxPicker.tsx @@ -23,7 +23,7 @@ type TaxPickerProps = { onSubmit: () => void; }; -function TaxPicker({selectedTaxRate = '', policyTaxRates = {} as OptionsListUtils.PolicyTaxRateWithDefault, insets, onSubmit}: TaxPickerProps) { +function TaxPicker({selectedTaxRate = '', policyTaxRates, insets, onSubmit}: TaxPickerProps) { const styles = useThemeStyles(); const StyleUtils = useStyleUtils(); const {translate} = useLocalize(); From c39a76e29a133f9bf2ebf3ff93cac6130c64c58d Mon Sep 17 00:00:00 2001 From: jeremy-croff Date: Tue, 20 Feb 2024 19:54:41 -0600 Subject: [PATCH 009/170] feat(35600): upgrade electron major versions --- package-lock.json | 19 +++++-------------- package.json | 2 +- 2 files changed, 6 insertions(+), 15 deletions(-) diff --git a/package-lock.json b/package-lock.json index 93951ba0f241..d925e0733610 100644 --- a/package-lock.json +++ b/package-lock.json @@ -202,7 +202,7 @@ "css-loader": "^6.7.2", "diff-so-fancy": "^1.3.0", "dotenv": "^16.0.3", - "electron": "^26.6.8", + "electron": "^29.0.0", "electron-builder": "24.6.4", "eslint": "^7.6.0", "eslint-config-airbnb-typescript": "^17.1.0", @@ -28598,14 +28598,14 @@ } }, "node_modules/electron": { - "version": "26.6.8", - "resolved": "https://registry.npmjs.org/electron/-/electron-26.6.8.tgz", - "integrity": "sha512-nuzJ5nVButL1jErc97IVb+A6jbContMg5Uuz5fhmZ4NLcygLkSW8FZpnOT7A4k8Saa95xDJOvqGZyQdI/OPNFw==", + "version": "29.0.0", + "resolved": "https://registry.npmjs.intuit.com:443/artifactory/api/npm/npm-intuit/electron/-/electron-29.0.0.tgz", + "integrity": "sha512-HhrRC5vWb6fAbWXP3A6ABwKUO9JvYSC4E141RzWFgnDBqNiNtabfmgC8hsVeCR65RQA2MLSDgC8uP52I9zFllQ==", "dev": true, "hasInstallScript": true, "dependencies": { "@electron/get": "^2.0.0", - "@types/node": "^18.11.18", + "@types/node": "^20.9.0", "extract-zip": "^2.0.1" }, "bin": { @@ -28886,15 +28886,6 @@ "resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.4.435.tgz", "integrity": "sha512-B0CBWVFhvoQCW/XtjRzgrmqcgVWg6RXOEM/dK59+wFV93BFGR6AeNKc4OyhM+T3IhJaOOG8o/V+33Y2mwJWtzw==" }, - "node_modules/electron/node_modules/@types/node": { - "version": "18.19.8", - "resolved": "https://registry.npmjs.org/@types/node/-/node-18.19.8.tgz", - "integrity": "sha512-g1pZtPhsvGVTwmeVoexWZLTQaOvXwoSq//pTL0DHeNzUDrFnir4fgETdhjhIxjVnN+hKOuh98+E1eMLnUXstFg==", - "dev": true, - "dependencies": { - "undici-types": "~5.26.4" - } - }, "node_modules/element-resize-detector": { "version": "1.2.4", "resolved": "https://registry.npmjs.org/element-resize-detector/-/element-resize-detector-1.2.4.tgz", diff --git a/package.json b/package.json index 76e3f689ca39..d528c46e9635 100644 --- a/package.json +++ b/package.json @@ -250,7 +250,7 @@ "css-loader": "^6.7.2", "diff-so-fancy": "^1.3.0", "dotenv": "^16.0.3", - "electron": "^26.6.8", + "electron": "^29.0.0", "electron-builder": "24.6.4", "eslint": "^7.6.0", "eslint-config-airbnb-typescript": "^17.1.0", From fe356fbada4abc4f443b122edb05e8e5fd8bab18 Mon Sep 17 00:00:00 2001 From: Pedro Guerreiro Date: Wed, 21 Feb 2024 18:03:36 +0000 Subject: [PATCH 010/170] refactor(typescript): migrate localephonenumbertest --- tests/unit/{LocalePhoneNumberTest.js => LocalePhoneNumberTest.ts} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename tests/unit/{LocalePhoneNumberTest.js => LocalePhoneNumberTest.ts} (100%) diff --git a/tests/unit/LocalePhoneNumberTest.js b/tests/unit/LocalePhoneNumberTest.ts similarity index 100% rename from tests/unit/LocalePhoneNumberTest.js rename to tests/unit/LocalePhoneNumberTest.ts From 1061c08239cf3fb323362fbbdbe3c48231c0629e Mon Sep 17 00:00:00 2001 From: Pedro Guerreiro Date: Wed, 21 Feb 2024 21:50:24 +0000 Subject: [PATCH 011/170] refactor(typescript): migrate calendarpickertest --- jest.config.js | 2 +- jest/setupAfterEnv.ts | 3 +++ ...lendarPickerTest.js => CalendarPickerTest.tsx} | 15 +++++++++------ 3 files changed, 13 insertions(+), 7 deletions(-) rename tests/unit/{CalendarPickerTest.js => CalendarPickerTest.tsx} (92%) diff --git a/jest.config.js b/jest.config.js index 95ecc350ed9f..86532b5c9cfd 100644 --- a/jest.config.js +++ b/jest.config.js @@ -23,7 +23,7 @@ module.exports = { }, testEnvironment: 'jsdom', setupFiles: ['/jest/setup.ts', './node_modules/@react-native-google-signin/google-signin/jest/build/setup.js'], - setupFilesAfterEnv: ['@testing-library/jest-native/extend-expect', '/jest/setupAfterEnv.ts', '/tests/perf-test/setupAfterEnv.js'], + setupFilesAfterEnv: ['/jest/setupAfterEnv.ts', '/tests/perf-test/setupAfterEnv.js'], cacheDirectory: '/.jest-cache', moduleNameMapper: { '\\.(lottie)$': '/__mocks__/fileMock.ts', diff --git a/jest/setupAfterEnv.ts b/jest/setupAfterEnv.ts index 6f7836b64dbb..d59495874588 100644 --- a/jest/setupAfterEnv.ts +++ b/jest/setupAfterEnv.ts @@ -1 +1,4 @@ +// This is required in order for jest to recognize custom matchers like toBeDisabled. This can be removed once testing-library/react-native version is bumped to v12.4 or later +import '@testing-library/jest-native/extend-expect'; + jest.useRealTimers(); diff --git a/tests/unit/CalendarPickerTest.js b/tests/unit/CalendarPickerTest.tsx similarity index 92% rename from tests/unit/CalendarPickerTest.js rename to tests/unit/CalendarPickerTest.tsx index 3aab3a13c1c3..8beb02ec80c4 100644 --- a/tests/unit/CalendarPickerTest.js +++ b/tests/unit/CalendarPickerTest.tsx @@ -1,19 +1,22 @@ +import type ReactNavigationNative from '@react-navigation/native'; import {fireEvent, render, within} from '@testing-library/react-native'; import {addMonths, addYears, subMonths, subYears} from 'date-fns'; -import CalendarPicker from '../../src/components/DatePicker/CalendarPicker'; -import CONST from '../../src/CONST'; -import DateUtils from '../../src/libs/DateUtils'; +import type {ComponentType} from 'react'; +import CalendarPicker from '@components/DatePicker/CalendarPicker'; +import type {WithLocalizeProps} from '@components/withLocalize'; +import DateUtils from '@libs/DateUtils'; +import CONST from '@src/CONST'; const monthNames = DateUtils.getMonthNames(CONST.LOCALES.EN); jest.mock('@react-navigation/native', () => ({ - ...jest.requireActual('@react-navigation/native'), + ...jest.requireActual('@react-navigation/native'), useNavigation: () => ({navigate: jest.fn()}), createNavigationContainerRef: jest.fn(), })); -jest.mock('../../src/components/withLocalize', () => (Component) => { - function WrappedComponent(props) { +jest.mock('../../src/components/withLocalize', () => (Component: ComponentType) => { + function WrappedComponent(props: Omit) { return ( Date: Thu, 22 Feb 2024 13:37:54 +0800 Subject: [PATCH 012/170] unsubs from active element when out of focus --- src/components/OptionsSelector/BaseOptionsSelector.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/components/OptionsSelector/BaseOptionsSelector.js b/src/components/OptionsSelector/BaseOptionsSelector.js index 690897d548ce..0ef0a69cf6bf 100755 --- a/src/components/OptionsSelector/BaseOptionsSelector.js +++ b/src/components/OptionsSelector/BaseOptionsSelector.js @@ -125,8 +125,11 @@ class BaseOptionsSelector extends Component { // Unregister the shortcut before registering a new one to avoid lingering shortcut listener this.unSubscribeFromKeyboardShortcut(); if (this.props.isFocused) { + this.subscribeActiveElement(); this.subscribeToEnterShortcut(); this.subscribeToCtrlEnterShortcut(); + } else { + this.unSubscribeActiveElement(); } } From 376b452f6a903d70ba9b3df5857a7ecbad84778c Mon Sep 17 00:00:00 2001 From: Ishpaul Singh Date: Sat, 24 Feb 2024 04:09:28 +0530 Subject: [PATCH 013/170] clean up and changes v2 --- .../DisplayNames/DisplayNamesWithTooltip.tsx | 2 -- src/components/ReportWelcomeText.tsx | 20 ++++++++----------- src/libs/PersonalDetailsUtils.ts | 9 +++++++-- src/libs/ReportUtils.ts | 15 ++++++++++---- src/pages/ProfilePage.js | 8 ++++---- src/pages/ReportDetailsPage.tsx | 14 +++++++++---- src/pages/ReportParticipantsPage.tsx | 2 +- src/pages/home/HeaderView.js | 6 ++---- .../report/ReportDetailsShareCodePage.tsx | 5 +++++ .../withReportAndPrivateNotesOrNotFound.tsx | 2 +- .../Report/NotificationPreferencePage.tsx | 2 +- .../settings/Report/ReportSettingsPage.tsx | 2 +- 12 files changed, 51 insertions(+), 36 deletions(-) diff --git a/src/components/DisplayNames/DisplayNamesWithTooltip.tsx b/src/components/DisplayNames/DisplayNamesWithTooltip.tsx index 9af9b362197f..91b8b0fc4483 100644 --- a/src/components/DisplayNames/DisplayNamesWithTooltip.tsx +++ b/src/components/DisplayNames/DisplayNamesWithTooltip.tsx @@ -47,8 +47,6 @@ function DisplayNamesWithToolTip({shouldUseFullTitle, fullTitle, displayNamesWit return textNodeRight > containerRight ? -(tooltipX - newToolX) : 0; }, []); - console.log('DisplayNamesWithToolTip', {shouldUseFullTitle, fullTitle, displayNamesWithTooltips, textStyles, numberOfLines, renderAdditionalText}); - return ( // Tokenization of string only support prop numberOfLines on Web { - if(isChatRoom) { + if (isChatRoom) { return translate('reportActionsView.welcomeToRoom', {roomName: reportName}); } @@ -70,9 +70,7 @@ function ReportWelcomeText({report, policy, personalDetails}: ReportWelcomeTextP return ( <> - - {getWelcomeHeroText} - + {getWelcomeHeroText} {isPolicyExpenseChat && ( @@ -134,13 +132,11 @@ function ReportWelcomeText({report, policy, personalDetails}: ReportWelcomeTextP )} )} - { - isSelfDM && ( - - {translate('reportActionsView.beginningOfChatHistorySelfDM')} - - ) - } + {isSelfDM && ( + + {translate('reportActionsView.beginningOfChatHistorySelfDM')} + + )} {isDefault && ( {translate('reportActionsView.beginningOfChatHistory')} diff --git a/src/libs/PersonalDetailsUtils.ts b/src/libs/PersonalDetailsUtils.ts index 55aee10e611a..c444beeef266 100644 --- a/src/libs/PersonalDetailsUtils.ts +++ b/src/libs/PersonalDetailsUtils.ts @@ -24,9 +24,14 @@ Onyx.connect({ }, }); -function getDisplayNameOrDefault(passedPersonalDetails?: Partial | null, defaultValue = '', shouldFallbackToHidden = true): string { - const displayName = passedPersonalDetails?.displayName ? passedPersonalDetails.displayName.replace(CONST.REGEX.MERGED_ACCOUNT_PREFIX, '') : ''; +function getDisplayNameOrDefault(passedPersonalDetails?: Partial | null, defaultValue = '', shouldFallbackToHidden = true, shouldAddCurrentUserPostfix = false): string { + let displayName = passedPersonalDetails?.displayName ? passedPersonalDetails.displayName.replace(CONST.REGEX.MERGED_ACCOUNT_PREFIX, '') : ''; + if (shouldAddCurrentUserPostfix) { + displayName = `${displayName} (${Localize.translateLocal('common.you').toLowerCase()})`; + } + const fallbackValue = shouldFallbackToHidden ? Localize.translateLocal('common.hidden') : ''; + return displayName || defaultValue || fallbackValue; } diff --git a/src/libs/ReportUtils.ts b/src/libs/ReportUtils.ts index 9de7b245d6ca..2babce63731e 100644 --- a/src/libs/ReportUtils.ts +++ b/src/libs/ReportUtils.ts @@ -1647,7 +1647,7 @@ function getPersonalDetailsForAccountID(accountID: number): Partial { const accountID = Number(user?.accountID); // eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing - const displayName = getDisplayNameForParticipant(accountID, isMultipleParticipantReport, shouldFallbackToHidden) || user?.login || ''; + const displayName = getDisplayNameForParticipant(accountID, isMultipleParticipantReport, shouldFallbackToHidden, shouldAddCurrentUserPostfix) || user?.login || ''; const avatar = UserUtils.getDefaultAvatar(accountID); let pronouns = user?.pronouns ?? undefined; @@ -4309,7 +4312,11 @@ function getMoneyRequestOptions(report: OnyxEntry, policy: OnyxEntry 0) || (isDM(report) && hasMultipleOtherParticipants) || (isPolicyExpenseChat(report) && report?.isOwnPolicyExpenseChat) && !isSelfDM(report)) { + if ( + (isChatRoom(report) && otherParticipants.length > 0) || + (isDM(report) && hasMultipleOtherParticipants) || + (isPolicyExpenseChat(report) && report?.isOwnPolicyExpenseChat && !isSelfDM(report)) + ) { options = [CONST.IOU.TYPE.SPLIT]; } diff --git a/src/pages/ProfilePage.js b/src/pages/ProfilePage.js index a35937ffc8b8..504392e08878 100755 --- a/src/pages/ProfilePage.js +++ b/src/pages/ProfilePage.js @@ -98,9 +98,10 @@ const getPhoneNumber = (details) => { function ProfilePage(props) { const styles = useThemeStyles(); const accountID = Number(lodashGet(props.route.params, 'accountID', 0)); - const details = lodashGet(props.personalDetails, accountID, ValidationUtils.isValidAccountRoute(accountID) ? {} : {isloading: false}); + const isSelfDM = ReportUtils.isSelfDM(props.report); - const displayName = PersonalDetailsUtils.getDisplayNameOrDefault(details); + const details = lodashGet(props.personalDetails, accountID, ValidationUtils.isValidAccountRoute(accountID) ? {} : {isloading: false}); + const displayName = PersonalDetailsUtils.getDisplayNameOrDefault(details, undefined, undefined, isSelfDM); const avatar = lodashGet(details, 'avatar', UserUtils.getDefaultAvatar()); const fallbackIcon = lodashGet(details, 'fallbackIcon', ''); const login = lodashGet(details, 'login', ''); @@ -132,7 +133,6 @@ function ProfilePage(props) { const statusContent = `${statusEmojiCode} ${statusText}`; const navigateBackTo = lodashGet(props.route, 'params.backTo'); - const isSelfDM = ReportUtils.isSelfDM(props.report); const shouldShowNotificationPreference = !_.isEmpty(props.report) && props.report.notificationPreference !== CONST.REPORT.NOTIFICATION_PREFERENCE.HIDDEN && !isSelfDM; const notificationPreference = shouldShowNotificationPreference ? props.translate(`notificationPreferencesPage.notificationPreferences.${props.report.notificationPreference}`) : ''; @@ -238,7 +238,7 @@ function ProfilePage(props) { shouldShowRightIcon /> )} - {!_.isEmpty(props.report) && ( + {!_.isEmpty(props.report) && !isSelfDM && ( ReportUtils.isSelfDM(report), [report]); + useEffect(() => { - // Do not fetch private notes if isLoadingPrivateNotes is already defined, or if network is offline. - if (isPrivateNotesFetchTriggered || isOffline) { + // Do not fetch private notes if isLoadingPrivateNotes is already defined, or if network is offline or if report is a self DM + if (isPrivateNotesFetchTriggered || isOffline || isSelfDM) { return; } Report.getReportPrivateNote(report?.reportID ?? ''); - }, [report?.reportID, isOffline, isPrivateNotesFetchTriggered]); + }, [report?.reportID, isOffline, isPrivateNotesFetchTriggered, isSelfDM]); const menuItems: ReportDetailsPageMenuItem[] = useMemo(() => { const items: ReportDetailsPageMenuItem[] = []; + if (isSelfDM) { + return items; + } + if (!isGroupDMChat) { items.push({ key: CONST.REPORT_DETAILS_MENU_ITEM.SHARE_CODE, @@ -162,7 +168,7 @@ function ReportDetailsPage({policies, report, session, personalDetails}: ReportD } return items; - }, [isArchivedRoom, participants.length, isThread, isMoneyRequestReport, report, isGroupDMChat, isPolicyMember, isUserCreatedPolicyRoom, session]); + }, [isArchivedRoom, participants.length, isThread, isMoneyRequestReport, report, isGroupDMChat, isPolicyMember, isUserCreatedPolicyRoom, session, isSelfDM]); const displayNamesWithTooltips = useMemo(() => { const hasMultipleParticipants = participants.length > 1; diff --git a/src/pages/ReportParticipantsPage.tsx b/src/pages/ReportParticipantsPage.tsx index 15490455ce09..df9344417137 100755 --- a/src/pages/ReportParticipantsPage.tsx +++ b/src/pages/ReportParticipantsPage.tsx @@ -86,7 +86,7 @@ function ReportParticipantsPage({report, personalDetails}: ReportParticipantsPag testID={ReportParticipantsPage.displayName} > {({safeAreaPaddingBottomStyle}) => ( - + Navigation.goBack(ROUTES.REPORT_WITH_ID_DETAILS.getRoute(report.reportID)) : undefined} title={translate( diff --git a/src/pages/home/HeaderView.js b/src/pages/home/HeaderView.js index 16b9b4f155ae..20bee42cb89b 100644 --- a/src/pages/home/HeaderView.js +++ b/src/pages/home/HeaderView.js @@ -96,11 +96,9 @@ function HeaderView(props) { const participants = lodashGet(props.report, 'participantAccountIDs', []); const participantPersonalDetails = OptionsListUtils.getPersonalDetailsForAccountIDs(participants, props.personalDetails); const isMultipleParticipant = participants.length > 1; - const displayNamesWithTooltips = ReportUtils.getDisplayNamesWithTooltips(participantPersonalDetails, isMultipleParticipant); + const isSelfDM = ReportUtils.isSelfDM(props.report, props.session.accountID); + const displayNamesWithTooltips = ReportUtils.getDisplayNamesWithTooltips(participantPersonalDetails, isMultipleParticipant, undefined, isSelfDM); - if(ReportUtils.isSelfDM(props.report)){ - displayNamesWithTooltips[0].displayName += ` (${translate('common.you')})` - } const isChatThread = ReportUtils.isChatThread(props.report); const isChatRoom = ReportUtils.isChatRoom(props.report); const isPolicyExpenseChat = ReportUtils.isPolicyExpenseChat(props.report); diff --git a/src/pages/home/report/ReportDetailsShareCodePage.tsx b/src/pages/home/report/ReportDetailsShareCodePage.tsx index 28b1d5cd71d7..712e6c3097be 100644 --- a/src/pages/home/report/ReportDetailsShareCodePage.tsx +++ b/src/pages/home/report/ReportDetailsShareCodePage.tsx @@ -1,4 +1,6 @@ import React from 'react'; +import * as ReportUtils from '@libs/ReportUtils'; +import NotFoundPage from '@pages/ErrorPage/NotFoundPage'; import ShareCodePage from '@pages/ShareCodePage'; import type {WithReportOrNotFoundProps} from './withReportOrNotFound'; import withReportOrNotFound from './withReportOrNotFound'; @@ -6,6 +8,9 @@ import withReportOrNotFound from './withReportOrNotFound'; type ReportDetailsShareCodePageProps = WithReportOrNotFoundProps; function ReportDetailsShareCodePage({report}: ReportDetailsShareCodePageProps) { + if (ReportUtils.isSelfDM(report)) { + return ; + } return ; } diff --git a/src/pages/home/report/withReportAndPrivateNotesOrNotFound.tsx b/src/pages/home/report/withReportAndPrivateNotesOrNotFound.tsx index d8d461568a45..6bf88849e8b8 100644 --- a/src/pages/home/report/withReportAndPrivateNotesOrNotFound.tsx +++ b/src/pages/home/report/withReportAndPrivateNotesOrNotFound.tsx @@ -57,7 +57,7 @@ export default function (pageTitle: TranslationPaths) { // eslint-disable-next-line rulesdir/no-negated-variables const shouldShowNotFoundPage = useMemo(() => { // Show not found view if the report is archived, or if the note is not of current user. - if (ReportUtils.isArchivedRoom(report) || isOtherUserNote) { + if (ReportUtils.isArchivedRoom(report) || isOtherUserNote || ReportUtils.isSelfDM(report)) { return true; } diff --git a/src/pages/settings/Report/NotificationPreferencePage.tsx b/src/pages/settings/Report/NotificationPreferencePage.tsx index 3977bdd0233d..af55ff994fcf 100644 --- a/src/pages/settings/Report/NotificationPreferencePage.tsx +++ b/src/pages/settings/Report/NotificationPreferencePage.tsx @@ -18,7 +18,7 @@ type NotificationPreferencePageProps = WithReportOrNotFoundProps & StackScreenPr function NotificationPreferencePage({report}: NotificationPreferencePageProps) { const {translate} = useLocalize(); - const shouldDisableNotificationPreferences = ReportUtils.isArchivedRoom(report); + const shouldDisableNotificationPreferences = ReportUtils.isArchivedRoom(report) || ReportUtils.isSelfDM(report); const notificationPreferenceOptions = Object.values(CONST.REPORT.NOTIFICATION_PREFERENCE) .filter((pref) => pref !== CONST.REPORT.NOTIFICATION_PREFERENCE.HIDDEN) .map((preference) => ({ diff --git a/src/pages/settings/Report/ReportSettingsPage.tsx b/src/pages/settings/Report/ReportSettingsPage.tsx index d738fc7ac3cf..0610d1e9057d 100644 --- a/src/pages/settings/Report/ReportSettingsPage.tsx +++ b/src/pages/settings/Report/ReportSettingsPage.tsx @@ -33,7 +33,7 @@ function ReportSettingsPage({report, policies}: ReportSettingsPageProps) { const shouldDisableRename = useMemo(() => ReportUtils.shouldDisableRename(report, linkedWorkspace), [report, linkedWorkspace]); const isMoneyRequestReport = ReportUtils.isMoneyRequestReport(report); - const shouldDisableSettings = isEmptyObject(report) || ReportUtils.isArchivedRoom(report); + const shouldDisableSettings = isEmptyObject(report) || ReportUtils.isArchivedRoom(report) || ReportUtils.isSelfDM(report); const shouldShowRoomName = !ReportUtils.isPolicyExpenseChat(report) && !ReportUtils.isChatThread(report); const notificationPreference = report?.notificationPreference && report.notificationPreference !== CONST.REPORT.NOTIFICATION_PREFERENCE.HIDDEN From f16a19ff9b7e6620ffd05db463b1d4e6e123bf41 Mon Sep 17 00:00:00 2001 From: Ishpaul Singh Date: Sat, 24 Feb 2024 04:49:22 +0530 Subject: [PATCH 014/170] fixes selfDm reportName in LHN --- src/libs/OptionsListUtils.ts | 3 +++ src/libs/ReportUtils.ts | 5 +++++ src/libs/SidebarUtils.ts | 3 ++- 3 files changed, 10 insertions(+), 1 deletion(-) diff --git a/src/libs/OptionsListUtils.ts b/src/libs/OptionsListUtils.ts index 70d92d9d7b96..f26d4b33d4d0 100644 --- a/src/libs/OptionsListUtils.ts +++ b/src/libs/OptionsListUtils.ts @@ -665,6 +665,8 @@ function createOption( result.tooltipText = ReportUtils.getReportParticipantsTitle(report.visibleChatMemberAccountIDs ?? []); result.isWaitingOnBankAccount = report.isWaitingOnBankAccount; result.policyID = report.policyID; + result.isSelfDM = ReportUtils.isSelfDM(report); + hasMultipleParticipants = personalDetailList.length > 1 || result.isChatRoom || result.isPolicyExpenseChat; subtitle = ReportUtils.getChatRoomSubtitle(report); @@ -1732,6 +1734,7 @@ function getSearchOptions(reports: Record, personalDetails: Onyx includeThreads: true, includeMoneyRequests: true, includeTasks: true, + includeSelfDM: true, }); Timing.end(CONST.TIMING.LOAD_SEARCH_OPTIONS); Performance.markEnd(CONST.TIMING.LOAD_SEARCH_OPTIONS); diff --git a/src/libs/ReportUtils.ts b/src/libs/ReportUtils.ts index 2babce63731e..f2632b8b7d99 100644 --- a/src/libs/ReportUtils.ts +++ b/src/libs/ReportUtils.ts @@ -399,6 +399,7 @@ type OptionData = { notificationPreference?: NotificationPreference | null; isDisabled?: boolean | null; name?: string | null; + isSelfDM?: boolean | null; } & Report; type OnyxDataTaskAssigneeChat = { @@ -2570,6 +2571,10 @@ function getReportName(report: OnyxEntry, policy: OnyxEntry = nu formattedName += ` (${Localize.translateLocal('common.archived')})`; } + if (isSelfDM(report)) { + formattedName = getDisplayNameForParticipant(report?.participantAccountIDs?.[0], undefined, undefined, true); + } + if (formattedName) { return formattedName; } diff --git a/src/libs/SidebarUtils.ts b/src/libs/SidebarUtils.ts index d9298817f6b7..b2432b1e7a07 100644 --- a/src/libs/SidebarUtils.ts +++ b/src/libs/SidebarUtils.ts @@ -258,6 +258,7 @@ function getOptionData({ result.isAllowedToComment = ReportUtils.canUserPerformWriteAction(report); result.chatType = report.chatType; result.isDeletedParentAction = report.isDeletedParentAction; + result.isSelfDM = ReportUtils.isSelfDM(report); const hasMultipleParticipants = participantPersonalDetailList.length > 1 || result.isChatRoom || result.isPolicyExpenseChat || ReportUtils.isExpenseReport(report); const subtitle = ReportUtils.getChatRoomSubtitle(report); @@ -267,7 +268,7 @@ function getOptionData({ const formattedLogin = Str.isSMSLogin(login) ? LocalePhoneNumber.formatPhoneNumber(login) : login; // We only create tooltips for the first 10 users or so since some reports have hundreds of users, causing performance to degrade. - const displayNamesWithTooltips = ReportUtils.getDisplayNamesWithTooltips((participantPersonalDetailList || []).slice(0, 10), hasMultipleParticipants); + const displayNamesWithTooltips = ReportUtils.getDisplayNamesWithTooltips((participantPersonalDetailList || []).slice(0, 10), hasMultipleParticipants, undefined, ReportUtils.isSelfDM(report)); // If the last actor's details are not currently saved in Onyx Collection, // then try to get that from the last report action if that action is valid From ad2580599c0a9b53fc00f11a2772a7920b0f0886 Mon Sep 17 00:00:00 2001 From: Ishpaul Singh Date: Sat, 24 Feb 2024 05:00:54 +0530 Subject: [PATCH 015/170] show report in detination for tasks --- src/libs/OptionsListUtils.ts | 5 +++-- .../MoneyTemporaryForRefactorRequestParticipantsSelector.js | 3 --- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/src/libs/OptionsListUtils.ts b/src/libs/OptionsListUtils.ts index f26d4b33d4d0..5d1a952413e8 100644 --- a/src/libs/OptionsListUtils.ts +++ b/src/libs/OptionsListUtils.ts @@ -1363,7 +1363,7 @@ function getOptions( transactionViolations = {}, includePolicyTaxRates, policyTaxRates, - includeSelfDM = true, + includeSelfDM = false, }: GetOptionsConfig, ): GetOptions { if (includeCategories) { @@ -1810,7 +1810,7 @@ function getFilteredOptions( includeSelectedOptions = false, includePolicyTaxRates = false, policyTaxRates: PolicyTaxRateWithDefault = {} as PolicyTaxRateWithDefault, - includeSelfDM = true, + includeSelfDM = false, ) { return getOptions(reports, personalDetails, { betas, @@ -1866,6 +1866,7 @@ function getShareDestinationOptions( excludeLogins, includeOwnedWorkspaceChats, excludeUnknownUsers, + includeSelfDM: true, }); } diff --git a/src/pages/iou/request/MoneyTemporaryForRefactorRequestParticipantsSelector.js b/src/pages/iou/request/MoneyTemporaryForRefactorRequestParticipantsSelector.js index fa1272531757..d9d844e3a9a2 100644 --- a/src/pages/iou/request/MoneyTemporaryForRefactorRequestParticipantsSelector.js +++ b/src/pages/iou/request/MoneyTemporaryForRefactorRequestParticipantsSelector.js @@ -133,9 +133,6 @@ function MoneyTemporaryForRefactorRequestParticipantsSelector({ // This functionality is being built here: https://github.com/Expensify/App/issues/23291 iouRequestType !== CONST.IOU.REQUEST_TYPE.DISTANCE, false, - undefined, - undefined, - false, ); const formatResults = OptionsListUtils.formatSectionsFromSearchTerm( From f6362ad327591c73b4808dcc0d3cf20bf91c0139 Mon Sep 17 00:00:00 2001 From: Ishpaul Singh Date: Sat, 24 Feb 2024 05:08:17 +0530 Subject: [PATCH 016/170] prettier diffs --- src/libs/SidebarUtils.ts | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/libs/SidebarUtils.ts b/src/libs/SidebarUtils.ts index b2432b1e7a07..c8a51471156e 100644 --- a/src/libs/SidebarUtils.ts +++ b/src/libs/SidebarUtils.ts @@ -268,7 +268,12 @@ function getOptionData({ const formattedLogin = Str.isSMSLogin(login) ? LocalePhoneNumber.formatPhoneNumber(login) : login; // We only create tooltips for the first 10 users or so since some reports have hundreds of users, causing performance to degrade. - const displayNamesWithTooltips = ReportUtils.getDisplayNamesWithTooltips((participantPersonalDetailList || []).slice(0, 10), hasMultipleParticipants, undefined, ReportUtils.isSelfDM(report)); + const displayNamesWithTooltips = ReportUtils.getDisplayNamesWithTooltips( + (participantPersonalDetailList || []).slice(0, 10), + hasMultipleParticipants, + undefined, + ReportUtils.isSelfDM(report), + ); // If the last actor's details are not currently saved in Onyx Collection, // then try to get that from the last report action if that action is valid From 646b6897f40b6e9ca4d964b97dbfb999c6e37eac Mon Sep 17 00:00:00 2001 From: Rushat Gabhane Date: Tue, 27 Feb 2024 15:43:46 +0300 Subject: [PATCH 017/170] add spend route --- src/ROUTES.ts | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/ROUTES.ts b/src/ROUTES.ts index a8786bda3ffb..3b493740d8ca 100644 --- a/src/ROUTES.ts +++ b/src/ROUTES.ts @@ -486,6 +486,10 @@ const ROUTES = { route: 'workspace/:policyID/workflows', getRoute: (policyID: string) => `workspace/${policyID}/workflows` as const, }, + WORKSPACE_WORKFLOWS_SPEND_APPROVER: { + route: 'workspace/:policyId/workflows/spend/approver', + getRoute: (policyId: string) => `workspace/${policyId}/workflow/spend/approver` as const, + }, WORKSPACE_CARD: { route: 'workspace/:policyID/card', getRoute: (policyID: string) => `workspace/${policyID}/card` as const, From 08b1ed22611875aa4dcb771149736d35dccbbb3b Mon Sep 17 00:00:00 2001 From: Rushat Gabhane Date: Tue, 27 Feb 2024 15:43:57 +0300 Subject: [PATCH 018/170] add spend route --- src/SCREENS.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/src/SCREENS.ts b/src/SCREENS.ts index 520895c89c98..2d5f90b85a71 100644 --- a/src/SCREENS.ts +++ b/src/SCREENS.ts @@ -216,6 +216,7 @@ const SCREENS = { CATEGORIES: 'Workspace_Categories', CURRENCY: 'Workspace_Profile_Currency', WORKFLOWS: 'Workspace_Workflows', + WORKFLOWS_SPEND_APPROVER: 'Workspace_Workflows_Spend_Approver', DESCRIPTION: 'Workspace_Profile_Description', SHARE: 'Workspace_Profile_Share', NAME: 'Workspace_Profile_Name', From 52d78fa5761b96f24c3b258da51250ce294b19f5 Mon Sep 17 00:00:00 2001 From: Rushat Gabhane Date: Tue, 27 Feb 2024 15:44:22 +0300 Subject: [PATCH 019/170] add approver to stack nav --- src/libs/Navigation/AppNavigator/ModalStackNavigators.tsx | 1 + src/libs/Navigation/linkingConfig/config.ts | 3 +++ 2 files changed, 4 insertions(+) diff --git a/src/libs/Navigation/AppNavigator/ModalStackNavigators.tsx b/src/libs/Navigation/AppNavigator/ModalStackNavigators.tsx index 0ecbe7a03d87..9d1a8e2ebde0 100644 --- a/src/libs/Navigation/AppNavigator/ModalStackNavigators.tsx +++ b/src/libs/Navigation/AppNavigator/ModalStackNavigators.tsx @@ -252,6 +252,7 @@ const SettingsModalStackNavigator = createModalStackNavigator require('../../../pages/workspace/reimburse/WorkspaceRateAndUnitPage/RatePage').default as React.ComponentType, [SCREENS.WORKSPACE.RATE_AND_UNIT_UNIT]: () => require('../../../pages/workspace/reimburse/WorkspaceRateAndUnitPage/UnitPage').default as React.ComponentType, [SCREENS.WORKSPACE.INVITE]: () => require('../../../pages/workspace/WorkspaceInvitePage').default as React.ComponentType, + [SCREENS.WORKSPACE.WORKFLOWS_SPEND_APPROVER]: () => require('../../../pages/workspace/workflows/WorkspaceWorkflowsApproverPage').default as React.ComponentType, [SCREENS.WORKSPACE.INVITE_MESSAGE]: () => require('../../../pages/workspace/WorkspaceInviteMessagePage').default as React.ComponentType, [SCREENS.WORKSPACE.NAME]: () => require('../../../pages/workspace/WorkspaceNamePage').default as React.ComponentType, [SCREENS.WORKSPACE.DESCRIPTION]: () => require('../../../pages/workspace/WorkspaceProfileDescriptionPage').default as React.ComponentType, diff --git a/src/libs/Navigation/linkingConfig/config.ts b/src/libs/Navigation/linkingConfig/config.ts index 48d649cc4dd9..b282405f8d7e 100644 --- a/src/libs/Navigation/linkingConfig/config.ts +++ b/src/libs/Navigation/linkingConfig/config.ts @@ -256,6 +256,9 @@ const config: LinkingOptions['config'] = { [SCREENS.WORKSPACE.INVITE]: { path: ROUTES.WORKSPACE_INVITE.route, }, + [SCREENS.WORKSPACE.WORKFLOWS_SPEND_APPROVER]: { + path: ROUTES.WORKSPACE_WORKFLOWS_SPEND_APPROVER.route, + }, [SCREENS.WORKSPACE.INVITE_MESSAGE]: { path: ROUTES.WORKSPACE_INVITE_MESSAGE.route, }, From e30eb65fccaa918047287ab6b7b66422bf2e57ba Mon Sep 17 00:00:00 2001 From: Rushat Gabhane Date: Tue, 27 Feb 2024 15:45:00 +0300 Subject: [PATCH 020/170] open workflow page on click --- src/pages/workspace/workflows/WorkspaceWorkflowsPage.tsx | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/pages/workspace/workflows/WorkspaceWorkflowsPage.tsx b/src/pages/workspace/workflows/WorkspaceWorkflowsPage.tsx index fc1ed1d19560..b4b15034601c 100644 --- a/src/pages/workspace/workflows/WorkspaceWorkflowsPage.tsx +++ b/src/pages/workspace/workflows/WorkspaceWorkflowsPage.tsx @@ -10,6 +10,7 @@ import useNetwork from '@hooks/useNetwork'; import useStyleUtils from '@hooks/useStyleUtils'; import useThemeStyles from '@hooks/useThemeStyles'; import useWindowDimensions from '@hooks/useWindowDimensions'; +import Navigation from '@libs/Navigation/Navigation'; import * as OptionsListUtils from '@libs/OptionsListUtils'; import * as PolicyUtils from '@libs/PolicyUtils'; import * as ReportUtils from '@libs/ReportUtils'; @@ -19,6 +20,7 @@ import type {WithPolicyProps} from '@pages/workspace/withPolicy'; import WorkspacePageWithSections from '@pages/workspace/WorkspacePageWithSections'; import * as Policy from '@userActions/Policy'; import CONST from '@src/CONST'; +import ROUTES from '@src/ROUTES'; import type SCREENS from '@src/SCREENS'; import ToggleSettingOptionRow from './ToggleSettingsOptionRow'; import type {ToggleSettingOptionRowProps} from './ToggleSettingsOptionRow'; @@ -74,7 +76,7 @@ function WorkspaceWorkflowsPage({policy, route}: WorkspaceWorkflowsPageProps) { titleStyle={styles.textLabelSupportingNormal} descriptionTextStyle={styles.textNormalThemeText} description={policyOwnerDisplayName ?? ''} - // onPress={() => Navigation.navigate(ROUTES.WORKSPACE_WORKFLOWS_APPROVER.getRoute(route.params.policyID))} + onPress={() => Navigation.navigate(ROUTES.WORKSPACE_WORKFLOW_SPEND_APPROVER.getRoute(route.params.policyID))} // TODO will be done in https://github.com/Expensify/Expensify/issues/368334 shouldShowRightIcon wrapperStyle={containerStyle} From b45c1062ec714c4b4d853cbe7d9394d3e2783c4d Mon Sep 17 00:00:00 2001 From: Rushat Gabhane Date: Tue, 27 Feb 2024 15:45:16 +0300 Subject: [PATCH 021/170] add dummy approver page --- .../workspace/workflows/WorkspaceWorkflowsApproverPage.tsx | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 src/pages/workspace/workflows/WorkspaceWorkflowsApproverPage.tsx diff --git a/src/pages/workspace/workflows/WorkspaceWorkflowsApproverPage.tsx b/src/pages/workspace/workflows/WorkspaceWorkflowsApproverPage.tsx new file mode 100644 index 000000000000..5e7502ff2429 --- /dev/null +++ b/src/pages/workspace/workflows/WorkspaceWorkflowsApproverPage.tsx @@ -0,0 +1,3 @@ +function WorkspaceWorkflowsApproverPage() {} + +export default WorkspaceWorkflowsApproverPage; From c335676613e2342d387f4d5299f0658475e6a5ed Mon Sep 17 00:00:00 2001 From: Rushat Gabhane Date: Tue, 27 Feb 2024 15:46:58 +0300 Subject: [PATCH 022/170] fix linking --- src/pages/workspace/workflows/WorkspaceWorkflowsPage.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pages/workspace/workflows/WorkspaceWorkflowsPage.tsx b/src/pages/workspace/workflows/WorkspaceWorkflowsPage.tsx index b4b15034601c..da70aacbbe94 100644 --- a/src/pages/workspace/workflows/WorkspaceWorkflowsPage.tsx +++ b/src/pages/workspace/workflows/WorkspaceWorkflowsPage.tsx @@ -76,7 +76,7 @@ function WorkspaceWorkflowsPage({policy, route}: WorkspaceWorkflowsPageProps) { titleStyle={styles.textLabelSupportingNormal} descriptionTextStyle={styles.textNormalThemeText} description={policyOwnerDisplayName ?? ''} - onPress={() => Navigation.navigate(ROUTES.WORKSPACE_WORKFLOW_SPEND_APPROVER.getRoute(route.params.policyID))} + onPress={() => Navigation.navigate(ROUTES.WORKSPACE_WORKFLOWS_SPEND_APPROVER.getRoute(route.params.policyID))} // TODO will be done in https://github.com/Expensify/Expensify/issues/368334 shouldShowRightIcon wrapperStyle={containerStyle} From 7028951aaed96f57c98768b66bff41dd25bfd38f Mon Sep 17 00:00:00 2001 From: Rushat Gabhane Date: Tue, 27 Feb 2024 15:49:42 +0300 Subject: [PATCH 023/170] fix tpo --- src/ROUTES.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/ROUTES.ts b/src/ROUTES.ts index 3b493740d8ca..127ca2a27afc 100644 --- a/src/ROUTES.ts +++ b/src/ROUTES.ts @@ -488,7 +488,7 @@ const ROUTES = { }, WORKSPACE_WORKFLOWS_SPEND_APPROVER: { route: 'workspace/:policyId/workflows/spend/approver', - getRoute: (policyId: string) => `workspace/${policyId}/workflow/spend/approver` as const, + getRoute: (policyId: string) => `workspace/${policyId}/workflows/spend/approver` as const, }, WORKSPACE_CARD: { route: 'workspace/:policyID/card', From 15704d474191d1da2117b38a290cbff6af09f948 Mon Sep 17 00:00:00 2001 From: Rushat Gabhane Date: Tue, 27 Feb 2024 15:59:43 +0300 Subject: [PATCH 024/170] rename --- src/ROUTES.ts | 6 +++--- src/libs/API/types.ts | 1 + src/libs/Navigation/linkingConfig/config.ts | 2 +- src/pages/workspace/workflows/WorkspaceWorkflowsPage.tsx | 2 +- 4 files changed, 6 insertions(+), 5 deletions(-) diff --git a/src/ROUTES.ts b/src/ROUTES.ts index 127ca2a27afc..09eab557b283 100644 --- a/src/ROUTES.ts +++ b/src/ROUTES.ts @@ -486,9 +486,9 @@ const ROUTES = { route: 'workspace/:policyID/workflows', getRoute: (policyID: string) => `workspace/${policyID}/workflows` as const, }, - WORKSPACE_WORKFLOWS_SPEND_APPROVER: { - route: 'workspace/:policyId/workflows/spend/approver', - getRoute: (policyId: string) => `workspace/${policyId}/workflows/spend/approver` as const, + WORKSPACE_WORKFLOWS_APPROVER: { + route: 'workspace/:policyId/workflows/approver', + getRoute: (policyId: string) => `workspace/${policyId}/workflows/approver` as const, }, WORKSPACE_CARD: { route: 'workspace/:policyID/card', diff --git a/src/libs/API/types.ts b/src/libs/API/types.ts index 17cc366ba3b7..beeec04fa44e 100644 --- a/src/libs/API/types.ts +++ b/src/libs/API/types.ts @@ -10,6 +10,7 @@ type ApiRequest = ValueOf; const WRITE_COMMANDS = { SET_WORKSPACE_AUTO_REPORTING: 'SetWorkspaceAutoReporting', SET_WORKSPACE_APPROVAL_MODE: 'SetWorkspaceApprovalMode', + SET_WORKSPACE_APPROVER: 'SetWorkspaceApprover', DISMISS_REFERRAL_BANNER: 'DismissReferralBanner', UPDATE_PREFERRED_LOCALE: 'UpdatePreferredLocale', RECONNECT_APP: 'ReconnectApp', diff --git a/src/libs/Navigation/linkingConfig/config.ts b/src/libs/Navigation/linkingConfig/config.ts index b282405f8d7e..e50a71d9f9cb 100644 --- a/src/libs/Navigation/linkingConfig/config.ts +++ b/src/libs/Navigation/linkingConfig/config.ts @@ -257,7 +257,7 @@ const config: LinkingOptions['config'] = { path: ROUTES.WORKSPACE_INVITE.route, }, [SCREENS.WORKSPACE.WORKFLOWS_SPEND_APPROVER]: { - path: ROUTES.WORKSPACE_WORKFLOWS_SPEND_APPROVER.route, + path: ROUTES.WORKSPACE_WORKFLOWS_APPROVER.route, }, [SCREENS.WORKSPACE.INVITE_MESSAGE]: { path: ROUTES.WORKSPACE_INVITE_MESSAGE.route, diff --git a/src/pages/workspace/workflows/WorkspaceWorkflowsPage.tsx b/src/pages/workspace/workflows/WorkspaceWorkflowsPage.tsx index da70aacbbe94..60588cffba36 100644 --- a/src/pages/workspace/workflows/WorkspaceWorkflowsPage.tsx +++ b/src/pages/workspace/workflows/WorkspaceWorkflowsPage.tsx @@ -76,7 +76,7 @@ function WorkspaceWorkflowsPage({policy, route}: WorkspaceWorkflowsPageProps) { titleStyle={styles.textLabelSupportingNormal} descriptionTextStyle={styles.textNormalThemeText} description={policyOwnerDisplayName ?? ''} - onPress={() => Navigation.navigate(ROUTES.WORKSPACE_WORKFLOWS_SPEND_APPROVER.getRoute(route.params.policyID))} + onPress={() => Navigation.navigate(ROUTES.WORKSPACE_WORKFLOWS_APPROVER.getRoute(route.params.policyID))} // TODO will be done in https://github.com/Expensify/Expensify/issues/368334 shouldShowRightIcon wrapperStyle={containerStyle} From 90beac6b3c393b5be6de0d69084d83156b575461 Mon Sep 17 00:00:00 2001 From: Rushat Gabhane Date: Tue, 27 Feb 2024 16:02:01 +0300 Subject: [PATCH 025/170] rename: remove spend --- src/SCREENS.ts | 2 +- src/libs/Navigation/AppNavigator/ModalStackNavigators.tsx | 2 +- src/libs/Navigation/linkingConfig/config.ts | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/SCREENS.ts b/src/SCREENS.ts index 2d5f90b85a71..7c0c3c39a835 100644 --- a/src/SCREENS.ts +++ b/src/SCREENS.ts @@ -216,7 +216,7 @@ const SCREENS = { CATEGORIES: 'Workspace_Categories', CURRENCY: 'Workspace_Profile_Currency', WORKFLOWS: 'Workspace_Workflows', - WORKFLOWS_SPEND_APPROVER: 'Workspace_Workflows_Spend_Approver', + WORKFLOWS_APPROVER: 'Workspace_Workflows_Approver', DESCRIPTION: 'Workspace_Profile_Description', SHARE: 'Workspace_Profile_Share', NAME: 'Workspace_Profile_Name', diff --git a/src/libs/Navigation/AppNavigator/ModalStackNavigators.tsx b/src/libs/Navigation/AppNavigator/ModalStackNavigators.tsx index 9d1a8e2ebde0..53aaa2008c3d 100644 --- a/src/libs/Navigation/AppNavigator/ModalStackNavigators.tsx +++ b/src/libs/Navigation/AppNavigator/ModalStackNavigators.tsx @@ -252,7 +252,7 @@ const SettingsModalStackNavigator = createModalStackNavigator require('../../../pages/workspace/reimburse/WorkspaceRateAndUnitPage/RatePage').default as React.ComponentType, [SCREENS.WORKSPACE.RATE_AND_UNIT_UNIT]: () => require('../../../pages/workspace/reimburse/WorkspaceRateAndUnitPage/UnitPage').default as React.ComponentType, [SCREENS.WORKSPACE.INVITE]: () => require('../../../pages/workspace/WorkspaceInvitePage').default as React.ComponentType, - [SCREENS.WORKSPACE.WORKFLOWS_SPEND_APPROVER]: () => require('../../../pages/workspace/workflows/WorkspaceWorkflowsApproverPage').default as React.ComponentType, + [SCREENS.WORKSPACE.WORKFLOWS_APPROVER]: () => require('../../../pages/workspace/workflows/WorkspaceWorkflowsApproverPage').default as React.ComponentType, [SCREENS.WORKSPACE.INVITE_MESSAGE]: () => require('../../../pages/workspace/WorkspaceInviteMessagePage').default as React.ComponentType, [SCREENS.WORKSPACE.NAME]: () => require('../../../pages/workspace/WorkspaceNamePage').default as React.ComponentType, [SCREENS.WORKSPACE.DESCRIPTION]: () => require('../../../pages/workspace/WorkspaceProfileDescriptionPage').default as React.ComponentType, diff --git a/src/libs/Navigation/linkingConfig/config.ts b/src/libs/Navigation/linkingConfig/config.ts index e50a71d9f9cb..838219a63e8a 100644 --- a/src/libs/Navigation/linkingConfig/config.ts +++ b/src/libs/Navigation/linkingConfig/config.ts @@ -256,7 +256,7 @@ const config: LinkingOptions['config'] = { [SCREENS.WORKSPACE.INVITE]: { path: ROUTES.WORKSPACE_INVITE.route, }, - [SCREENS.WORKSPACE.WORKFLOWS_SPEND_APPROVER]: { + [SCREENS.WORKSPACE.WORKFLOWS_APPROVER]: { path: ROUTES.WORKSPACE_WORKFLOWS_APPROVER.route, }, [SCREENS.WORKSPACE.INVITE_MESSAGE]: { From e254f56449c08f3b906f5efa76b86b1ad72efe56 Mon Sep 17 00:00:00 2001 From: Rushat Gabhane Date: Tue, 27 Feb 2024 16:15:50 +0300 Subject: [PATCH 026/170] add api type --- src/libs/API/parameters/index.ts | 1 + src/libs/API/types.ts | 1 + 2 files changed, 2 insertions(+) diff --git a/src/libs/API/parameters/index.ts b/src/libs/API/parameters/index.ts index 0b0a81eb21f8..3214af820ae1 100644 --- a/src/libs/API/parameters/index.ts +++ b/src/libs/API/parameters/index.ts @@ -147,4 +147,5 @@ export type {default as AcceptACHContractForBankAccount} from './AcceptACHContra export type {default as UpdateWorkspaceDescriptionParams} from './UpdateWorkspaceDescriptionParams'; export type {default as SetWorkspaceAutoReportingParams} from './SetWorkspaceAutoReportingParams'; export type {default as SetWorkspaceApprovalModeParams} from './SetWorkspaceApprovalModeParams'; +export type {default as SetWorkspaceWorkflowsApproverParams} from './SetWorkspaceWorkflowsApproverParams'; export type {default as SwitchToOldDotParams} from './SwitchToOldDotParams'; diff --git a/src/libs/API/types.ts b/src/libs/API/types.ts index beeec04fa44e..e2ea1143a8d2 100644 --- a/src/libs/API/types.ts +++ b/src/libs/API/types.ts @@ -297,6 +297,7 @@ type WriteCommandParameters = { [WRITE_COMMANDS.ACCEPT_ACH_CONTRACT_FOR_BANK_ACCOUNT]: Parameters.AcceptACHContractForBankAccount; [WRITE_COMMANDS.UPDATE_WORKSPACE_DESCRIPTION]: Parameters.UpdateWorkspaceDescriptionParams; [WRITE_COMMANDS.SET_WORKSPACE_AUTO_REPORTING]: Parameters.SetWorkspaceAutoReportingParams; + [WRITE_COMMANDS.SET_WORKSPACE_APPROVER]: Parameters.SetWorkspaceWorkflowsApproverParams; [WRITE_COMMANDS.SET_WORKSPACE_APPROVAL_MODE]: Parameters.SetWorkspaceApprovalModeParams; [WRITE_COMMANDS.SWITCH_TO_OLD_DOT]: Parameters.SwitchToOldDotParams; }; From bcd89b7507ecb11fda06df47f74dc739f66b4e2e Mon Sep 17 00:00:00 2001 From: Rushat Gabhane Date: Tue, 27 Feb 2024 16:16:24 +0300 Subject: [PATCH 027/170] link write api params --- .../API/parameters/SetWorkspaceWorkflowsApproverParams.ts | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 src/libs/API/parameters/SetWorkspaceWorkflowsApproverParams.ts diff --git a/src/libs/API/parameters/SetWorkspaceWorkflowsApproverParams.ts b/src/libs/API/parameters/SetWorkspaceWorkflowsApproverParams.ts new file mode 100644 index 000000000000..cf1d4a2e705b --- /dev/null +++ b/src/libs/API/parameters/SetWorkspaceWorkflowsApproverParams.ts @@ -0,0 +1,6 @@ +type SetWorkspaceWorkflowsApproverParams = { + policyID: string; + accountID: number; +}; + +export default SetWorkspaceWorkflowsApproverParams; From c814c514ea175c5701afc4fb9f0eda1ddc9d38f4 Mon Sep 17 00:00:00 2001 From: Rushat Gabhane Date: Tue, 27 Feb 2024 17:08:09 +0300 Subject: [PATCH 028/170] fix policy id route --- src/ROUTES.ts | 2 +- .../WorkspaceWorkflowsApproverPage.tsx | 32 +++++++++++++++++-- 2 files changed, 31 insertions(+), 3 deletions(-) diff --git a/src/ROUTES.ts b/src/ROUTES.ts index 09eab557b283..8ae3125e728d 100644 --- a/src/ROUTES.ts +++ b/src/ROUTES.ts @@ -487,7 +487,7 @@ const ROUTES = { getRoute: (policyID: string) => `workspace/${policyID}/workflows` as const, }, WORKSPACE_WORKFLOWS_APPROVER: { - route: 'workspace/:policyId/workflows/approver', + route: 'workspace/:policyID/workflows/approver', getRoute: (policyId: string) => `workspace/${policyId}/workflows/approver` as const, }, WORKSPACE_CARD: { diff --git a/src/pages/workspace/workflows/WorkspaceWorkflowsApproverPage.tsx b/src/pages/workspace/workflows/WorkspaceWorkflowsApproverPage.tsx index 5e7502ff2429..669d94247055 100644 --- a/src/pages/workspace/workflows/WorkspaceWorkflowsApproverPage.tsx +++ b/src/pages/workspace/workflows/WorkspaceWorkflowsApproverPage.tsx @@ -1,3 +1,31 @@ -function WorkspaceWorkflowsApproverPage() {} +import React from 'react'; +import HeaderWithBackButton from '@components/HeaderWithBackButton'; +import ScreenWrapper from '@components/ScreenWrapper'; +import useLocalize from '@hooks/useLocalize'; +import Navigation from '@libs/Navigation/Navigation'; +import withPolicy, {WithPolicyOnyxProps} from '@pages/workspace/withPolicy'; -export default WorkspaceWorkflowsApproverPage; +type WorkspaceWorkflowsApproverPageProps = WithPolicyOnyxProps; + +function WorkspaceWorkflowsApproverPage({policy}: WorkspaceWorkflowsApproverPageProps) { + const {translate} = useLocalize(); + const policyName = policy?.name ?? ''; + console.log(policy); + + return ( + + + + ); +} + +WorkspaceWorkflowsApproverPage.displayName = 'WorkspaceWorkflowsApproverPage'; + +export default withPolicy(WorkspaceWorkflowsApproverPage); From d4e4de13bed06fb1fa2cd972b68e843055f4310a Mon Sep 17 00:00:00 2001 From: Rushat Gabhane Date: Tue, 27 Feb 2024 17:10:27 +0300 Subject: [PATCH 029/170] rm console --- src/pages/workspace/workflows/WorkspaceWorkflowsApproverPage.tsx | 1 - 1 file changed, 1 deletion(-) diff --git a/src/pages/workspace/workflows/WorkspaceWorkflowsApproverPage.tsx b/src/pages/workspace/workflows/WorkspaceWorkflowsApproverPage.tsx index 669d94247055..fdba10dd324c 100644 --- a/src/pages/workspace/workflows/WorkspaceWorkflowsApproverPage.tsx +++ b/src/pages/workspace/workflows/WorkspaceWorkflowsApproverPage.tsx @@ -10,7 +10,6 @@ type WorkspaceWorkflowsApproverPageProps = WithPolicyOnyxProps; function WorkspaceWorkflowsApproverPage({policy}: WorkspaceWorkflowsApproverPageProps) { const {translate} = useLocalize(); const policyName = policy?.name ?? ''; - console.log(policy); return ( Date: Tue, 27 Feb 2024 17:12:23 +0300 Subject: [PATCH 030/170] use policy members --- .../workspace/workflows/WorkspaceWorkflowsApproverPage.tsx | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/pages/workspace/workflows/WorkspaceWorkflowsApproverPage.tsx b/src/pages/workspace/workflows/WorkspaceWorkflowsApproverPage.tsx index fdba10dd324c..4b6493e6e31d 100644 --- a/src/pages/workspace/workflows/WorkspaceWorkflowsApproverPage.tsx +++ b/src/pages/workspace/workflows/WorkspaceWorkflowsApproverPage.tsx @@ -7,9 +7,10 @@ import withPolicy, {WithPolicyOnyxProps} from '@pages/workspace/withPolicy'; type WorkspaceWorkflowsApproverPageProps = WithPolicyOnyxProps; -function WorkspaceWorkflowsApproverPage({policy}: WorkspaceWorkflowsApproverPageProps) { +function WorkspaceWorkflowsApproverPage({policy, policyMembers}: WorkspaceWorkflowsApproverPageProps) { const {translate} = useLocalize(); const policyName = policy?.name ?? ''; + console.log(policy, policyMembers); return ( Date: Tue, 27 Feb 2024 22:38:48 +0800 Subject: [PATCH 031/170] only bold user display name when it's unread --- src/components/SelectionList/UserListItem.tsx | 2 +- src/components/SelectionList/types.ts | 3 +++ src/pages/SearchPage/index.js | 2 +- 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/src/components/SelectionList/UserListItem.tsx b/src/components/SelectionList/UserListItem.tsx index 759c29013b5d..2cff4645b778 100644 --- a/src/components/SelectionList/UserListItem.tsx +++ b/src/components/SelectionList/UserListItem.tsx @@ -86,7 +86,7 @@ function UserListItem({ textStyles={[ styles.optionDisplayName, isFocused ? styles.sidebarLinkActiveText : styles.sidebarLinkText, - styles.sidebarLinkTextBold, + item.isBold !== false && styles.sidebarLinkTextBold, styles.pre, item.alternateText ? styles.mb1 : null, ]} diff --git a/src/components/SelectionList/types.ts b/src/components/SelectionList/types.ts index 59f6b14cfb1f..9f92c1aaead4 100644 --- a/src/components/SelectionList/types.ts +++ b/src/components/SelectionList/types.ts @@ -55,6 +55,9 @@ type ListItem = { /** Whether this option is disabled for selection */ isDisabled?: boolean; + /** List title is bold by default. Use this props to customize it */ + isBold?: boolean; + /** User accountID */ accountID?: number | null; diff --git a/src/pages/SearchPage/index.js b/src/pages/SearchPage/index.js index 0c17e58837c1..da58f1c8edcf 100644 --- a/src/pages/SearchPage/index.js +++ b/src/pages/SearchPage/index.js @@ -93,7 +93,7 @@ function SearchPage({betas, reports, isSearchingForReports}) { if (recentReports.length > 0) { newSections.push({ - data: recentReports, + data: recentReports.map((report) => ({...report, isBold: report.isUnread})), shouldShow: true, indexOffset, }); From 2093642cebda7ef2ecf1f03958b2390463557f6b Mon Sep 17 00:00:00 2001 From: Bernhard Owen Josephus Date: Tue, 27 Feb 2024 22:48:30 +0800 Subject: [PATCH 032/170] use underscore map --- src/pages/SearchPage/index.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/pages/SearchPage/index.js b/src/pages/SearchPage/index.js index da58f1c8edcf..1957b19abeb6 100644 --- a/src/pages/SearchPage/index.js +++ b/src/pages/SearchPage/index.js @@ -2,6 +2,7 @@ import PropTypes from 'prop-types'; import React, {useEffect, useMemo, useState} from 'react'; import {View} from 'react-native'; import {withOnyx} from 'react-native-onyx'; +import _ from 'underscore'; import HeaderWithBackButton from '@components/HeaderWithBackButton'; import {usePersonalDetails} from '@components/OnyxProvider'; import ScreenWrapper from '@components/ScreenWrapper'; @@ -93,7 +94,7 @@ function SearchPage({betas, reports, isSearchingForReports}) { if (recentReports.length > 0) { newSections.push({ - data: recentReports.map((report) => ({...report, isBold: report.isUnread})), + data: _.map(recentReports, (report) => ({...report, isBold: report.isUnread})), shouldShow: true, indexOffset, }); From f215f03e6abdc47821852722c63ba54a5ce27c96 Mon Sep 17 00:00:00 2001 From: Rushat Gabhane Date: Tue, 27 Feb 2024 19:24:04 +0300 Subject: [PATCH 033/170] add settings to routes as per doc --- src/ROUTES.ts | 4 +- .../WorkspaceWorkflowsApproverPage.tsx | 39 ++++++++++++++++++- 2 files changed, 40 insertions(+), 3 deletions(-) diff --git a/src/ROUTES.ts b/src/ROUTES.ts index 8ae3125e728d..6f3034dca4c2 100644 --- a/src/ROUTES.ts +++ b/src/ROUTES.ts @@ -487,8 +487,8 @@ const ROUTES = { getRoute: (policyID: string) => `workspace/${policyID}/workflows` as const, }, WORKSPACE_WORKFLOWS_APPROVER: { - route: 'workspace/:policyID/workflows/approver', - getRoute: (policyId: string) => `workspace/${policyId}/workflows/approver` as const, + route: 'workspace/:policyID/settings/workflows/approver', + getRoute: (policyId: string) => `workspace/${policyId}/settings/workflows/approver` as const, }, WORKSPACE_CARD: { route: 'workspace/:policyID/card', diff --git a/src/pages/workspace/workflows/WorkspaceWorkflowsApproverPage.tsx b/src/pages/workspace/workflows/WorkspaceWorkflowsApproverPage.tsx index 4b6493e6e31d..5fd5958cc6d1 100644 --- a/src/pages/workspace/workflows/WorkspaceWorkflowsApproverPage.tsx +++ b/src/pages/workspace/workflows/WorkspaceWorkflowsApproverPage.tsx @@ -1,17 +1,43 @@ -import React from 'react'; +import React, {useMemo, useState} from 'react'; import HeaderWithBackButton from '@components/HeaderWithBackButton'; import ScreenWrapper from '@components/ScreenWrapper'; +import SelectionList from '@components/SelectionList'; +import UserListItem from '@components/SelectionList/UserListItem'; import useLocalize from '@hooks/useLocalize'; import Navigation from '@libs/Navigation/Navigation'; +import * as OptionsListUtils from '@libs/OptionsListUtils'; import withPolicy, {WithPolicyOnyxProps} from '@pages/workspace/withPolicy'; +import type {Section} from '@components/SelectionList/types'; +import useNetwork from '@hooks/useNetwork'; +import useThemeStyles from '@hooks/useThemeStyles'; +import * as DeviceCapabilities from '@libs/DeviceCapabilities'; +import * as LoginUtils from '@libs/LoginUtils'; +import type {MemberForList} from '@libs/OptionsListUtils'; +import {parsePhoneNumber} from '@libs/PhoneNumber'; +import * as PolicyUtils from '@libs/PolicyUtils'; +import type {OptionData} from '@libs/ReportUtils'; +import type {SettingsNavigatorParamList} from '@navigation/types'; +import * as Policy from '@userActions/Policy'; +import { SectionListData } from 'react-native'; type WorkspaceWorkflowsApproverPageProps = WithPolicyOnyxProps; +type MembersSection = SectionListData>; function WorkspaceWorkflowsApproverPage({policy, policyMembers}: WorkspaceWorkflowsApproverPageProps) { const {translate} = useLocalize(); const policyName = policy?.name ?? ''; + const [searchTerm, setSearchTerm] = useState(''); + const headerMessage = useMemo(() => { + const searchValue = searchTerm.trim().toLowerCase(); + return OptionsListUtils.getHeaderMessage(true, false, searchValue); + }, [translate, searchTerm, policyName]); + console.log(policy, policyMembers); + const sections: MembersSection[] = () => { + + } + return ( + {}} + // initiallyFocusedOptionKey={0} + showScrollIndicator + /> ); } From 353d350dd0d2d3f4697886b37e04b1e932d8c703 Mon Sep 17 00:00:00 2001 From: Rushat Gabhane Date: Tue, 27 Feb 2024 21:03:22 +0300 Subject: [PATCH 034/170] get personal details for policy members --- .../WorkspaceWorkflowsApproverPage.tsx | 49 ++++++++++++++----- 1 file changed, 36 insertions(+), 13 deletions(-) diff --git a/src/pages/workspace/workflows/WorkspaceWorkflowsApproverPage.tsx b/src/pages/workspace/workflows/WorkspaceWorkflowsApproverPage.tsx index 5fd5958cc6d1..352c51132a7b 100644 --- a/src/pages/workspace/workflows/WorkspaceWorkflowsApproverPage.tsx +++ b/src/pages/workspace/workflows/WorkspaceWorkflowsApproverPage.tsx @@ -1,29 +1,41 @@ import React, {useMemo, useState} from 'react'; +import {SectionListData} from 'react-native'; +import {OnyxEntry, withOnyx} from 'react-native-onyx'; import HeaderWithBackButton from '@components/HeaderWithBackButton'; import ScreenWrapper from '@components/ScreenWrapper'; import SelectionList from '@components/SelectionList'; +import type {Section} from '@components/SelectionList/types'; import UserListItem from '@components/SelectionList/UserListItem'; import useLocalize from '@hooks/useLocalize'; -import Navigation from '@libs/Navigation/Navigation'; -import * as OptionsListUtils from '@libs/OptionsListUtils'; -import withPolicy, {WithPolicyOnyxProps} from '@pages/workspace/withPolicy'; -import type {Section} from '@components/SelectionList/types'; import useNetwork from '@hooks/useNetwork'; import useThemeStyles from '@hooks/useThemeStyles'; +import compose from '@libs/compose'; import * as DeviceCapabilities from '@libs/DeviceCapabilities'; import * as LoginUtils from '@libs/LoginUtils'; +import Navigation from '@libs/Navigation/Navigation'; +import * as OptionsListUtils from '@libs/OptionsListUtils'; import type {MemberForList} from '@libs/OptionsListUtils'; +import * as PersonalDetailsUtils from '@libs/PersonalDetailsUtils'; import {parsePhoneNumber} from '@libs/PhoneNumber'; import * as PolicyUtils from '@libs/PolicyUtils'; import type {OptionData} from '@libs/ReportUtils'; import type {SettingsNavigatorParamList} from '@navigation/types'; +import withPolicy, {WithPolicyProps} from '@pages/workspace/withPolicy'; import * as Policy from '@userActions/Policy'; -import { SectionListData } from 'react-native'; +import ONYXKEYS from '@src/ONYXKEYS'; +import {Beta, InvitedEmailsToAccountIDs, PersonalDetailsList} from '@src/types/onyx'; +import withPolicyAndFullscreenLoading from '../withPolicyAndFullscreenLoading'; +import useCurrentUserPersonalDetails from '@hooks/useCurrentUserPersonalDetails'; -type WorkspaceWorkflowsApproverPageProps = WithPolicyOnyxProps; +type WorkspaceWorkflowsApproverPageOnyxProps = { + /** All of the personal details for everyone */ + personalDetails: OnyxEntry; +}; + +type WorkspaceWorkflowsApproverPageProps = WorkspaceWorkflowsApproverPageOnyxProps & WithPolicyProps; type MembersSection = SectionListData>; -function WorkspaceWorkflowsApproverPage({policy, policyMembers}: WorkspaceWorkflowsApproverPageProps) { +function WorkspaceWorkflowsApproverPage({policy, policyMembers, personalDetails}: WorkspaceWorkflowsApproverPageProps) { const {translate} = useLocalize(); const policyName = policy?.name ?? ''; const [searchTerm, setSearchTerm] = useState(''); @@ -31,12 +43,16 @@ function WorkspaceWorkflowsApproverPage({policy, policyMembers}: WorkspaceWorkfl const searchValue = searchTerm.trim().toLowerCase(); return OptionsListUtils.getHeaderMessage(true, false, searchValue); }, [translate, searchTerm, policyName]); + const currentUserPersonalDetails = useCurrentUserPersonalDetails(); + + const policyMemberAccountIDs = Object.keys(policyMembers ?? {}).map((accountId) => parseInt(accountId)); + const workspaceMembers = PersonalDetailsUtils.getPersonalDetailsByIDs(policyMemberAccountIDs, currentUserPersonalDetails.accountID); + console.log('[workspaceMembers]: ', workspaceMembers); - console.log(policy, policyMembers); + // const sections: MembersSection[] = () => { + // const sectionsArr: MembersSection[] = []; - const sections: MembersSection[] = () => { - - } + // }; return ( ({ + personalDetails: { + key: ONYXKEYS.PERSONAL_DETAILS_LIST, + }, + }), + withPolicy, +)(WorkspaceWorkflowsApproverPage); From c65636b66b692063e2bf739e28ac911ee7e32062 Mon Sep 17 00:00:00 2001 From: Rushat Gabhane Date: Wed, 28 Feb 2024 04:54:11 +0300 Subject: [PATCH 035/170] get personal details for policy members --- src/libs/OptionsListUtils.ts | 2 +- .../WorkspaceWorkflowsApproverPage.tsx | 31 ++++++++++--------- 2 files changed, 17 insertions(+), 16 deletions(-) diff --git a/src/libs/OptionsListUtils.ts b/src/libs/OptionsListUtils.ts index 3d11795f5452..cea2616651c6 100644 --- a/src/libs/OptionsListUtils.ts +++ b/src/libs/OptionsListUtils.ts @@ -1874,7 +1874,7 @@ function formatMemberForList(member: ReportUtils.OptionData): MemberForList { login: member.login ?? '', icons: member.icons, pendingAction: member.pendingAction, - reportID: member.reportID, + reportID: member.reportID ?? '', }; } diff --git a/src/pages/workspace/workflows/WorkspaceWorkflowsApproverPage.tsx b/src/pages/workspace/workflows/WorkspaceWorkflowsApproverPage.tsx index 352c51132a7b..c550b9ca3171 100644 --- a/src/pages/workspace/workflows/WorkspaceWorkflowsApproverPage.tsx +++ b/src/pages/workspace/workflows/WorkspaceWorkflowsApproverPage.tsx @@ -1,11 +1,13 @@ +import Str from 'expensify-common/lib/str'; import React, {useMemo, useState} from 'react'; import {SectionListData} from 'react-native'; import {OnyxEntry, withOnyx} from 'react-native-onyx'; import HeaderWithBackButton from '@components/HeaderWithBackButton'; import ScreenWrapper from '@components/ScreenWrapper'; import SelectionList from '@components/SelectionList'; -import type {Section} from '@components/SelectionList/types'; +import type {ListItem, Section} from '@components/SelectionList/types'; import UserListItem from '@components/SelectionList/UserListItem'; +import useCurrentUserPersonalDetails from '@hooks/useCurrentUserPersonalDetails'; import useLocalize from '@hooks/useLocalize'; import useNetwork from '@hooks/useNetwork'; import useThemeStyles from '@hooks/useThemeStyles'; @@ -23,17 +25,17 @@ import type {SettingsNavigatorParamList} from '@navigation/types'; import withPolicy, {WithPolicyProps} from '@pages/workspace/withPolicy'; import * as Policy from '@userActions/Policy'; import ONYXKEYS from '@src/ONYXKEYS'; -import {Beta, InvitedEmailsToAccountIDs, PersonalDetailsList} from '@src/types/onyx'; +import {Beta, InvitedEmailsToAccountIDs, PersonalDetails, PersonalDetailsList} from '@src/types/onyx'; import withPolicyAndFullscreenLoading from '../withPolicyAndFullscreenLoading'; -import useCurrentUserPersonalDetails from '@hooks/useCurrentUserPersonalDetails'; +import type {WithPolicyAndFullscreenLoadingProps} from '../withPolicyAndFullscreenLoading'; type WorkspaceWorkflowsApproverPageOnyxProps = { /** All of the personal details for everyone */ personalDetails: OnyxEntry; }; -type WorkspaceWorkflowsApproverPageProps = WorkspaceWorkflowsApproverPageOnyxProps & WithPolicyProps; -type MembersSection = SectionListData>; +type WorkspaceWorkflowsApproverPageProps = WorkspaceWorkflowsApproverPageOnyxProps & WithPolicyAndFullscreenLoadingProps; +type MembersSection = SectionListData>; function WorkspaceWorkflowsApproverPage({policy, policyMembers, personalDetails}: WorkspaceWorkflowsApproverPageProps) { const {translate} = useLocalize(); @@ -43,16 +45,15 @@ function WorkspaceWorkflowsApproverPage({policy, policyMembers, personalDetails} const searchValue = searchTerm.trim().toLowerCase(); return OptionsListUtils.getHeaderMessage(true, false, searchValue); }, [translate, searchTerm, policyName]); - const currentUserPersonalDetails = useCurrentUserPersonalDetails(); - const policyMemberAccountIDs = Object.keys(policyMembers ?? {}).map((accountId) => parseInt(accountId)); - const workspaceMembers = PersonalDetailsUtils.getPersonalDetailsByIDs(policyMemberAccountIDs, currentUserPersonalDetails.accountID); - console.log('[workspaceMembers]: ', workspaceMembers); + const policyMemberAccountIDs = Object.keys(policyMembers ?? {}).map((accountId) => accountId); + const policyMemberDetails = policyMemberAccountIDs.filter((accountID) => !!personalDetails?.[accountID]).map((accountID) => personalDetails?.[accountID]); - // const sections: MembersSection[] = () => { - // const sectionsArr: MembersSection[] = []; + const sections: MembersSection[] = useMemo(() => { + let result: MembersSection[] = []; - // }; + return result; + }, [personalDetails, searchTerm, translate]); return ( Date: Wed, 28 Feb 2024 06:35:11 +0300 Subject: [PATCH 036/170] add check for approver --- .../WorkspaceWorkflowsApproverPage.tsx | 86 ++++++++++++++----- 1 file changed, 65 insertions(+), 21 deletions(-) diff --git a/src/pages/workspace/workflows/WorkspaceWorkflowsApproverPage.tsx b/src/pages/workspace/workflows/WorkspaceWorkflowsApproverPage.tsx index c550b9ca3171..44a2ec519fe8 100644 --- a/src/pages/workspace/workflows/WorkspaceWorkflowsApproverPage.tsx +++ b/src/pages/workspace/workflows/WorkspaceWorkflowsApproverPage.tsx @@ -1,31 +1,26 @@ -import Str from 'expensify-common/lib/str'; import React, {useMemo, useState} from 'react'; -import {SectionListData} from 'react-native'; import {OnyxEntry, withOnyx} from 'react-native-onyx'; +import Badge from '@components/Badge'; import HeaderWithBackButton from '@components/HeaderWithBackButton'; import ScreenWrapper from '@components/ScreenWrapper'; import SelectionList from '@components/SelectionList'; -import type {ListItem, Section} from '@components/SelectionList/types'; +import type {ListItem} from '@components/SelectionList/types'; import UserListItem from '@components/SelectionList/UserListItem'; -import useCurrentUserPersonalDetails from '@hooks/useCurrentUserPersonalDetails'; import useLocalize from '@hooks/useLocalize'; import useNetwork from '@hooks/useNetwork'; +import useStyleUtils from '@hooks/useStyleUtils'; import useThemeStyles from '@hooks/useThemeStyles'; import compose from '@libs/compose'; -import * as DeviceCapabilities from '@libs/DeviceCapabilities'; -import * as LoginUtils from '@libs/LoginUtils'; +import {formatPhoneNumber} from '@libs/LocalePhoneNumber'; +import Log from '@libs/Log'; import Navigation from '@libs/Navigation/Navigation'; import * as OptionsListUtils from '@libs/OptionsListUtils'; -import type {MemberForList} from '@libs/OptionsListUtils'; import * as PersonalDetailsUtils from '@libs/PersonalDetailsUtils'; -import {parsePhoneNumber} from '@libs/PhoneNumber'; -import * as PolicyUtils from '@libs/PolicyUtils'; -import type {OptionData} from '@libs/ReportUtils'; -import type {SettingsNavigatorParamList} from '@navigation/types'; -import withPolicy, {WithPolicyProps} from '@pages/workspace/withPolicy'; -import * as Policy from '@userActions/Policy'; +import * as UserUtils from '@libs/UserUtils'; +import CONST from '@src/CONST'; import ONYXKEYS from '@src/ONYXKEYS'; -import {Beta, InvitedEmailsToAccountIDs, PersonalDetails, PersonalDetailsList} from '@src/types/onyx'; +import {PersonalDetailsList, PolicyMember} from '@src/types/onyx'; +import {isEmptyObject} from '@src/types/utils/EmptyObject'; import withPolicyAndFullscreenLoading from '../withPolicyAndFullscreenLoading'; import type {WithPolicyAndFullscreenLoadingProps} from '../withPolicyAndFullscreenLoading'; @@ -35,25 +30,74 @@ type WorkspaceWorkflowsApproverPageOnyxProps = { }; type WorkspaceWorkflowsApproverPageProps = WorkspaceWorkflowsApproverPageOnyxProps & WithPolicyAndFullscreenLoadingProps; -type MembersSection = SectionListData>; +type MemberOption = Omit & {accountID: number}; function WorkspaceWorkflowsApproverPage({policy, policyMembers, personalDetails}: WorkspaceWorkflowsApproverPageProps) { const {translate} = useLocalize(); const policyName = policy?.name ?? ''; const [searchTerm, setSearchTerm] = useState(''); + const {isOffline} = useNetwork(); + const styles = useThemeStyles(); + const StyleUtils = useStyleUtils(); + const headerMessage = useMemo(() => { const searchValue = searchTerm.trim().toLowerCase(); return OptionsListUtils.getHeaderMessage(true, false, searchValue); }, [translate, searchTerm, policyName]); - const policyMemberAccountIDs = Object.keys(policyMembers ?? {}).map((accountId) => accountId); - const policyMemberDetails = policyMemberAccountIDs.filter((accountID) => !!personalDetails?.[accountID]).map((accountID) => personalDetails?.[accountID]); + const isDeletedPolicyMember = (policyMember: PolicyMember): boolean => + !isOffline && policyMember.pendingAction === CONST.RED_BRICK_ROAD_PENDING_ACTION.DELETE && isEmptyObject(policyMember.errors); + + const policyUsers: MemberOption[] = useMemo(() => { + let result: MemberOption[] = []; + Object.entries(policyMembers ?? {}).forEach(([accountIDKey, policyMember]) => { + const accountID = Number(accountIDKey); + if (isDeletedPolicyMember(policyMember)) { + return; + } + + const details = personalDetails?.[accountID]; + if (!details) { + Log.hmmm(`[WorkspaceMembersPage] no personal details found for policy member with accountID: ${accountID}`); + return; + } + + const isOwner = policy?.owner === details.login; + const isAdmin = policyMember.role === CONST.POLICY.ROLE.ADMIN; - const sections: MembersSection[] = useMemo(() => { - let result: MembersSection[] = []; + let roleBadge = null; + if (isOwner || isAdmin) { + roleBadge = ( + + ); + } + result.push({ + keyForList: accountIDKey, + accountID, + isSelected: policy?.approver === details.login, + isDisabled: policyMember.pendingAction === CONST.RED_BRICK_ROAD_PENDING_ACTION.DELETE || !isEmptyObject(policyMember.errors), + text: formatPhoneNumber(PersonalDetailsUtils.getDisplayNameOrDefault(details)), + alternateText: formatPhoneNumber(details?.login ?? ''), + rightElement: roleBadge, + icons: [ + { + source: UserUtils.getAvatar(details.avatar, accountID), + name: formatPhoneNumber(details?.login ?? ''), + type: CONST.ICON_TYPE_AVATAR, + id: accountID, + }, + ], + errors: policyMember.errors, + pendingAction: policyMember.pendingAction, + }); + }); return result; - }, [personalDetails, searchTerm, translate]); + }, [personalDetails, policyMembers, searchTerm, translate]); return ( Date: Wed, 28 Feb 2024 07:07:03 +0300 Subject: [PATCH 037/170] add all section --- .../workspace/workflows/WorkspaceWorkflowsApproverPage.tsx | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/pages/workspace/workflows/WorkspaceWorkflowsApproverPage.tsx b/src/pages/workspace/workflows/WorkspaceWorkflowsApproverPage.tsx index 44a2ec519fe8..0c8c9679bc88 100644 --- a/src/pages/workspace/workflows/WorkspaceWorkflowsApproverPage.tsx +++ b/src/pages/workspace/workflows/WorkspaceWorkflowsApproverPage.tsx @@ -1,10 +1,11 @@ import React, {useMemo, useState} from 'react'; +import {SectionListData} from 'react-native'; import {OnyxEntry, withOnyx} from 'react-native-onyx'; import Badge from '@components/Badge'; import HeaderWithBackButton from '@components/HeaderWithBackButton'; import ScreenWrapper from '@components/ScreenWrapper'; import SelectionList from '@components/SelectionList'; -import type {ListItem} from '@components/SelectionList/types'; +import type {ListItem, Section} from '@components/SelectionList/types'; import UserListItem from '@components/SelectionList/UserListItem'; import useLocalize from '@hooks/useLocalize'; import useNetwork from '@hooks/useNetwork'; From 1e4e5cb6848a34754d45f9cf346a5862939005a5 Mon Sep 17 00:00:00 2001 From: Rushat Gabhane Date: Wed, 28 Feb 2024 07:07:11 +0300 Subject: [PATCH 038/170] add all section --- src/pages/workspace/workflows/WorkspaceWorkflowsApproverPage.tsx | 1 + 1 file changed, 1 insertion(+) diff --git a/src/pages/workspace/workflows/WorkspaceWorkflowsApproverPage.tsx b/src/pages/workspace/workflows/WorkspaceWorkflowsApproverPage.tsx index 0c8c9679bc88..0969d79d69eb 100644 --- a/src/pages/workspace/workflows/WorkspaceWorkflowsApproverPage.tsx +++ b/src/pages/workspace/workflows/WorkspaceWorkflowsApproverPage.tsx @@ -32,6 +32,7 @@ type WorkspaceWorkflowsApproverPageOnyxProps = { type WorkspaceWorkflowsApproverPageProps = WorkspaceWorkflowsApproverPageOnyxProps & WithPolicyAndFullscreenLoadingProps; type MemberOption = Omit & {accountID: number}; +type MembersSection = SectionListData>; function WorkspaceWorkflowsApproverPage({policy, policyMembers, personalDetails}: WorkspaceWorkflowsApproverPageProps) { const {translate} = useLocalize(); From 4e0d42b8e5c1ea77cb441a00a374749fa7943040 Mon Sep 17 00:00:00 2001 From: Rushat Gabhane Date: Wed, 28 Feb 2024 07:07:17 +0300 Subject: [PATCH 039/170] add all section --- .../workspace/workflows/WorkspaceWorkflowsApproverPage.tsx | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/pages/workspace/workflows/WorkspaceWorkflowsApproverPage.tsx b/src/pages/workspace/workflows/WorkspaceWorkflowsApproverPage.tsx index 0969d79d69eb..7a33719f1d11 100644 --- a/src/pages/workspace/workflows/WorkspaceWorkflowsApproverPage.tsx +++ b/src/pages/workspace/workflows/WorkspaceWorkflowsApproverPage.tsx @@ -50,8 +50,11 @@ function WorkspaceWorkflowsApproverPage({policy, policyMembers, personalDetails} const isDeletedPolicyMember = (policyMember: PolicyMember): boolean => !isOffline && policyMember.pendingAction === CONST.RED_BRICK_ROAD_PENDING_ACTION.DELETE && isEmptyObject(policyMember.errors); - const policyUsers: MemberOption[] = useMemo(() => { - let result: MemberOption[] = []; + const sections: MembersSection[] = useMemo(() => { + let sectionsArr: MembersSection[] = []; + + let policyUsersSection: MemberOption[] = []; + Object.entries(policyMembers ?? {}).forEach(([accountIDKey, policyMember]) => { const accountID = Number(accountIDKey); if (isDeletedPolicyMember(policyMember)) { From 97dd3a2fa6bc1062980ffd7ee2c0d4afcba0a29e Mon Sep 17 00:00:00 2001 From: Rushat Gabhane Date: Wed, 28 Feb 2024 07:07:39 +0300 Subject: [PATCH 040/170] add all section 0 offset --- .../workspace/workflows/WorkspaceWorkflowsApproverPage.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pages/workspace/workflows/WorkspaceWorkflowsApproverPage.tsx b/src/pages/workspace/workflows/WorkspaceWorkflowsApproverPage.tsx index 7a33719f1d11..4c396accf373 100644 --- a/src/pages/workspace/workflows/WorkspaceWorkflowsApproverPage.tsx +++ b/src/pages/workspace/workflows/WorkspaceWorkflowsApproverPage.tsx @@ -81,7 +81,7 @@ function WorkspaceWorkflowsApproverPage({policy, policyMembers, personalDetails} ); } - result.push({ + policyUsersSection.push({ keyForList: accountIDKey, accountID, isSelected: policy?.approver === details.login, From 54f846e1d85305dc40e981f7ec1668dc88684933 Mon Sep 17 00:00:00 2001 From: Rushat Gabhane Date: Wed, 28 Feb 2024 07:07:46 +0300 Subject: [PATCH 041/170] add all section 0 offset --- .../workflows/WorkspaceWorkflowsApproverPage.tsx | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/pages/workspace/workflows/WorkspaceWorkflowsApproverPage.tsx b/src/pages/workspace/workflows/WorkspaceWorkflowsApproverPage.tsx index 4c396accf373..1a0d507e15fa 100644 --- a/src/pages/workspace/workflows/WorkspaceWorkflowsApproverPage.tsx +++ b/src/pages/workspace/workflows/WorkspaceWorkflowsApproverPage.tsx @@ -101,8 +101,16 @@ function WorkspaceWorkflowsApproverPage({policy, policyMembers, personalDetails} pendingAction: policyMember.pendingAction, }); }); - return result; - }, [personalDetails, policyMembers, searchTerm, translate]); + + sectionsArr.push({ + title: translate('common.all'), + data: policyUsersSection, + shouldShow: true, + indexOffset: 0, + }); + + return sectionsArr; + }, [personalDetails, policyMembers, searchTerm, translate, policy?.approver]); return ( Date: Wed, 28 Feb 2024 07:07:57 +0300 Subject: [PATCH 042/170] add all section 0 offset --- .../workspace/workflows/WorkspaceWorkflowsApproverPage.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pages/workspace/workflows/WorkspaceWorkflowsApproverPage.tsx b/src/pages/workspace/workflows/WorkspaceWorkflowsApproverPage.tsx index 1a0d507e15fa..ebec25863444 100644 --- a/src/pages/workspace/workflows/WorkspaceWorkflowsApproverPage.tsx +++ b/src/pages/workspace/workflows/WorkspaceWorkflowsApproverPage.tsx @@ -123,7 +123,7 @@ function WorkspaceWorkflowsApproverPage({policy, policyMembers, personalDetails} onBackButtonPress={Navigation.goBack} /> Date: Wed, 28 Feb 2024 07:13:29 +0300 Subject: [PATCH 043/170] add approver section --- src/pages/workspace/workflows/WorkspaceWorkflowsApproverPage.tsx | 1 + 1 file changed, 1 insertion(+) diff --git a/src/pages/workspace/workflows/WorkspaceWorkflowsApproverPage.tsx b/src/pages/workspace/workflows/WorkspaceWorkflowsApproverPage.tsx index ebec25863444..779cf84d1b0b 100644 --- a/src/pages/workspace/workflows/WorkspaceWorkflowsApproverPage.tsx +++ b/src/pages/workspace/workflows/WorkspaceWorkflowsApproverPage.tsx @@ -54,6 +54,7 @@ function WorkspaceWorkflowsApproverPage({policy, policyMembers, personalDetails} let sectionsArr: MembersSection[] = []; let policyUsersSection: MemberOption[] = []; + let approverSection: MemberOption[] = []; Object.entries(policyMembers ?? {}).forEach(([accountIDKey, policyMember]) => { const accountID = Number(accountIDKey); From 06399aa4c6adb82b5cb7caf58a9d34951a5179fc Mon Sep 17 00:00:00 2001 From: Rushat Gabhane Date: Wed, 28 Feb 2024 07:13:36 +0300 Subject: [PATCH 044/170] add approver section --- .../workspace/workflows/WorkspaceWorkflowsApproverPage.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pages/workspace/workflows/WorkspaceWorkflowsApproverPage.tsx b/src/pages/workspace/workflows/WorkspaceWorkflowsApproverPage.tsx index 779cf84d1b0b..acc2e84183ba 100644 --- a/src/pages/workspace/workflows/WorkspaceWorkflowsApproverPage.tsx +++ b/src/pages/workspace/workflows/WorkspaceWorkflowsApproverPage.tsx @@ -82,7 +82,7 @@ function WorkspaceWorkflowsApproverPage({policy, policyMembers, personalDetails} ); } - policyUsersSection.push({ + const formattedMember = { keyForList: accountIDKey, accountID, isSelected: policy?.approver === details.login, From eeaae976c2f5ec3d2d6635af8345a4b553bc55c5 Mon Sep 17 00:00:00 2001 From: Rushat Gabhane Date: Wed, 28 Feb 2024 07:13:42 +0300 Subject: [PATCH 045/170] add approver section --- .../WorkspaceWorkflowsApproverPage.tsx | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/src/pages/workspace/workflows/WorkspaceWorkflowsApproverPage.tsx b/src/pages/workspace/workflows/WorkspaceWorkflowsApproverPage.tsx index acc2e84183ba..fed693df1566 100644 --- a/src/pages/workspace/workflows/WorkspaceWorkflowsApproverPage.tsx +++ b/src/pages/workspace/workflows/WorkspaceWorkflowsApproverPage.tsx @@ -100,14 +100,27 @@ function WorkspaceWorkflowsApproverPage({policy, policyMembers, personalDetails} ], errors: policyMember.errors, pendingAction: policyMember.pendingAction, - }); + }; + + if (policy?.approver === details.login) { + approverSection.push(formattedMember); + } else { + policyUsersSection.push(formattedMember); + } + }); + + sectionsArr.push({ + title: undefined, + data: approverSection, + shouldShow: true, + indexOffset: 0, }); sectionsArr.push({ title: translate('common.all'), data: policyUsersSection, shouldShow: true, - indexOffset: 0, + indexOffset: 1, }); return sectionsArr; From 8a058da01cd0aa610a043d21d4c28b73c6783ffa Mon Sep 17 00:00:00 2001 From: Rushat Gabhane Date: Wed, 28 Feb 2024 07:22:26 +0300 Subject: [PATCH 046/170] fix index offset for all --- .../workspace/workflows/WorkspaceWorkflowsApproverPage.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pages/workspace/workflows/WorkspaceWorkflowsApproverPage.tsx b/src/pages/workspace/workflows/WorkspaceWorkflowsApproverPage.tsx index fed693df1566..c227f39fbe29 100644 --- a/src/pages/workspace/workflows/WorkspaceWorkflowsApproverPage.tsx +++ b/src/pages/workspace/workflows/WorkspaceWorkflowsApproverPage.tsx @@ -120,7 +120,7 @@ function WorkspaceWorkflowsApproverPage({policy, policyMembers, personalDetails} title: translate('common.all'), data: policyUsersSection, shouldShow: true, - indexOffset: 1, + indexOffset: approverSection.length, }); return sectionsArr; From 4c629b6d15dbfc389c24ce200a5562b7a027687d Mon Sep 17 00:00:00 2001 From: Rushat Gabhane Date: Wed, 28 Feb 2024 08:01:38 +0300 Subject: [PATCH 047/170] make api call on approver select --- .../workflows/WorkspaceWorkflowsApproverPage.tsx | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/pages/workspace/workflows/WorkspaceWorkflowsApproverPage.tsx b/src/pages/workspace/workflows/WorkspaceWorkflowsApproverPage.tsx index c227f39fbe29..8f684f30c8c6 100644 --- a/src/pages/workspace/workflows/WorkspaceWorkflowsApproverPage.tsx +++ b/src/pages/workspace/workflows/WorkspaceWorkflowsApproverPage.tsx @@ -18,6 +18,7 @@ import Navigation from '@libs/Navigation/Navigation'; import * as OptionsListUtils from '@libs/OptionsListUtils'; import * as PersonalDetailsUtils from '@libs/PersonalDetailsUtils'; import * as UserUtils from '@libs/UserUtils'; +import * as Policy from '@userActions/Policy'; import CONST from '@src/CONST'; import ONYXKEYS from '@src/ONYXKEYS'; import {PersonalDetailsList, PolicyMember} from '@src/types/onyx'; @@ -126,6 +127,13 @@ function WorkspaceWorkflowsApproverPage({policy, policyMembers, personalDetails} return sectionsArr; }, [personalDetails, policyMembers, searchTerm, translate, policy?.approver]); + const setPolicyApprover = (member: MemberOption) => { + if (!policy) { + return; + } + Policy.setWorkspaceApprover(policy.id, member.accountID); + }; + return ( {}} + onSelectRow={setPolicyApprover} // initiallyFocusedOptionKey={0} showScrollIndicator /> From a9fc40510dd634ec3838324e20fdf84f88a07566 Mon Sep 17 00:00:00 2001 From: Rushat Gabhane Date: Wed, 28 Feb 2024 08:02:01 +0300 Subject: [PATCH 048/170] add set approver action --- src/libs/actions/Policy.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/src/libs/actions/Policy.ts b/src/libs/actions/Policy.ts index 57cd4a6fc071..197a4eebcd49 100644 --- a/src/libs/actions/Policy.ts +++ b/src/libs/actions/Policy.ts @@ -22,6 +22,7 @@ import type { OpenWorkspaceReimburseViewParams, SetWorkspaceApprovalModeParams, SetWorkspaceAutoReportingParams, + SetWorkspaceWorkflowsApproverParams, UpdateWorkspaceAvatarParams, UpdateWorkspaceCustomUnitAndRateParams, UpdateWorkspaceDescriptionParams, From 73b8245ac41fd8f03a1eea993b2b1752fff84118 Mon Sep 17 00:00:00 2001 From: Rushat Gabhane Date: Wed, 28 Feb 2024 08:02:10 +0300 Subject: [PATCH 049/170] add set approver action --- src/libs/actions/Policy.ts | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/src/libs/actions/Policy.ts b/src/libs/actions/Policy.ts index 197a4eebcd49..2f26d6b8b7a4 100644 --- a/src/libs/actions/Policy.ts +++ b/src/libs/actions/Policy.ts @@ -466,6 +466,41 @@ function setWorkspaceApprovalMode(policyID: string, approver: string, approvalMo API.write(WRITE_COMMANDS.SET_WORKSPACE_APPROVAL_MODE, params, {optimisticData, failureData, successData}); } +function setWorkspaceApprover(policyID: string, approverAccountID: number) { + const optimisticData: OnyxUpdate[] = [ + { + onyxMethod: Onyx.METHOD.MERGE, + key: `${ONYXKEYS.COLLECTION.POLICY}${policyID}`, + value: { + pendingFields: {approver: CONST.RED_BRICK_ROAD_PENDING_ACTION.UPDATE}, + }, + }, + ]; + + const failureData: OnyxUpdate[] = [ + { + onyxMethod: Onyx.METHOD.MERGE, + key: `${ONYXKEYS.COLLECTION.POLICY}${policyID}`, + value: { + pendingFields: {approver: null}, + }, + }, + ]; + + const successData: OnyxUpdate[] = [ + { + onyxMethod: Onyx.METHOD.MERGE, + key: `${ONYXKEYS.COLLECTION.POLICY}${policyID}`, + value: { + pendingFields: {approver: null}, + }, + }, + ]; + + const params: SetWorkspaceWorkflowsApproverParams = {policyID, accountID: approverAccountID}; + API.write(WRITE_COMMANDS.SET_WORKSPACE_APPROVER, params, {optimisticData, failureData, successData}); +} + /** * Build optimistic data for removing users from the announcement room */ From 89e42afb15d84b3d0f2850b3cbc3a9677e6f78d2 Mon Sep 17 00:00:00 2001 From: Rushat Gabhane Date: Wed, 28 Feb 2024 08:02:15 +0300 Subject: [PATCH 050/170] add set approver action --- src/libs/actions/Policy.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/src/libs/actions/Policy.ts b/src/libs/actions/Policy.ts index 2f26d6b8b7a4..a66211373af0 100644 --- a/src/libs/actions/Policy.ts +++ b/src/libs/actions/Policy.ts @@ -2256,5 +2256,6 @@ export { setWorkspaceInviteMessageDraft, setWorkspaceAutoReporting, setWorkspaceApprovalMode, + setWorkspaceApprover, updateWorkspaceDescription, }; From 2f46ead4096a4070cf5eaf0527e19bea6d00377a Mon Sep 17 00:00:00 2001 From: Rushat Gabhane Date: Wed, 28 Feb 2024 08:02:58 +0300 Subject: [PATCH 051/170] go back on set approver --- src/pages/workspace/workflows/WorkspaceWorkflowsApproverPage.tsx | 1 + 1 file changed, 1 insertion(+) diff --git a/src/pages/workspace/workflows/WorkspaceWorkflowsApproverPage.tsx b/src/pages/workspace/workflows/WorkspaceWorkflowsApproverPage.tsx index 8f684f30c8c6..c698ea033c40 100644 --- a/src/pages/workspace/workflows/WorkspaceWorkflowsApproverPage.tsx +++ b/src/pages/workspace/workflows/WorkspaceWorkflowsApproverPage.tsx @@ -132,6 +132,7 @@ function WorkspaceWorkflowsApproverPage({policy, policyMembers, personalDetails} return; } Policy.setWorkspaceApprover(policy.id, member.accountID); + Navigation.goBack(); }; return ( From 5a2ed4031781cdc9a2d24a8082405ea79718aff7 Mon Sep 17 00:00:00 2001 From: Rushat Gabhane Date: Wed, 28 Feb 2024 08:03:30 +0300 Subject: [PATCH 052/170] rm comment --- src/pages/workspace/workflows/WorkspaceWorkflowsApproverPage.tsx | 1 - 1 file changed, 1 deletion(-) diff --git a/src/pages/workspace/workflows/WorkspaceWorkflowsApproverPage.tsx b/src/pages/workspace/workflows/WorkspaceWorkflowsApproverPage.tsx index c698ea033c40..a1ea2daffab9 100644 --- a/src/pages/workspace/workflows/WorkspaceWorkflowsApproverPage.tsx +++ b/src/pages/workspace/workflows/WorkspaceWorkflowsApproverPage.tsx @@ -153,7 +153,6 @@ function WorkspaceWorkflowsApproverPage({policy, policyMembers, personalDetails} headerMessage={headerMessage} ListItem={UserListItem} onSelectRow={setPolicyApprover} - // initiallyFocusedOptionKey={0} showScrollIndicator /> From c87b60f14b28da45b6c814e442fab51563c8ada2 Mon Sep 17 00:00:00 2001 From: Bernhard Owen Josephus Date: Wed, 28 Feb 2024 13:05:47 +0800 Subject: [PATCH 053/170] only display the merchant error when the smartscan failed --- src/components/MoneyRequestConfirmationList.js | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/src/components/MoneyRequestConfirmationList.js b/src/components/MoneyRequestConfirmationList.js index df2781d3ea89..dfe1d96b0e5d 100755 --- a/src/components/MoneyRequestConfirmationList.js +++ b/src/components/MoneyRequestConfirmationList.js @@ -282,7 +282,7 @@ function MoneyRequestConfirmationList(props) { }, [props.isEditingSplitBill, props.hasSmartScanFailed, transaction, didConfirmSplit]); const isMerchantEmpty = !props.iouMerchant || props.iouMerchant === CONST.TRANSACTION.PARTIAL_TRANSACTION_MERCHANT; - const shouldDisplayMerchantError = props.isPolicyExpenseChat && !props.isScanRequest && isMerchantEmpty; + const shouldDisplayMerchantError = props.isPolicyExpenseChat && shouldDisplayFieldError && isMerchantEmpty; useEffect(() => { if (shouldDisplayFieldError && didConfirmSplit) { @@ -750,14 +750,8 @@ function MoneyRequestConfirmationList(props) { }} disabled={didConfirm} interactive={!props.isReadOnly} - brickRoadIndicator={ - props.isPolicyExpenseChat && shouldDisplayFieldError && TransactionUtils.isMerchantMissing(transaction) ? CONST.BRICK_ROAD_INDICATOR_STATUS.ERROR : '' - } - error={ - shouldDisplayMerchantError || (props.isPolicyExpenseChat && shouldDisplayFieldError && TransactionUtils.isMerchantMissing(transaction)) - ? translate('common.error.enterMerchant') - : '' - } + brickRoadIndicator={shouldDisplayMerchantError ? CONST.BRICK_ROAD_INDICATOR_STATUS.ERROR : ''} + error={shouldDisplayMerchantError ? translate('common.error.enterMerchant') : ''} /> )} {shouldShowCategories && ( From a88070c78d0938c857bea8a53c7a0a00f03499f2 Mon Sep 17 00:00:00 2001 From: Rushat Gabhane Date: Wed, 28 Feb 2024 08:22:28 +0300 Subject: [PATCH 054/170] fix lint --- .../workflows/WorkspaceWorkflowsApproverPage.tsx | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/pages/workspace/workflows/WorkspaceWorkflowsApproverPage.tsx b/src/pages/workspace/workflows/WorkspaceWorkflowsApproverPage.tsx index a1ea2daffab9..599a0a46d796 100644 --- a/src/pages/workspace/workflows/WorkspaceWorkflowsApproverPage.tsx +++ b/src/pages/workspace/workflows/WorkspaceWorkflowsApproverPage.tsx @@ -21,7 +21,7 @@ import * as UserUtils from '@libs/UserUtils'; import * as Policy from '@userActions/Policy'; import CONST from '@src/CONST'; import ONYXKEYS from '@src/ONYXKEYS'; -import {PersonalDetailsList, PolicyMember} from '@src/types/onyx'; +import type {PersonalDetailsList, PolicyMember} from '@src/types/onyx'; import {isEmptyObject} from '@src/types/utils/EmptyObject'; import withPolicyAndFullscreenLoading from '../withPolicyAndFullscreenLoading'; import type {WithPolicyAndFullscreenLoadingProps} from '../withPolicyAndFullscreenLoading'; @@ -52,10 +52,10 @@ function WorkspaceWorkflowsApproverPage({policy, policyMembers, personalDetails} !isOffline && policyMember.pendingAction === CONST.RED_BRICK_ROAD_PENDING_ACTION.DELETE && isEmptyObject(policyMember.errors); const sections: MembersSection[] = useMemo(() => { - let sectionsArr: MembersSection[] = []; + const sectionsArr: MembersSection[] = []; - let policyUsersSection: MemberOption[] = []; - let approverSection: MemberOption[] = []; + const policyUsersSection: MemberOption[] = []; + const approverSection: MemberOption[] = []; Object.entries(policyMembers ?? {}).forEach(([accountIDKey, policyMember]) => { const accountID = Number(accountIDKey); From 30655d825447969cf2f2bf8850e24673a46e3a74 Mon Sep 17 00:00:00 2001 From: Rushat Gabhane Date: Wed, 28 Feb 2024 10:50:47 +0300 Subject: [PATCH 055/170] rm setworkspace approver command --- src/libs/API/types.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/src/libs/API/types.ts b/src/libs/API/types.ts index ed25278d6121..7a97405ce931 100644 --- a/src/libs/API/types.ts +++ b/src/libs/API/types.ts @@ -10,7 +10,6 @@ type ApiRequest = ValueOf; const WRITE_COMMANDS = { SET_WORKSPACE_AUTO_REPORTING: 'SetWorkspaceAutoReporting', SET_WORKSPACE_APPROVAL_MODE: 'SetWorkspaceApprovalMode', - SET_WORKSPACE_APPROVER: 'SetWorkspaceApprover', DISMISS_REFERRAL_BANNER: 'DismissReferralBanner', UPDATE_PREFERRED_LOCALE: 'UpdatePreferredLocale', OPEN_APP: 'OpenApp', From b894a345a3aca2f051422d0db7e93b08921ac735 Mon Sep 17 00:00:00 2001 From: Rushat Gabhane Date: Wed, 28 Feb 2024 10:50:55 +0300 Subject: [PATCH 056/170] rm setworkspace approver command --- src/libs/API/types.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/src/libs/API/types.ts b/src/libs/API/types.ts index 7a97405ce931..c6fd1154fbf1 100644 --- a/src/libs/API/types.ts +++ b/src/libs/API/types.ts @@ -300,7 +300,6 @@ type WriteCommandParameters = { [WRITE_COMMANDS.ACCEPT_ACH_CONTRACT_FOR_BANK_ACCOUNT]: Parameters.AcceptACHContractForBankAccount; [WRITE_COMMANDS.UPDATE_WORKSPACE_DESCRIPTION]: Parameters.UpdateWorkspaceDescriptionParams; [WRITE_COMMANDS.SET_WORKSPACE_AUTO_REPORTING]: Parameters.SetWorkspaceAutoReportingParams; - [WRITE_COMMANDS.SET_WORKSPACE_APPROVER]: Parameters.SetWorkspaceWorkflowsApproverParams; [WRITE_COMMANDS.SET_WORKSPACE_APPROVAL_MODE]: Parameters.SetWorkspaceApprovalModeParams; [WRITE_COMMANDS.SWITCH_TO_OLD_DOT]: Parameters.SwitchToOldDotParams; }; From 138edadb7949af151195508e958fdebb83a9392e Mon Sep 17 00:00:00 2001 From: Rushat Gabhane Date: Wed, 28 Feb 2024 10:51:02 +0300 Subject: [PATCH 057/170] rm setworkspace approver command --- src/libs/actions/Policy.ts | 35 ----------------------------------- 1 file changed, 35 deletions(-) diff --git a/src/libs/actions/Policy.ts b/src/libs/actions/Policy.ts index 8f4a4c2f3300..b11dd7e44a5d 100644 --- a/src/libs/actions/Policy.ts +++ b/src/libs/actions/Policy.ts @@ -467,41 +467,6 @@ function setWorkspaceApprovalMode(policyID: string, approver: string, approvalMo API.write(WRITE_COMMANDS.SET_WORKSPACE_APPROVAL_MODE, params, {optimisticData, failureData, successData}); } -function setWorkspaceApprover(policyID: string, approverAccountID: number) { - const optimisticData: OnyxUpdate[] = [ - { - onyxMethod: Onyx.METHOD.MERGE, - key: `${ONYXKEYS.COLLECTION.POLICY}${policyID}`, - value: { - pendingFields: {approver: CONST.RED_BRICK_ROAD_PENDING_ACTION.UPDATE}, - }, - }, - ]; - - const failureData: OnyxUpdate[] = [ - { - onyxMethod: Onyx.METHOD.MERGE, - key: `${ONYXKEYS.COLLECTION.POLICY}${policyID}`, - value: { - pendingFields: {approver: null}, - }, - }, - ]; - - const successData: OnyxUpdate[] = [ - { - onyxMethod: Onyx.METHOD.MERGE, - key: `${ONYXKEYS.COLLECTION.POLICY}${policyID}`, - value: { - pendingFields: {approver: null}, - }, - }, - ]; - - const params: SetWorkspaceWorkflowsApproverParams = {policyID, accountID: approverAccountID}; - API.write(WRITE_COMMANDS.SET_WORKSPACE_APPROVER, params, {optimisticData, failureData, successData}); -} - /** * Build optimistic data for removing users from the announcement room */ From af43199502e30fd700f63053f6b652d9dd711648 Mon Sep 17 00:00:00 2001 From: Rushat Gabhane Date: Wed, 28 Feb 2024 10:51:11 +0300 Subject: [PATCH 058/170] rm setworkspace approver command --- src/libs/actions/Policy.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/src/libs/actions/Policy.ts b/src/libs/actions/Policy.ts index b11dd7e44a5d..5771c7ada1de 100644 --- a/src/libs/actions/Policy.ts +++ b/src/libs/actions/Policy.ts @@ -2276,7 +2276,6 @@ export { setWorkspaceInviteMessageDraft, setWorkspaceAutoReporting, setWorkspaceApprovalMode, - setWorkspaceApprover, updateWorkspaceDescription, setWorkspaceRequiresCategory, }; From 324c529515c21889869051ca001f69c7b0df14a1 Mon Sep 17 00:00:00 2001 From: Rushat Gabhane Date: Wed, 28 Feb 2024 10:51:33 +0300 Subject: [PATCH 059/170] use set policy approver mode --- .../workspace/workflows/WorkspaceWorkflowsApproverPage.tsx | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/pages/workspace/workflows/WorkspaceWorkflowsApproverPage.tsx b/src/pages/workspace/workflows/WorkspaceWorkflowsApproverPage.tsx index 599a0a46d796..83a09e030625 100644 --- a/src/pages/workspace/workflows/WorkspaceWorkflowsApproverPage.tsx +++ b/src/pages/workspace/workflows/WorkspaceWorkflowsApproverPage.tsx @@ -1,6 +1,7 @@ import React, {useMemo, useState} from 'react'; import {SectionListData} from 'react-native'; -import {OnyxEntry, withOnyx} from 'react-native-onyx'; +import {withOnyx} from 'react-native-onyx'; +import type {OnyxEntry} from 'react-native-onyx'; import Badge from '@components/Badge'; import HeaderWithBackButton from '@components/HeaderWithBackButton'; import ScreenWrapper from '@components/ScreenWrapper'; From c0e4981a55b900ebff3011b8c9fb5862fbffd969 Mon Sep 17 00:00:00 2001 From: Rushat Gabhane Date: Wed, 28 Feb 2024 10:51:38 +0300 Subject: [PATCH 060/170] use set policy approver mode --- .../workspace/workflows/WorkspaceWorkflowsApproverPage.tsx | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/pages/workspace/workflows/WorkspaceWorkflowsApproverPage.tsx b/src/pages/workspace/workflows/WorkspaceWorkflowsApproverPage.tsx index 83a09e030625..8ca60b66e10b 100644 --- a/src/pages/workspace/workflows/WorkspaceWorkflowsApproverPage.tsx +++ b/src/pages/workspace/workflows/WorkspaceWorkflowsApproverPage.tsx @@ -129,10 +129,12 @@ function WorkspaceWorkflowsApproverPage({policy, policyMembers, personalDetails} }, [personalDetails, policyMembers, searchTerm, translate, policy?.approver]); const setPolicyApprover = (member: MemberOption) => { - if (!policy) { + if (!policy || !policy.approvalMode || !personalDetails?.[member.accountID]?.login) { return; } - Policy.setWorkspaceApprover(policy.id, member.accountID); + const approver: string = personalDetails?.[member.accountID]?.login || policy.approver || ''; + console.log(approver); + Policy.setWorkspaceApprovalMode(policy.id, approver, policy.approvalMode); Navigation.goBack(); }; From 35e5d1828df5c965a102b13d4ac48bb4e881587b Mon Sep 17 00:00:00 2001 From: Rushat Gabhane Date: Wed, 28 Feb 2024 10:59:40 +0300 Subject: [PATCH 061/170] show policy approver --- src/pages/workspace/workflows/WorkspaceWorkflowsPage.tsx | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/pages/workspace/workflows/WorkspaceWorkflowsPage.tsx b/src/pages/workspace/workflows/WorkspaceWorkflowsPage.tsx index 60588cffba36..8731407fe6fd 100644 --- a/src/pages/workspace/workflows/WorkspaceWorkflowsPage.tsx +++ b/src/pages/workspace/workflows/WorkspaceWorkflowsPage.tsx @@ -34,8 +34,7 @@ function WorkspaceWorkflowsPage({policy, route}: WorkspaceWorkflowsPageProps) { const {isSmallScreenWidth} = useWindowDimensions(); const {isOffline} = useNetwork(); - const ownerPersonalDetails = ReportUtils.getDisplayNamesWithTooltips(OptionsListUtils.getPersonalDetailsForAccountIDs([policy?.ownerAccountID ?? 0], CONST.EMPTY_OBJECT), false); - const policyOwnerDisplayName = ownerPersonalDetails[0]?.displayName; + const policyApprover = policy?.approver; const containerStyle = useMemo(() => [styles.ph8, styles.mhn8, styles.ml11, styles.pv3, styles.pr0, styles.pl4, styles.mr0, styles.widthAuto, styles.mt4], [styles]); const items: ToggleSettingOptionRowProps[] = useMemo( From a01f23c48ccea8a3b55d83ee0844ea5a222c1207 Mon Sep 17 00:00:00 2001 From: Rushat Gabhane Date: Wed, 28 Feb 2024 10:59:45 +0300 Subject: [PATCH 062/170] show policy approver --- src/pages/workspace/workflows/WorkspaceWorkflowsPage.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pages/workspace/workflows/WorkspaceWorkflowsPage.tsx b/src/pages/workspace/workflows/WorkspaceWorkflowsPage.tsx index 8731407fe6fd..362039baff00 100644 --- a/src/pages/workspace/workflows/WorkspaceWorkflowsPage.tsx +++ b/src/pages/workspace/workflows/WorkspaceWorkflowsPage.tsx @@ -74,7 +74,7 @@ function WorkspaceWorkflowsPage({policy, route}: WorkspaceWorkflowsPageProps) { title={translate('workflowsPage.approver')} titleStyle={styles.textLabelSupportingNormal} descriptionTextStyle={styles.textNormalThemeText} - description={policyOwnerDisplayName ?? ''} + description={policyApprover ?? ''} onPress={() => Navigation.navigate(ROUTES.WORKSPACE_WORKFLOWS_APPROVER.getRoute(route.params.policyID))} // TODO will be done in https://github.com/Expensify/Expensify/issues/368334 shouldShowRightIcon From bd296622de8b3ffdbde9ca133d97d4e5ac77f75b Mon Sep 17 00:00:00 2001 From: Rushat Gabhane Date: Wed, 28 Feb 2024 10:59:51 +0300 Subject: [PATCH 063/170] show policy approver --- src/pages/workspace/workflows/WorkspaceWorkflowsPage.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pages/workspace/workflows/WorkspaceWorkflowsPage.tsx b/src/pages/workspace/workflows/WorkspaceWorkflowsPage.tsx index 362039baff00..afcf7351f219 100644 --- a/src/pages/workspace/workflows/WorkspaceWorkflowsPage.tsx +++ b/src/pages/workspace/workflows/WorkspaceWorkflowsPage.tsx @@ -109,7 +109,7 @@ function WorkspaceWorkflowsPage({policy, route}: WorkspaceWorkflowsPageProps) { isActive: false, // TODO will be done in https://github.com/Expensify/Expensify/issues/368335 }, ], - [policy, route.params.policyID, styles, translate, policyOwnerDisplayName, containerStyle, isOffline, StyleUtils], + [policy, route.params.policyID, styles, translate, policyApprover, containerStyle, isOffline, StyleUtils], ); const renderItem = ({item}: {item: ToggleSettingOptionRowProps}) => ( From d619c7005b901c316f1978cb93b876b25097ca53 Mon Sep 17 00:00:00 2001 From: Rushat Gabhane Date: Wed, 28 Feb 2024 11:00:38 +0300 Subject: [PATCH 064/170] default to policy owner --- .../workspace/workflows/WorkspaceWorkflowsApproverPage.tsx | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/pages/workspace/workflows/WorkspaceWorkflowsApproverPage.tsx b/src/pages/workspace/workflows/WorkspaceWorkflowsApproverPage.tsx index 8ca60b66e10b..133ebc737aea 100644 --- a/src/pages/workspace/workflows/WorkspaceWorkflowsApproverPage.tsx +++ b/src/pages/workspace/workflows/WorkspaceWorkflowsApproverPage.tsx @@ -132,8 +132,7 @@ function WorkspaceWorkflowsApproverPage({policy, policyMembers, personalDetails} if (!policy || !policy.approvalMode || !personalDetails?.[member.accountID]?.login) { return; } - const approver: string = personalDetails?.[member.accountID]?.login || policy.approver || ''; - console.log(approver); + const approver: string = personalDetails?.[member.accountID]?.login || policy.approver || policy.owner; Policy.setWorkspaceApprovalMode(policy.id, approver, policy.approvalMode); Navigation.goBack(); }; From eb09ea1878d00866d1c47dca9f0aa4fa5930b4f7 Mon Sep 17 00:00:00 2001 From: Rushat Gabhane Date: Wed, 28 Feb 2024 11:42:21 +0300 Subject: [PATCH 065/170] memoize policy members --- .../workflows/WorkspaceWorkflowsApproverPage.tsx | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/src/pages/workspace/workflows/WorkspaceWorkflowsApproverPage.tsx b/src/pages/workspace/workflows/WorkspaceWorkflowsApproverPage.tsx index 133ebc737aea..70e3b57b6e44 100644 --- a/src/pages/workspace/workflows/WorkspaceWorkflowsApproverPage.tsx +++ b/src/pages/workspace/workflows/WorkspaceWorkflowsApproverPage.tsx @@ -52,11 +52,9 @@ function WorkspaceWorkflowsApproverPage({policy, policyMembers, personalDetails} const isDeletedPolicyMember = (policyMember: PolicyMember): boolean => !isOffline && policyMember.pendingAction === CONST.RED_BRICK_ROAD_PENDING_ACTION.DELETE && isEmptyObject(policyMember.errors); - const sections: MembersSection[] = useMemo(() => { - const sectionsArr: MembersSection[] = []; - - const policyUsersSection: MemberOption[] = []; - const approverSection: MemberOption[] = []; + const [formattedPolicyMembers, formattedApprover] = useMemo(() => { + const formattedPolicyMembers: MemberOption[] = []; + const formattedApprover: MemberOption[] = []; Object.entries(policyMembers ?? {}).forEach(([accountIDKey, policyMember]) => { const accountID = Number(accountIDKey); From 9ad56ccb378adbb7cec9d229b17b04a02bb036a3 Mon Sep 17 00:00:00 2001 From: Rushat Gabhane Date: Wed, 28 Feb 2024 11:42:29 +0300 Subject: [PATCH 066/170] memoize policy members --- .../WorkspaceWorkflowsApproverPage.tsx | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/src/pages/workspace/workflows/WorkspaceWorkflowsApproverPage.tsx b/src/pages/workspace/workflows/WorkspaceWorkflowsApproverPage.tsx index 70e3b57b6e44..6a265ab5998f 100644 --- a/src/pages/workspace/workflows/WorkspaceWorkflowsApproverPage.tsx +++ b/src/pages/workspace/workflows/WorkspaceWorkflowsApproverPage.tsx @@ -103,28 +103,33 @@ function WorkspaceWorkflowsApproverPage({policy, policyMembers, personalDetails} }; if (policy?.approver === details.login) { - approverSection.push(formattedMember); + formattedApprover.push(formattedMember); } else { - policyUsersSection.push(formattedMember); + formattedPolicyMembers.push(formattedMember); } }); + return [formattedPolicyMembers, formattedApprover]; + }, [personalDetails, policyMembers, translate, policy?.approver]); + + const sections: MembersSection[] = useMemo(() => { + const sectionsArr: MembersSection[] = []; sectionsArr.push({ title: undefined, - data: approverSection, + data: formattedApprover, shouldShow: true, indexOffset: 0, }); sectionsArr.push({ title: translate('common.all'), - data: policyUsersSection, + data: formattedPolicyMembers, shouldShow: true, - indexOffset: approverSection.length, + indexOffset: formattedApprover.length, }); return sectionsArr; - }, [personalDetails, policyMembers, searchTerm, translate, policy?.approver]); + }, [formattedPolicyMembers, formattedApprover, searchTerm]); const setPolicyApprover = (member: MemberOption) => { if (!policy || !policy.approvalMode || !personalDetails?.[member.accountID]?.login) { From 05ca9610bec77eeea9ba58b4171a938727ace62a Mon Sep 17 00:00:00 2001 From: dukenv0307 Date: Wed, 28 Feb 2024 16:22:02 +0700 Subject: [PATCH 067/170] Fix display name displays twice on LHN after receiving payment --- src/libs/SidebarUtils.ts | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/libs/SidebarUtils.ts b/src/libs/SidebarUtils.ts index 35cf52a5ff99..d8b0ed90309e 100644 --- a/src/libs/SidebarUtils.ts +++ b/src/libs/SidebarUtils.ts @@ -289,14 +289,12 @@ function getOptionData({ let lastMessageText = lastMessageTextFromReport; - const reportAction = lastReportActions?.[report.reportID]; + const lastAction = visibleReportActionItems[report.reportID]; const isThreadMessage = - ReportUtils.isThread(report) && reportAction?.actionName === CONST.REPORT.ACTIONS.TYPE.ADDCOMMENT && reportAction?.pendingAction !== CONST.RED_BRICK_ROAD_PENDING_ACTION.DELETE; + ReportUtils.isThread(report) && lastAction?.actionName === CONST.REPORT.ACTIONS.TYPE.ADDCOMMENT && lastAction?.pendingAction !== CONST.RED_BRICK_ROAD_PENDING_ACTION.DELETE; if ((result.isChatRoom || result.isPolicyExpenseChat || result.isThread || result.isTaskReport || isThreadMessage) && !result.isArchivedRoom) { - const lastAction = visibleReportActionItems[report.reportID]; - if (lastAction?.actionName === CONST.REPORT.ACTIONS.TYPE.RENAMED) { const newName = lastAction?.originalMessage?.newName ?? ''; result.alternateText = Localize.translate(preferredLocale, 'newRoomPage.roomRenamedTo', {newName}); From e91716266c9e4f856f2153f84d7e64f70cb0bd21 Mon Sep 17 00:00:00 2001 From: Rushat Gabhane Date: Wed, 28 Feb 2024 12:54:13 +0300 Subject: [PATCH 068/170] add filter --- src/pages/workspace/workflows/WorkspaceWorkflowsApproverPage.tsx | 1 + 1 file changed, 1 insertion(+) diff --git a/src/pages/workspace/workflows/WorkspaceWorkflowsApproverPage.tsx b/src/pages/workspace/workflows/WorkspaceWorkflowsApproverPage.tsx index 6a265ab5998f..0390a697a069 100644 --- a/src/pages/workspace/workflows/WorkspaceWorkflowsApproverPage.tsx +++ b/src/pages/workspace/workflows/WorkspaceWorkflowsApproverPage.tsx @@ -1,3 +1,4 @@ +import Str from 'expensify-common/lib/str'; import React, {useMemo, useState} from 'react'; import {SectionListData} from 'react-native'; import {withOnyx} from 'react-native-onyx'; From aca798a92efc20ccb25de45a1ffce04e6963c034 Mon Sep 17 00:00:00 2001 From: Rushat Gabhane Date: Wed, 28 Feb 2024 12:54:19 +0300 Subject: [PATCH 069/170] add filter --- .../workspace/workflows/WorkspaceWorkflowsApproverPage.tsx | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/pages/workspace/workflows/WorkspaceWorkflowsApproverPage.tsx b/src/pages/workspace/workflows/WorkspaceWorkflowsApproverPage.tsx index 0390a697a069..b8c82251139b 100644 --- a/src/pages/workspace/workflows/WorkspaceWorkflowsApproverPage.tsx +++ b/src/pages/workspace/workflows/WorkspaceWorkflowsApproverPage.tsx @@ -16,9 +16,11 @@ import useThemeStyles from '@hooks/useThemeStyles'; import compose from '@libs/compose'; import {formatPhoneNumber} from '@libs/LocalePhoneNumber'; import Log from '@libs/Log'; +import * as LoginUtils from '@libs/LoginUtils'; import Navigation from '@libs/Navigation/Navigation'; import * as OptionsListUtils from '@libs/OptionsListUtils'; import * as PersonalDetailsUtils from '@libs/PersonalDetailsUtils'; +import {parsePhoneNumber} from '@libs/PhoneNumber'; import * as UserUtils from '@libs/UserUtils'; import * as Policy from '@userActions/Policy'; import CONST from '@src/CONST'; From f2e6310da45e4fcaab895e18079d33e4bbaab0a9 Mon Sep 17 00:00:00 2001 From: Rushat Gabhane Date: Wed, 28 Feb 2024 12:54:24 +0300 Subject: [PATCH 070/170] add filter --- .../WorkspaceWorkflowsApproverPage.tsx | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/src/pages/workspace/workflows/WorkspaceWorkflowsApproverPage.tsx b/src/pages/workspace/workflows/WorkspaceWorkflowsApproverPage.tsx index b8c82251139b..9f1c627e1a32 100644 --- a/src/pages/workspace/workflows/WorkspaceWorkflowsApproverPage.tsx +++ b/src/pages/workspace/workflows/WorkspaceWorkflowsApproverPage.tsx @@ -117,6 +117,23 @@ function WorkspaceWorkflowsApproverPage({policy, policyMembers, personalDetails} const sections: MembersSection[] = useMemo(() => { const sectionsArr: MembersSection[] = []; + if (searchTerm !== '') { + const filteredOptions = [...formattedApprover, ...formattedPolicyMembers].filter((option) => { + const parsedPhoneNumber = parsePhoneNumber(LoginUtils.appendCountryCode(Str.removeSMSDomain(searchTerm))); + const searchValue = parsedPhoneNumber.possible ? parsedPhoneNumber.number?.e164 ?? '' : searchTerm.toLowerCase(); + + const isPartOfSearchTerm = !!option.text?.toLowerCase().includes(searchValue) || !!option.login?.toLowerCase().includes(searchValue); + return isPartOfSearchTerm; + }); + return [ + { + title: undefined, + data: filteredOptions, + shouldShow: true, + }, + ]; + } + sectionsArr.push({ title: undefined, data: formattedApprover, From a3cacc277e1052949e293f565e610f121a4e4f62 Mon Sep 17 00:00:00 2001 From: Rushat Gabhane Date: Wed, 28 Feb 2024 12:59:24 +0300 Subject: [PATCH 071/170] handle empty approver --- .../workspace/workflows/WorkspaceWorkflowsApproverPage.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pages/workspace/workflows/WorkspaceWorkflowsApproverPage.tsx b/src/pages/workspace/workflows/WorkspaceWorkflowsApproverPage.tsx index 9f1c627e1a32..0ff25c2ef470 100644 --- a/src/pages/workspace/workflows/WorkspaceWorkflowsApproverPage.tsx +++ b/src/pages/workspace/workflows/WorkspaceWorkflowsApproverPage.tsx @@ -137,7 +137,7 @@ function WorkspaceWorkflowsApproverPage({policy, policyMembers, personalDetails} sectionsArr.push({ title: undefined, data: formattedApprover, - shouldShow: true, + shouldShow: formattedApprover.length > 0, indexOffset: 0, }); From e8b63b32a2794d317f4eb1dc5d21ee2800a8b323 Mon Sep 17 00:00:00 2001 From: Rushat Gabhane Date: Wed, 28 Feb 2024 13:04:47 +0300 Subject: [PATCH 072/170] fix lint --- .../workspace/workflows/WorkspaceWorkflowsApproverPage.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pages/workspace/workflows/WorkspaceWorkflowsApproverPage.tsx b/src/pages/workspace/workflows/WorkspaceWorkflowsApproverPage.tsx index 0ff25c2ef470..aeda8c84d1e6 100644 --- a/src/pages/workspace/workflows/WorkspaceWorkflowsApproverPage.tsx +++ b/src/pages/workspace/workflows/WorkspaceWorkflowsApproverPage.tsx @@ -1,6 +1,6 @@ import Str from 'expensify-common/lib/str'; import React, {useMemo, useState} from 'react'; -import {SectionListData} from 'react-native'; +import type {SectionListData} from 'react-native'; import {withOnyx} from 'react-native-onyx'; import type {OnyxEntry} from 'react-native-onyx'; import Badge from '@components/Badge'; From 722ae401e21ef010d6241623a4495f782bacd46a Mon Sep 17 00:00:00 2001 From: Rushat Gabhane Date: Wed, 28 Feb 2024 13:04:52 +0300 Subject: [PATCH 073/170] fix lint --- .../workspace/workflows/WorkspaceWorkflowsApproverPage.tsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/pages/workspace/workflows/WorkspaceWorkflowsApproverPage.tsx b/src/pages/workspace/workflows/WorkspaceWorkflowsApproverPage.tsx index aeda8c84d1e6..b1d92dc69701 100644 --- a/src/pages/workspace/workflows/WorkspaceWorkflowsApproverPage.tsx +++ b/src/pages/workspace/workflows/WorkspaceWorkflowsApproverPage.tsx @@ -56,8 +56,8 @@ function WorkspaceWorkflowsApproverPage({policy, policyMembers, personalDetails} !isOffline && policyMember.pendingAction === CONST.RED_BRICK_ROAD_PENDING_ACTION.DELETE && isEmptyObject(policyMember.errors); const [formattedPolicyMembers, formattedApprover] = useMemo(() => { - const formattedPolicyMembers: MemberOption[] = []; - const formattedApprover: MemberOption[] = []; + const policyMemberDetails: MemberOption[] = []; + const approverDetails: MemberOption[] = []; Object.entries(policyMembers ?? {}).forEach(([accountIDKey, policyMember]) => { const accountID = Number(accountIDKey); From f69f94f1d1f32601324745406cfeaeae39e7b4a7 Mon Sep 17 00:00:00 2001 From: Rushat Gabhane Date: Wed, 28 Feb 2024 13:04:58 +0300 Subject: [PATCH 074/170] fix lint --- .../workspace/workflows/WorkspaceWorkflowsApproverPage.tsx | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/pages/workspace/workflows/WorkspaceWorkflowsApproverPage.tsx b/src/pages/workspace/workflows/WorkspaceWorkflowsApproverPage.tsx index b1d92dc69701..b1ea38d9fe7a 100644 --- a/src/pages/workspace/workflows/WorkspaceWorkflowsApproverPage.tsx +++ b/src/pages/workspace/workflows/WorkspaceWorkflowsApproverPage.tsx @@ -106,12 +106,12 @@ function WorkspaceWorkflowsApproverPage({policy, policyMembers, personalDetails} }; if (policy?.approver === details.login) { - formattedApprover.push(formattedMember); + approverDetails.push(formattedMember); } else { - formattedPolicyMembers.push(formattedMember); + policyMemberDetails.push(formattedMember); } }); - return [formattedPolicyMembers, formattedApprover]; + return [policyMemberDetails, approverDetails]; }, [personalDetails, policyMembers, translate, policy?.approver]); const sections: MembersSection[] = useMemo(() => { From 3e66027efbe3d26c33f61c9051867e7649ea3513 Mon Sep 17 00:00:00 2001 From: Rushat Gabhane Date: Wed, 28 Feb 2024 13:05:03 +0300 Subject: [PATCH 075/170] fix lint --- .../workspace/workflows/WorkspaceWorkflowsApproverPage.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pages/workspace/workflows/WorkspaceWorkflowsApproverPage.tsx b/src/pages/workspace/workflows/WorkspaceWorkflowsApproverPage.tsx index b1ea38d9fe7a..891596b1d0cc 100644 --- a/src/pages/workspace/workflows/WorkspaceWorkflowsApproverPage.tsx +++ b/src/pages/workspace/workflows/WorkspaceWorkflowsApproverPage.tsx @@ -155,7 +155,7 @@ function WorkspaceWorkflowsApproverPage({policy, policyMembers, personalDetails} if (!policy || !policy.approvalMode || !personalDetails?.[member.accountID]?.login) { return; } - const approver: string = personalDetails?.[member.accountID]?.login || policy.approver || policy.owner; + const approver: string = personalDetails?.[member.accountID]?.login ?? policy.approver ?? policy.owner; Policy.setWorkspaceApprovalMode(policy.id, approver, policy.approvalMode); Navigation.goBack(); }; From 34aa03939f710f39369b6c84a48b217a75025f16 Mon Sep 17 00:00:00 2001 From: Rushat Gabhane Date: Wed, 28 Feb 2024 13:15:24 +0300 Subject: [PATCH 076/170] add not found page --- src/pages/workspace/workflows/WorkspaceWorkflowsApproverPage.tsx | 1 + 1 file changed, 1 insertion(+) diff --git a/src/pages/workspace/workflows/WorkspaceWorkflowsApproverPage.tsx b/src/pages/workspace/workflows/WorkspaceWorkflowsApproverPage.tsx index 891596b1d0cc..8170d37e8cd1 100644 --- a/src/pages/workspace/workflows/WorkspaceWorkflowsApproverPage.tsx +++ b/src/pages/workspace/workflows/WorkspaceWorkflowsApproverPage.tsx @@ -4,6 +4,7 @@ import type {SectionListData} from 'react-native'; import {withOnyx} from 'react-native-onyx'; import type {OnyxEntry} from 'react-native-onyx'; import Badge from '@components/Badge'; +import FullPageNotFoundView from '@components/BlockingViews/FullPageNotFoundView'; import HeaderWithBackButton from '@components/HeaderWithBackButton'; import ScreenWrapper from '@components/ScreenWrapper'; import SelectionList from '@components/SelectionList'; From 9fc8ee78d1a8b155312a604a673a985add295f3e Mon Sep 17 00:00:00 2001 From: Rushat Gabhane Date: Wed, 28 Feb 2024 13:15:30 +0300 Subject: [PATCH 077/170] add not found page --- src/pages/workspace/workflows/WorkspaceWorkflowsApproverPage.tsx | 1 + 1 file changed, 1 insertion(+) diff --git a/src/pages/workspace/workflows/WorkspaceWorkflowsApproverPage.tsx b/src/pages/workspace/workflows/WorkspaceWorkflowsApproverPage.tsx index 8170d37e8cd1..3844ff9fd7b7 100644 --- a/src/pages/workspace/workflows/WorkspaceWorkflowsApproverPage.tsx +++ b/src/pages/workspace/workflows/WorkspaceWorkflowsApproverPage.tsx @@ -22,6 +22,7 @@ import Navigation from '@libs/Navigation/Navigation'; import * as OptionsListUtils from '@libs/OptionsListUtils'; import * as PersonalDetailsUtils from '@libs/PersonalDetailsUtils'; import {parsePhoneNumber} from '@libs/PhoneNumber'; +import * as PolicyUtils from '@libs/PolicyUtils'; import * as UserUtils from '@libs/UserUtils'; import * as Policy from '@userActions/Policy'; import CONST from '@src/CONST'; From baf34f52abe3fe0f1372a00d31515e2c3c4c291b Mon Sep 17 00:00:00 2001 From: Rushat Gabhane Date: Wed, 28 Feb 2024 13:15:36 +0300 Subject: [PATCH 078/170] add not found page --- .../workspace/workflows/WorkspaceWorkflowsApproverPage.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pages/workspace/workflows/WorkspaceWorkflowsApproverPage.tsx b/src/pages/workspace/workflows/WorkspaceWorkflowsApproverPage.tsx index 3844ff9fd7b7..1ff6c021ec0c 100644 --- a/src/pages/workspace/workflows/WorkspaceWorkflowsApproverPage.tsx +++ b/src/pages/workspace/workflows/WorkspaceWorkflowsApproverPage.tsx @@ -41,7 +41,7 @@ type WorkspaceWorkflowsApproverPageProps = WorkspaceWorkflowsApproverPageOnyxPro type MemberOption = Omit & {accountID: number}; type MembersSection = SectionListData>; -function WorkspaceWorkflowsApproverPage({policy, policyMembers, personalDetails}: WorkspaceWorkflowsApproverPageProps) { +function WorkspaceWorkflowsApproverPage({policy, policyMembers, personalDetails, isLoadingReportData = true}: WorkspaceWorkflowsApproverPageProps) { const {translate} = useLocalize(); const policyName = policy?.name ?? ''; const [searchTerm, setSearchTerm] = useState(''); From 4cf6d18e6ce50893845a4efde687e1e9badb3d00 Mon Sep 17 00:00:00 2001 From: Rushat Gabhane Date: Wed, 28 Feb 2024 13:15:41 +0300 Subject: [PATCH 079/170] add not found page --- .../WorkspaceWorkflowsApproverPage.tsx | 37 +++++++++++-------- 1 file changed, 22 insertions(+), 15 deletions(-) diff --git a/src/pages/workspace/workflows/WorkspaceWorkflowsApproverPage.tsx b/src/pages/workspace/workflows/WorkspaceWorkflowsApproverPage.tsx index 1ff6c021ec0c..9e59fe4583cd 100644 --- a/src/pages/workspace/workflows/WorkspaceWorkflowsApproverPage.tsx +++ b/src/pages/workspace/workflows/WorkspaceWorkflowsApproverPage.tsx @@ -167,21 +167,28 @@ function WorkspaceWorkflowsApproverPage({policy, policyMembers, personalDetails, includeSafeAreaPaddingBottom={false} testID={WorkspaceWorkflowsApproverPage.displayName} > - - + + + + ); } From b86d2f03fb3cfc64491f8580350aded4ed919667 Mon Sep 17 00:00:00 2001 From: Rushat Gabhane Date: Wed, 28 Feb 2024 13:35:18 +0300 Subject: [PATCH 080/170] handle no results --- .../workspace/workflows/WorkspaceWorkflowsApproverPage.tsx | 5 ----- 1 file changed, 5 deletions(-) diff --git a/src/pages/workspace/workflows/WorkspaceWorkflowsApproverPage.tsx b/src/pages/workspace/workflows/WorkspaceWorkflowsApproverPage.tsx index 9e59fe4583cd..b23eac90f559 100644 --- a/src/pages/workspace/workflows/WorkspaceWorkflowsApproverPage.tsx +++ b/src/pages/workspace/workflows/WorkspaceWorkflowsApproverPage.tsx @@ -49,11 +49,6 @@ function WorkspaceWorkflowsApproverPage({policy, policyMembers, personalDetails, const styles = useThemeStyles(); const StyleUtils = useStyleUtils(); - const headerMessage = useMemo(() => { - const searchValue = searchTerm.trim().toLowerCase(); - return OptionsListUtils.getHeaderMessage(true, false, searchValue); - }, [translate, searchTerm, policyName]); - const isDeletedPolicyMember = (policyMember: PolicyMember): boolean => !isOffline && policyMember.pendingAction === CONST.RED_BRICK_ROAD_PENDING_ACTION.DELETE && isEmptyObject(policyMember.errors); From b935378f645f6bdc333b6b481884890e87de48aa Mon Sep 17 00:00:00 2001 From: Rushat Gabhane Date: Wed, 28 Feb 2024 13:35:23 +0300 Subject: [PATCH 081/170] handle no results --- .../workspace/workflows/WorkspaceWorkflowsApproverPage.tsx | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/pages/workspace/workflows/WorkspaceWorkflowsApproverPage.tsx b/src/pages/workspace/workflows/WorkspaceWorkflowsApproverPage.tsx index b23eac90f559..e76a557b539c 100644 --- a/src/pages/workspace/workflows/WorkspaceWorkflowsApproverPage.tsx +++ b/src/pages/workspace/workflows/WorkspaceWorkflowsApproverPage.tsx @@ -148,6 +148,10 @@ function WorkspaceWorkflowsApproverPage({policy, policyMembers, personalDetails, return sectionsArr; }, [formattedPolicyMembers, formattedApprover, searchTerm]); + const headerMessage = useMemo(() => { + return !sections.length ? translate('workspace.common.memberNotFound') : ''; + }, [translate, sections]); + const setPolicyApprover = (member: MemberOption) => { if (!policy || !policy.approvalMode || !personalDetails?.[member.accountID]?.login) { return; From caec3f64fb0719b803755e380aada71eca3d35d2 Mon Sep 17 00:00:00 2001 From: Rushat Gabhane Date: Wed, 28 Feb 2024 13:39:37 +0300 Subject: [PATCH 082/170] fix err msg --- .../workspace/workflows/WorkspaceWorkflowsApproverPage.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pages/workspace/workflows/WorkspaceWorkflowsApproverPage.tsx b/src/pages/workspace/workflows/WorkspaceWorkflowsApproverPage.tsx index e76a557b539c..24e0dbcc94d7 100644 --- a/src/pages/workspace/workflows/WorkspaceWorkflowsApproverPage.tsx +++ b/src/pages/workspace/workflows/WorkspaceWorkflowsApproverPage.tsx @@ -149,7 +149,7 @@ function WorkspaceWorkflowsApproverPage({policy, policyMembers, personalDetails, }, [formattedPolicyMembers, formattedApprover, searchTerm]); const headerMessage = useMemo(() => { - return !sections.length ? translate('workspace.common.memberNotFound') : ''; + return !sections[0].data.length ? translate('common.noResultsFound') : ''; }, [translate, sections]); const setPolicyApprover = (member: MemberOption) => { From 2419ba6a0a3aa7bc85dada219f5d0af336c12a5e Mon Sep 17 00:00:00 2001 From: dukenv0307 Date: Wed, 28 Feb 2024 17:49:50 +0700 Subject: [PATCH 083/170] remove unused variable --- src/libs/SidebarUtils.ts | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/libs/SidebarUtils.ts b/src/libs/SidebarUtils.ts index d8b0ed90309e..299becd45515 100644 --- a/src/libs/SidebarUtils.ts +++ b/src/libs/SidebarUtils.ts @@ -23,7 +23,6 @@ import * as TaskUtils from './TaskUtils'; import * as UserUtils from './UserUtils'; const visibleReportActionItems: ReportActions = {}; -const lastReportActions: ReportActions = {}; Onyx.connect({ key: ONYXKEYS.COLLECTION.REPORT_ACTIONS, @@ -34,7 +33,6 @@ Onyx.connect({ const reportID = CollectionUtils.extractCollectionItemID(key); const actionsArray: ReportAction[] = ReportActionsUtils.getSortedReportActions(Object.values(actions)); - lastReportActions[reportID] = actionsArray[actionsArray.length - 1]; // The report is only visible if it is the last action not deleted that // does not match a closed or created state. From b4728c9a6d0c12182c6a782cef9e4ac445d5d45c Mon Sep 17 00:00:00 2001 From: Rushat Gabhane Date: Wed, 28 Feb 2024 14:42:44 +0300 Subject: [PATCH 084/170] fix err msg --- .../workspace/workflows/WorkspaceWorkflowsApproverPage.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pages/workspace/workflows/WorkspaceWorkflowsApproverPage.tsx b/src/pages/workspace/workflows/WorkspaceWorkflowsApproverPage.tsx index 24e0dbcc94d7..9c2f6f3f6e63 100644 --- a/src/pages/workspace/workflows/WorkspaceWorkflowsApproverPage.tsx +++ b/src/pages/workspace/workflows/WorkspaceWorkflowsApproverPage.tsx @@ -149,7 +149,7 @@ function WorkspaceWorkflowsApproverPage({policy, policyMembers, personalDetails, }, [formattedPolicyMembers, formattedApprover, searchTerm]); const headerMessage = useMemo(() => { - return !sections[0].data.length ? translate('common.noResultsFound') : ''; + return searchTerm && !sections[0].data.length ? translate('common.noResultsFound') : ''; }, [translate, sections]); const setPolicyApprover = (member: MemberOption) => { From 270707015c3c71f5130b2635332337285411d6f9 Mon Sep 17 00:00:00 2001 From: VickyStash Date: Wed, 28 Feb 2024 13:21:34 +0100 Subject: [PATCH 085/170] Fix TS error --- tests/e2e/compare/output/console.ts | 14 ++++++++++++++ tests/e2e/compare/output/format.ts | 21 +++------------------ 2 files changed, 17 insertions(+), 18 deletions(-) diff --git a/tests/e2e/compare/output/console.ts b/tests/e2e/compare/output/console.ts index 38d01292a791..03db95e43833 100644 --- a/tests/e2e/compare/output/console.ts +++ b/tests/e2e/compare/output/console.ts @@ -1,7 +1,19 @@ import * as format from './format'; +type Stats = { + mean: number; + stdev: number; + runs: number; + entries: Record; +}; + type Entry = { name: string; + baseline: Stats; + current: Stats; + diff: number; + relativeDurationDiff: number; + isDurationDiffOfSignificance: boolean; }; type Data = { @@ -29,3 +41,5 @@ export default (data: Data) => { console.debug(''); }; + +export type {Entry}; diff --git a/tests/e2e/compare/output/format.ts b/tests/e2e/compare/output/format.ts index cbed4a8a6365..40c9e74d6247 100644 --- a/tests/e2e/compare/output/format.ts +++ b/tests/e2e/compare/output/format.ts @@ -2,22 +2,7 @@ * Utility for formatting text for result outputs. * from: https://github.com/callstack/reassure/blob/main/packages/reassure-compare/src/utils/format.ts */ - -type Stats = { - mean: number; - stdev: number; - runs: number; - entries: Record; -}; - -type CompareEntry = { - name: string; - baseline: Stats; - current: Stats; - diff: number; - relativeDurationDiff: number; - isDurationDiffOfSignificance: boolean; -}; +import type {Entry} from './console'; const formatPercent = (value: number): string => { const valueAsPercent = value * 100; @@ -57,7 +42,7 @@ const formatChange = (value: number): string => { return '0'; }; -const getDurationSymbols = (entry: CompareEntry): string => { +const getDurationSymbols = (entry: Entry): string => { if (!entry.isDurationDiffOfSignificance) { if (entry.relativeDurationDiff > 0.15) { return '🟡'; @@ -84,7 +69,7 @@ const getDurationSymbols = (entry: CompareEntry): string => { return ''; }; -const formatDurationDiffChange = (entry: CompareEntry): string => { +const formatDurationDiffChange = (entry: Entry): string => { const {baseline, current} = entry; let output = `${formatDuration(baseline.mean)} → ${formatDuration(current.mean)}`; From 6dd7feebc155aa9bc020524b35aa800b122e410b Mon Sep 17 00:00:00 2001 From: Rushat Gabhane Date: Wed, 28 Feb 2024 18:39:16 +0300 Subject: [PATCH 086/170] fix lint --- .../API/parameters/SetWorkspaceWorkflowsApproverParams.ts | 6 ------ 1 file changed, 6 deletions(-) delete mode 100644 src/libs/API/parameters/SetWorkspaceWorkflowsApproverParams.ts diff --git a/src/libs/API/parameters/SetWorkspaceWorkflowsApproverParams.ts b/src/libs/API/parameters/SetWorkspaceWorkflowsApproverParams.ts deleted file mode 100644 index cf1d4a2e705b..000000000000 --- a/src/libs/API/parameters/SetWorkspaceWorkflowsApproverParams.ts +++ /dev/null @@ -1,6 +0,0 @@ -type SetWorkspaceWorkflowsApproverParams = { - policyID: string; - accountID: number; -}; - -export default SetWorkspaceWorkflowsApproverParams; From 5852f2e3648a9dffa1634586600fc150cd5865d1 Mon Sep 17 00:00:00 2001 From: Rushat Gabhane Date: Wed, 28 Feb 2024 18:39:21 +0300 Subject: [PATCH 087/170] fix lint --- src/libs/API/parameters/index.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/src/libs/API/parameters/index.ts b/src/libs/API/parameters/index.ts index cb3376b2b28a..fc24b97ff1f3 100644 --- a/src/libs/API/parameters/index.ts +++ b/src/libs/API/parameters/index.ts @@ -148,5 +148,4 @@ export type {default as UpdateWorkspaceDescriptionParams} from './UpdateWorkspac export type {default as SetWorkspaceRequiresCategoryParams} from './SetWorkspaceRequiresCategoryParams'; export type {default as SetWorkspaceAutoReportingParams} from './SetWorkspaceAutoReportingParams'; export type {default as SetWorkspaceApprovalModeParams} from './SetWorkspaceApprovalModeParams'; -export type {default as SetWorkspaceWorkflowsApproverParams} from './SetWorkspaceWorkflowsApproverParams'; export type {default as SwitchToOldDotParams} from './SwitchToOldDotParams'; From 538cacff17073f0d7dd46ce471e40797c51e0a22 Mon Sep 17 00:00:00 2001 From: Rushat Gabhane Date: Wed, 28 Feb 2024 18:39:28 +0300 Subject: [PATCH 088/170] fix lint --- src/libs/actions/Policy.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/src/libs/actions/Policy.ts b/src/libs/actions/Policy.ts index 5771c7ada1de..b9a2e8535b62 100644 --- a/src/libs/actions/Policy.ts +++ b/src/libs/actions/Policy.ts @@ -22,7 +22,6 @@ import type { OpenWorkspaceReimburseViewParams, SetWorkspaceApprovalModeParams, SetWorkspaceAutoReportingParams, - SetWorkspaceWorkflowsApproverParams, UpdateWorkspaceAvatarParams, UpdateWorkspaceCustomUnitAndRateParams, UpdateWorkspaceDescriptionParams, From eceef704fe6e9a292dd9c7b54bd972f1fd286b29 Mon Sep 17 00:00:00 2001 From: Rushat Gabhane Date: Wed, 28 Feb 2024 18:47:24 +0300 Subject: [PATCH 089/170] fix lint --- src/pages/workspace/workflows/WorkspaceWorkflowsApproverPage.tsx | 1 - 1 file changed, 1 deletion(-) diff --git a/src/pages/workspace/workflows/WorkspaceWorkflowsApproverPage.tsx b/src/pages/workspace/workflows/WorkspaceWorkflowsApproverPage.tsx index 9c2f6f3f6e63..b40280c0453b 100644 --- a/src/pages/workspace/workflows/WorkspaceWorkflowsApproverPage.tsx +++ b/src/pages/workspace/workflows/WorkspaceWorkflowsApproverPage.tsx @@ -19,7 +19,6 @@ import {formatPhoneNumber} from '@libs/LocalePhoneNumber'; import Log from '@libs/Log'; import * as LoginUtils from '@libs/LoginUtils'; import Navigation from '@libs/Navigation/Navigation'; -import * as OptionsListUtils from '@libs/OptionsListUtils'; import * as PersonalDetailsUtils from '@libs/PersonalDetailsUtils'; import {parsePhoneNumber} from '@libs/PhoneNumber'; import * as PolicyUtils from '@libs/PolicyUtils'; From c5daa84cdb0a8c6bc94f3f6e0ca7f1307c57a1e2 Mon Sep 17 00:00:00 2001 From: Rushat Gabhane Date: Wed, 28 Feb 2024 18:47:29 +0300 Subject: [PATCH 090/170] fix lint --- .../workspace/workflows/WorkspaceWorkflowsApproverPage.tsx | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/pages/workspace/workflows/WorkspaceWorkflowsApproverPage.tsx b/src/pages/workspace/workflows/WorkspaceWorkflowsApproverPage.tsx index b40280c0453b..ebf66de553a9 100644 --- a/src/pages/workspace/workflows/WorkspaceWorkflowsApproverPage.tsx +++ b/src/pages/workspace/workflows/WorkspaceWorkflowsApproverPage.tsx @@ -147,9 +147,7 @@ function WorkspaceWorkflowsApproverPage({policy, policyMembers, personalDetails, return sectionsArr; }, [formattedPolicyMembers, formattedApprover, searchTerm]); - const headerMessage = useMemo(() => { - return searchTerm && !sections[0].data.length ? translate('common.noResultsFound') : ''; - }, [translate, sections]); + const headerMessage = useMemo(() => (searchTerm && !sections[0].data.length ? translate('common.noResultsFound') : ''), [translate, sections]); const setPolicyApprover = (member: MemberOption) => { if (!policy || !policy.approvalMode || !personalDetails?.[member.accountID]?.login) { From 461d38bc2fc923626dc4436f4485789413b59329 Mon Sep 17 00:00:00 2001 From: Rushat Gabhane Date: Wed, 28 Feb 2024 18:57:08 +0300 Subject: [PATCH 091/170] fix more lint --- .../workspace/workflows/WorkspaceWorkflowsApproverPage.tsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/pages/workspace/workflows/WorkspaceWorkflowsApproverPage.tsx b/src/pages/workspace/workflows/WorkspaceWorkflowsApproverPage.tsx index ebf66de553a9..f212423ec7bb 100644 --- a/src/pages/workspace/workflows/WorkspaceWorkflowsApproverPage.tsx +++ b/src/pages/workspace/workflows/WorkspaceWorkflowsApproverPage.tsx @@ -23,13 +23,13 @@ import * as PersonalDetailsUtils from '@libs/PersonalDetailsUtils'; import {parsePhoneNumber} from '@libs/PhoneNumber'; import * as PolicyUtils from '@libs/PolicyUtils'; import * as UserUtils from '@libs/UserUtils'; +import withPolicyAndFullscreenLoading from '@pages/workspace/withPolicyAndFullscreenLoading'; +import type {WithPolicyAndFullscreenLoadingProps} from '@pages/workspace/withPolicyAndFullscreenLoading'; import * as Policy from '@userActions/Policy'; import CONST from '@src/CONST'; import ONYXKEYS from '@src/ONYXKEYS'; import type {PersonalDetailsList, PolicyMember} from '@src/types/onyx'; import {isEmptyObject} from '@src/types/utils/EmptyObject'; -import withPolicyAndFullscreenLoading from '../withPolicyAndFullscreenLoading'; -import type {WithPolicyAndFullscreenLoadingProps} from '../withPolicyAndFullscreenLoading'; type WorkspaceWorkflowsApproverPageOnyxProps = { /** All of the personal details for everyone */ From b965a33c7e3823af858b8619887455ed31bd968b Mon Sep 17 00:00:00 2001 From: Rushat Gabhane Date: Wed, 28 Feb 2024 18:57:29 +0300 Subject: [PATCH 092/170] fix deps arr for memo --- .../workspace/workflows/WorkspaceWorkflowsApproverPage.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pages/workspace/workflows/WorkspaceWorkflowsApproverPage.tsx b/src/pages/workspace/workflows/WorkspaceWorkflowsApproverPage.tsx index f212423ec7bb..4cbdedc2be2d 100644 --- a/src/pages/workspace/workflows/WorkspaceWorkflowsApproverPage.tsx +++ b/src/pages/workspace/workflows/WorkspaceWorkflowsApproverPage.tsx @@ -145,7 +145,7 @@ function WorkspaceWorkflowsApproverPage({policy, policyMembers, personalDetails, }); return sectionsArr; - }, [formattedPolicyMembers, formattedApprover, searchTerm]); + }, [formattedPolicyMembers, formattedApprover, searchTerm, translate]); const headerMessage = useMemo(() => (searchTerm && !sections[0].data.length ? translate('common.noResultsFound') : ''), [translate, sections]); From 77d1ffb2b41b3a1b70e367fda206f717be290d24 Mon Sep 17 00:00:00 2001 From: VickyStash Date: Thu, 29 Feb 2024 12:06:18 +0100 Subject: [PATCH 093/170] Reuse existing Stats type --- tests/e2e/compare/output/console.ts | 8 +------- tests/e2e/measure/math.ts | 2 ++ 2 files changed, 3 insertions(+), 7 deletions(-) diff --git a/tests/e2e/compare/output/console.ts b/tests/e2e/compare/output/console.ts index 03db95e43833..de8e5d913893 100644 --- a/tests/e2e/compare/output/console.ts +++ b/tests/e2e/compare/output/console.ts @@ -1,12 +1,6 @@ +import type {Stats} from '../../measure/math'; import * as format from './format'; -type Stats = { - mean: number; - stdev: number; - runs: number; - entries: Record; -}; - type Entry = { name: string; baseline: Stats; diff --git a/tests/e2e/measure/math.ts b/tests/e2e/measure/math.ts index e1c0cb981a0c..d444ab0e79da 100644 --- a/tests/e2e/measure/math.ts +++ b/tests/e2e/measure/math.ts @@ -49,3 +49,5 @@ const getStats = (entries: Entries): Stats => { }; export default getStats; + +export type {Stats}; From 6307a6ae9b233445ed1e09da1777e86c870cdca9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Hanno=20J=2E=20G=C3=B6decke?= Date: Thu, 29 Feb 2024 13:57:21 +0100 Subject: [PATCH 094/170] wip --- package.json | 3 ++- tests/e2e/tsconfig.build.json | 10 ++++++++++ 2 files changed, 12 insertions(+), 1 deletion(-) create mode 100644 tests/e2e/tsconfig.build.json diff --git a/package.json b/package.json index 10b4f107aa9d..f70e591537bf 100644 --- a/package.json +++ b/package.json @@ -55,7 +55,8 @@ "gh-actions-unused-styles": "./.github/scripts/findUnusedKeys.sh", "workflow-test": "./workflow_tests/scripts/runWorkflowTests.sh", "workflow-test:generate": "ts-node workflow_tests/utils/preGenerateTest.js", - "setup-https": "mkcert -install && mkcert -cert-file config/webpack/certificate.pem -key-file config/webpack/key.pem dev.new.expensify.com localhost 127.0.0.1" + "setup-https": "mkcert -install && mkcert -cert-file config/webpack/certificate.pem -key-file config/webpack/key.pem dev.new.expensify.com localhost 127.0.0.1", + "e2e-test-runner-build": "tsc -p tests/e2e/tsconfig.build.json" }, "dependencies": { "@dotlottie/react-player": "^1.6.3", diff --git a/tests/e2e/tsconfig.build.json b/tests/e2e/tsconfig.build.json new file mode 100644 index 000000000000..bd445813d52b --- /dev/null +++ b/tests/e2e/tsconfig.build.json @@ -0,0 +1,10 @@ +{ + "extends": "../../tsconfig.json", + "compilerOptions": { + "noEmit": false, + "esModuleInterop": true, + "outDir": "dist", + "rootDir": "." + }, + "exclude": [".github/**/*"] +} From 40b51e260874b6619978a919c48f4e79f3dd1df9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Hanno=20J=2E=20G=C3=B6decke?= Date: Thu, 29 Feb 2024 15:07:23 +0100 Subject: [PATCH 095/170] build e2e tests with ncc --- .github/workflows/e2ePerformanceTests.yml | 20 ++++---------------- package.json | 2 +- tests/e2e/TestSpec.yml | 3 +-- tests/e2e/tsconfig.build.json | 10 ---------- 4 files changed, 6 insertions(+), 29 deletions(-) delete mode 100644 tests/e2e/tsconfig.build.json diff --git a/.github/workflows/e2ePerformanceTests.yml b/.github/workflows/e2ePerformanceTests.yml index 338cb8313465..48bfb21e27a2 100644 --- a/.github/workflows/e2ePerformanceTests.yml +++ b/.github/workflows/e2ePerformanceTests.yml @@ -175,23 +175,11 @@ jobs: - name: Rename delta APK run: mv "${{steps.downloadDeltaAPK.outputs.download-path}}/app-e2edelta-release.apk" "${{steps.downloadDeltaAPK.outputs.download-path}}/app-e2edeltaRelease.apk" - - name: Copy e2e code into zip folder - run: cp -r tests/e2e zip + - name: Compile test runner to be executable in a nodeJS environment + run: npm run e2e-test-runner-build - # Note: we can't reuse the apps tsconfig, as it depends on modules that aren't available in the AWS Device Farm environment - - name: Write tsconfig.json to zip folder - run: | - echo '{ - "compilerOptions": { - "target": "ESNext", - "module": "commonjs", - "strict": true, - "esModuleInterop": true, - "skipLibCheck": true, - "forceConsistentCasingInFileNames": true, - "allowJs": true, - } - }' > zip/tsconfig.json + - name: Copy e2e code into zip folder + run: cp tests/e2e/dist/index.js zip/testRunner.js - name: Zip everything in the zip directory up run: zip -qr App.zip ./zip diff --git a/package.json b/package.json index f70e591537bf..f489f013788f 100644 --- a/package.json +++ b/package.json @@ -56,7 +56,7 @@ "workflow-test": "./workflow_tests/scripts/runWorkflowTests.sh", "workflow-test:generate": "ts-node workflow_tests/utils/preGenerateTest.js", "setup-https": "mkcert -install && mkcert -cert-file config/webpack/certificate.pem -key-file config/webpack/key.pem dev.new.expensify.com localhost 127.0.0.1", - "e2e-test-runner-build": "tsc -p tests/e2e/tsconfig.build.json" + "e2e-test-runner-build": "ncc build tests/e2e/testRunner.js -o tests/e2e/dist/" }, "dependencies": { "@dotlottie/react-player": "^1.6.3", diff --git a/tests/e2e/TestSpec.yml b/tests/e2e/TestSpec.yml index e0dcd2b9b66d..333d3af7d03d 100644 --- a/tests/e2e/TestSpec.yml +++ b/tests/e2e/TestSpec.yml @@ -21,8 +21,7 @@ phases: test: commands: - cd zip - - npm install underscore ts-node typescript - - npx ts-node e2e/testRunner.js -- --mainAppPath app-e2eRelease.apk --deltaAppPath app-e2edeltaRelease.apk + - node testRunner.js -- --mainAppPath app-e2eRelease.apk --deltaAppPath app-e2edeltaRelease.apk artifacts: - $WORKING_DIRECTORY diff --git a/tests/e2e/tsconfig.build.json b/tests/e2e/tsconfig.build.json deleted file mode 100644 index bd445813d52b..000000000000 --- a/tests/e2e/tsconfig.build.json +++ /dev/null @@ -1,10 +0,0 @@ -{ - "extends": "../../tsconfig.json", - "compilerOptions": { - "noEmit": false, - "esModuleInterop": true, - "outDir": "dist", - "rootDir": "." - }, - "exclude": [".github/**/*"] -} From 0762d2c005d44800726cf2e85ed2be3541d8d47f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Hanno=20J=2E=20G=C3=B6decke?= Date: Thu, 29 Feb 2024 15:12:25 +0100 Subject: [PATCH 096/170] add workflow for verifying th ee2e test runner is buildable --- .github/workflows/checkE2ETestCode.yml | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 .github/workflows/checkE2ETestCode.yml diff --git a/.github/workflows/checkE2ETestCode.yml b/.github/workflows/checkE2ETestCode.yml new file mode 100644 index 000000000000..9a22c5a43df0 --- /dev/null +++ b/.github/workflows/checkE2ETestCode.yml @@ -0,0 +1,23 @@ +name: Check e2e test code + +on: + workflow_call: + pull_request: + types: [opened, synchronize] + paths: + - 'tests/e2e/**' + - 'src/libs/E2E/**' + +jobs: + lint: + if: ${{ github.actor != 'OSBotify' || github.event_name == 'workflow_call' }} + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Setup Node + uses: ./.github/actions/composite/setupNode + + - name: Compile e2e test runner + run: npm run e2e-test-runner-build \ No newline at end of file From 4e51a2ca6827ae0592fdcf9e03c7dedc0309dfc3 Mon Sep 17 00:00:00 2001 From: John Lee Date: Thu, 29 Feb 2024 12:21:55 -0500 Subject: [PATCH 097/170] Improve App GH Actions by cancelling some longer tests if a newer run is kicked off, and upgrade to cachev4 --- .github/actions/composite/setupNode/action.yml | 4 ++-- .github/workflows/e2ePerformanceTests.yml | 4 ++++ .github/workflows/lint.yml | 5 +++++ .github/workflows/platformDeploy.yml | 2 +- .github/workflows/test.yml | 6 +++++- .github/workflows/testBuild.yml | 2 +- 6 files changed, 18 insertions(+), 5 deletions(-) diff --git a/.github/actions/composite/setupNode/action.yml b/.github/actions/composite/setupNode/action.yml index 0b32d8ee6dc1..c6a6029e06e0 100644 --- a/.github/actions/composite/setupNode/action.yml +++ b/.github/actions/composite/setupNode/action.yml @@ -18,13 +18,13 @@ runs: desktop/package-lock.json - id: cache-node-modules - uses: actions/cache@v3 + uses: actions/cache@v4 with: path: node_modules key: ${{ runner.os }}-node-modules-${{ hashFiles('package-lock.json', 'patches/**') }} - id: cache-desktop-node-modules - uses: actions/cache@v3 + uses: actions/cache@v4 with: path: desktop/node_modules key: ${{ runner.os }}-desktop-node-modules-${{ hashFiles('desktop/package-lock.json', 'desktop/patches/**') }} diff --git a/.github/workflows/e2ePerformanceTests.yml b/.github/workflows/e2ePerformanceTests.yml index 338cb8313465..51868df1664f 100644 --- a/.github/workflows/e2ePerformanceTests.yml +++ b/.github/workflows/e2ePerformanceTests.yml @@ -15,6 +15,10 @@ on: type: string required: true +concurrency: + group: "${{ github.ref }}-e2e" + cancel-in-progress: true + jobs: buildBaseline: runs-on: ubuntu-latest-xl diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index 33c850823413..50e886942c98 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -7,8 +7,13 @@ on: branches-ignore: [staging, production] paths: ['**.js', '**.ts', '**.tsx', '**.json', '**.mjs', '**.cjs', 'config/.editorconfig', '.watchmanconfig', '.imgbotconfig'] +concurrency: + group: "${{ github.ref }}-lint" + cancel-in-progress: true + jobs: lint: + name: Run ESLint if: ${{ github.actor != 'OSBotify' || github.event_name == 'workflow_call' }} runs-on: ubuntu-latest steps: diff --git a/.github/workflows/platformDeploy.yml b/.github/workflows/platformDeploy.yml index 818441828bf0..4d6597334447 100644 --- a/.github/workflows/platformDeploy.yml +++ b/.github/workflows/platformDeploy.yml @@ -194,7 +194,7 @@ jobs: bundler-cache: true - name: Cache Pod dependencies - uses: actions/cache@v3 + uses: actions/cache@v4 id: pods-cache with: path: ios/Pods diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index bdc14950a337..71b4bc3d8fc3 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -7,6 +7,10 @@ on: branches-ignore: [staging, production] paths: ['**.js', '**.ts', '**.tsx', '**.sh', 'package.json', 'package-lock.json'] +concurrency: + group: "${{ github.ref }}-jest" + cancel-in-progress: true + jobs: jest: if: ${{ github.actor != 'OSBotify' && github.actor != 'imgbot[bot]' || github.event_name == 'workflow_call' }} @@ -31,7 +35,7 @@ jobs: - name: Cache Jest cache id: cache-jest-cache - uses: actions/cache@ac25611caef967612169ab7e95533cf932c32270 + uses: actions/cache@v4 with: path: .jest-cache key: ${{ runner.os }}-jest diff --git a/.github/workflows/testBuild.yml b/.github/workflows/testBuild.yml index 9548c3a6e595..3f02430f3c1f 100644 --- a/.github/workflows/testBuild.yml +++ b/.github/workflows/testBuild.yml @@ -167,7 +167,7 @@ jobs: bundler-cache: true - name: Cache Pod dependencies - uses: actions/cache@v3 + uses: actions/cache@v4 id: pods-cache with: path: ios/Pods From 8d002caa6c8babf79727738318552baa453f2480 Mon Sep 17 00:00:00 2001 From: Ishpaul Singh Date: Fri, 1 Mar 2024 00:22:25 +0530 Subject: [PATCH 098/170] refactor after merge --- src/components/ReportWelcomeText.tsx | 27 ++++++++++++++++----------- 1 file changed, 16 insertions(+), 11 deletions(-) diff --git a/src/components/ReportWelcomeText.tsx b/src/components/ReportWelcomeText.tsx index 98ff2165bb81..7d0dc6864aae 100644 --- a/src/components/ReportWelcomeText.tsx +++ b/src/components/ReportWelcomeText.tsx @@ -1,7 +1,7 @@ -import React, {useMemo} from 'react'; -import {View} from 'react-native'; -import type {OnyxEntry} from 'react-native-onyx'; -import {withOnyx} from 'react-native-onyx'; +import React, { useMemo } 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 Navigation from '@libs/Navigation/Navigation'; @@ -11,8 +11,8 @@ import * as ReportUtils from '@libs/ReportUtils'; import CONST from '@src/CONST'; import ONYXKEYS from '@src/ONYXKEYS'; import ROUTES from '@src/ROUTES'; -import type {PersonalDetailsList, Policy, Report} from '@src/types/onyx'; -import {PressableWithoutFeedback} from './Pressable'; +import type { PersonalDetailsList, Policy, Report } from '@src/types/onyx'; +import { PressableWithoutFeedback } from './Pressable'; import RenderHTML from './RenderHTML'; import Text from './Text'; import UserDetailsTooltip from './UserDetailsTooltip'; @@ -30,8 +30,8 @@ type ReportWelcomeTextProps = ReportWelcomeTextOnyxProps & { policy: OnyxEntry; }; -function ReportWelcomeText({report, policy, personalDetails}: ReportWelcomeTextProps) { - const {translate} = useLocalize(); +function ReportWelcomeText({ report, policy, personalDetails }: ReportWelcomeTextProps) { + const { translate } = useLocalize(); const styles = useThemeStyles(); const isPolicyExpenseChat = ReportUtils.isPolicyExpenseChat(report); const isChatRoom = ReportUtils.isChatRoom(report); @@ -57,7 +57,7 @@ function ReportWelcomeText({report, policy, personalDetails}: ReportWelcomeTextP const getWelcomeHeroText = useMemo(() => { if (isChatRoom) { - return translate('reportActionsView.welcomeToRoom', {roomName: reportName}); + return translate('reportActionsView.welcomeToRoom', { roomName: reportName }); } if (isSelfDM) { @@ -73,6 +73,11 @@ function ReportWelcomeText({report, policy, personalDetails}: ReportWelcomeTextP {getWelcomeHeroText} + {isSelfDM && ( + + {translate('reportActionsView.beginningOfChatHistorySelfDM')} + + )} {isPolicyExpenseChat && ( <> {policy?.description ? ( @@ -135,7 +140,7 @@ function ReportWelcomeText({report, policy, personalDetails}: ReportWelcomeTextP {isDefault && ( {translate('reportActionsView.beginningOfChatHistory')} - {displayNamesWithTooltips.map(({displayName, pronouns, accountID}, index) => ( + {displayNamesWithTooltips.map(({ displayName, pronouns, accountID }, index) => ( // eslint-disable-next-line react/no-array-index-key @@ -160,7 +165,7 @@ function ReportWelcomeText({report, policy, personalDetails}: ReportWelcomeTextP )} {(moneyRequestOptions.includes(CONST.IOU.TYPE.SEND) || moneyRequestOptions.includes(CONST.IOU.TYPE.REQUEST)) && ( - {translate('reportActionsView.usePlusButton', {additionalText})} + {translate('reportActionsView.usePlusButton', { additionalText })} )} From 4ac87bbd831ad8053310b2bc979a0fa39321c432 Mon Sep 17 00:00:00 2001 From: Ishpaul Singh Date: Fri, 1 Mar 2024 00:25:06 +0530 Subject: [PATCH 099/170] prettier --- src/components/ReportWelcomeText.tsx | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/src/components/ReportWelcomeText.tsx b/src/components/ReportWelcomeText.tsx index 7d0dc6864aae..36097b61bfe6 100644 --- a/src/components/ReportWelcomeText.tsx +++ b/src/components/ReportWelcomeText.tsx @@ -1,7 +1,7 @@ -import React, { useMemo } from 'react'; -import { View } from 'react-native'; -import type { OnyxEntry } from 'react-native-onyx'; -import { withOnyx } from 'react-native-onyx'; +import React, {useMemo} 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 Navigation from '@libs/Navigation/Navigation'; @@ -11,8 +11,8 @@ import * as ReportUtils from '@libs/ReportUtils'; import CONST from '@src/CONST'; import ONYXKEYS from '@src/ONYXKEYS'; import ROUTES from '@src/ROUTES'; -import type { PersonalDetailsList, Policy, Report } from '@src/types/onyx'; -import { PressableWithoutFeedback } from './Pressable'; +import type {PersonalDetailsList, Policy, Report} from '@src/types/onyx'; +import {PressableWithoutFeedback} from './Pressable'; import RenderHTML from './RenderHTML'; import Text from './Text'; import UserDetailsTooltip from './UserDetailsTooltip'; @@ -30,8 +30,8 @@ type ReportWelcomeTextProps = ReportWelcomeTextOnyxProps & { policy: OnyxEntry; }; -function ReportWelcomeText({ report, policy, personalDetails }: ReportWelcomeTextProps) { - const { translate } = useLocalize(); +function ReportWelcomeText({report, policy, personalDetails}: ReportWelcomeTextProps) { + const {translate} = useLocalize(); const styles = useThemeStyles(); const isPolicyExpenseChat = ReportUtils.isPolicyExpenseChat(report); const isChatRoom = ReportUtils.isChatRoom(report); @@ -57,7 +57,7 @@ function ReportWelcomeText({ report, policy, personalDetails }: ReportWelcomeTex const getWelcomeHeroText = useMemo(() => { if (isChatRoom) { - return translate('reportActionsView.welcomeToRoom', { roomName: reportName }); + return translate('reportActionsView.welcomeToRoom', {roomName: reportName}); } if (isSelfDM) { @@ -140,7 +140,7 @@ function ReportWelcomeText({ report, policy, personalDetails }: ReportWelcomeTex {isDefault && ( {translate('reportActionsView.beginningOfChatHistory')} - {displayNamesWithTooltips.map(({ displayName, pronouns, accountID }, index) => ( + {displayNamesWithTooltips.map(({displayName, pronouns, accountID}, index) => ( // eslint-disable-next-line react/no-array-index-key @@ -165,7 +165,7 @@ function ReportWelcomeText({ report, policy, personalDetails }: ReportWelcomeTex )} {(moneyRequestOptions.includes(CONST.IOU.TYPE.SEND) || moneyRequestOptions.includes(CONST.IOU.TYPE.REQUEST)) && ( - {translate('reportActionsView.usePlusButton', { additionalText })} + {translate('reportActionsView.usePlusButton', {additionalText})} )} From c8ae5590c583488f5768ce2f54be7455d9ce4b04 Mon Sep 17 00:00:00 2001 From: Ishpaul Singh Date: Fri, 1 Mar 2024 00:28:30 +0530 Subject: [PATCH 100/170] fixes leave option in header three dots --- src/libs/ReportUtils.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/src/libs/ReportUtils.ts b/src/libs/ReportUtils.ts index 86489f46a0dd..6a8e6dc336ce 100644 --- a/src/libs/ReportUtils.ts +++ b/src/libs/ReportUtils.ts @@ -4350,6 +4350,7 @@ function canLeaveRoom(report: OnyxEntry, isPolicyMember: boolean): boole report?.chatType === CONST.REPORT.CHAT_TYPE.POLICY_ANNOUNCE || report?.chatType === CONST.REPORT.CHAT_TYPE.POLICY_EXPENSE_CHAT || report?.chatType === CONST.REPORT.CHAT_TYPE.DOMAIN_ALL || + report?.chatType === CONST.REPORT.CHAT_TYPE.SELF_DM || !report?.chatType ) { // DM chats don't have a chatType From 94260352de416561bcc44618052da97221d98664 Mon Sep 17 00:00:00 2001 From: Ishpaul Singh Date: Fri, 1 Mar 2024 00:33:01 +0530 Subject: [PATCH 101/170] fix conflicts after merge --- src/components/ReportWelcomeText.tsx | 112 +++++++++++++-------------- 1 file changed, 53 insertions(+), 59 deletions(-) diff --git a/src/components/ReportWelcomeText.tsx b/src/components/ReportWelcomeText.tsx index 36097b61bfe6..1650a24fdb98 100644 --- a/src/components/ReportWelcomeText.tsx +++ b/src/components/ReportWelcomeText.tsx @@ -73,70 +73,64 @@ function ReportWelcomeText({report, policy, personalDetails}: ReportWelcomeTextP {getWelcomeHeroText} + {isPolicyExpenseChat && + (policy?.description ? ( + { + if (!canEditPolicyDescription) { + return; + } + Navigation.navigate(ROUTES.WORKSPACE_PROFILE_DESCRIPTION.getRoute(policy.id)); + }} + style={[styles.renderHTML, canEditPolicyDescription ? styles.cursorPointer : styles.cursorText]} + accessibilityLabel={translate('reportDescriptionPage.roomDescription')} + > + + + ) : ( + + {translate('reportActionsView.beginningOfChatHistoryPolicyExpenseChatPartOne')} + {ReportUtils.getDisplayNameForParticipant(report?.ownerAccountID)} + {translate('reportActionsView.beginningOfChatHistoryPolicyExpenseChatPartTwo')} + {ReportUtils.getPolicyName(report)} + {translate('reportActionsView.beginningOfChatHistoryPolicyExpenseChatPartThree')} + + ))} + {isChatRoom && + (report?.description ? ( + { + if (ReportUtils.canEditReportDescription(report, policy)) { + Navigation.navigate(ROUTES.REPORT_DESCRIPTION.getRoute(report.reportID)); + return; + } + Navigation.navigate(ROUTES.REPORT_WITH_ID_DETAILS.getRoute(report.reportID)); + }} + style={styles.renderHTML} + accessibilityLabel={translate('reportDescriptionPage.roomDescription')} + > + + + ) : ( + + {roomWelcomeMessage.phrase1} + {roomWelcomeMessage.showReportName && ( + + {ReportUtils.getReportName(report)} + + )} + {roomWelcomeMessage.phrase2 !== undefined && {roomWelcomeMessage.phrase2}} + + ))} {isSelfDM && ( {translate('reportActionsView.beginningOfChatHistorySelfDM')} )} - {isPolicyExpenseChat && ( - <> - {policy?.description ? ( - { - if (!canEditPolicyDescription) { - return; - } - Navigation.navigate(ROUTES.WORKSPACE_PROFILE_DESCRIPTION.getRoute(policy.id)); - }} - style={[styles.renderHTML, canEditPolicyDescription ? styles.cursorPointer : styles.cursorText]} - accessibilityLabel={translate('reportDescriptionPage.roomDescription')} - > - - - ) : ( - - {translate('reportActionsView.beginningOfChatHistoryPolicyExpenseChatPartOne')} - {ReportUtils.getDisplayNameForParticipant(report?.ownerAccountID)} - {translate('reportActionsView.beginningOfChatHistoryPolicyExpenseChatPartTwo')} - {ReportUtils.getPolicyName(report)} - {translate('reportActionsView.beginningOfChatHistoryPolicyExpenseChatPartThree')} - - )} - - )} - {isChatRoom && ( - <> - {report?.description ? ( - { - if (ReportUtils.canEditReportDescription(report, policy)) { - Navigation.navigate(ROUTES.REPORT_DESCRIPTION.getRoute(report.reportID)); - return; - } - Navigation.navigate(ROUTES.REPORT_WITH_ID_DETAILS.getRoute(report.reportID)); - }} - style={styles.renderHTML} - accessibilityLabel={translate('reportDescriptionPage.roomDescription')} - > - - - ) : ( - - {roomWelcomeMessage.phrase1} - {roomWelcomeMessage.showReportName && ( - - {ReportUtils.getReportName(report)} - - )} - {roomWelcomeMessage.phrase2 !== undefined && {roomWelcomeMessage.phrase2}} - - )} - - )} {isDefault && ( {translate('reportActionsView.beginningOfChatHistory')} From 04b561f06eb8e85aa16a173afb16025c1491f0ce Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Hanno=20J=2E=20G=C3=B6decke?= Date: Thu, 29 Feb 2024 20:09:39 +0100 Subject: [PATCH 102/170] Update .github/workflows/checkE2ETestCode.yml Co-authored-by: Andrew Gable --- .github/workflows/checkE2ETestCode.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/checkE2ETestCode.yml b/.github/workflows/checkE2ETestCode.yml index 9a22c5a43df0..77c40336bf4f 100644 --- a/.github/workflows/checkE2ETestCode.yml +++ b/.github/workflows/checkE2ETestCode.yml @@ -1,4 +1,4 @@ -name: Check e2e test code +name: Check e2e test code builds correctly on: workflow_call: From 682c359ebdc05dbc79e0af69451123e2136f5b62 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Hanno=20J=2E=20G=C3=B6decke?= Date: Thu, 29 Feb 2024 20:09:48 +0100 Subject: [PATCH 103/170] Update .github/workflows/checkE2ETestCode.yml Co-authored-by: Andrew Gable --- .github/workflows/checkE2ETestCode.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/checkE2ETestCode.yml b/.github/workflows/checkE2ETestCode.yml index 77c40336bf4f..090b7a7f23e4 100644 --- a/.github/workflows/checkE2ETestCode.yml +++ b/.github/workflows/checkE2ETestCode.yml @@ -19,5 +19,5 @@ jobs: - name: Setup Node uses: ./.github/actions/composite/setupNode - - name: Compile e2e test runner + - name: Verify e2e tests compile correctly run: npm run e2e-test-runner-build \ No newline at end of file From 5d7a997148152a43181329ed110f7d03c3e04067 Mon Sep 17 00:00:00 2001 From: Ishpaul Singh Date: Fri, 1 Mar 2024 00:44:24 +0530 Subject: [PATCH 104/170] fix postfix for visible for self dm --- src/libs/ReportUtils.ts | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/libs/ReportUtils.ts b/src/libs/ReportUtils.ts index 6a8e6dc336ce..d93b9b89c408 100644 --- a/src/libs/ReportUtils.ts +++ b/src/libs/ReportUtils.ts @@ -1647,8 +1647,9 @@ function getDisplayNameForParticipant(accountID?: number, shouldUseShortForm = f return formattedLogin; } - // todo: remove this once we have a better way to handle this - const shouldAddPostfix = shouldAddCurrentUserPostfix && accountID !== currentUserAccountID; + // for selfDm, we show user dispalyName + (You) as postfix + const shouldAddPostfix = shouldAddCurrentUserPostfix && accountID === currentUserAccountID; + const longName = PersonalDetailsUtils.getDisplayNameOrDefault(personalDetails, formattedLogin, shouldFallbackToHidden, shouldAddPostfix); // If the user's personal details (first name) should be hidden, make sure we return "hidden" instead of the short name From 98859d70c874121f69ddf28011871a1040a1a211 Mon Sep 17 00:00:00 2001 From: jeremy-croff Date: Thu, 29 Feb 2024 14:48:01 -0600 Subject: [PATCH 105/170] fix(35600): reset artifactory --- package-lock.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package-lock.json b/package-lock.json index d925e0733610..f1836fae3e6f 100644 --- a/package-lock.json +++ b/package-lock.json @@ -28599,7 +28599,7 @@ }, "node_modules/electron": { "version": "29.0.0", - "resolved": "https://registry.npmjs.intuit.com:443/artifactory/api/npm/npm-intuit/electron/-/electron-29.0.0.tgz", + "resolved": "https://registry.npmjs.org/electron/-/electron-29.0.0.tgz", "integrity": "sha512-HhrRC5vWb6fAbWXP3A6ABwKUO9JvYSC4E141RzWFgnDBqNiNtabfmgC8hsVeCR65RQA2MLSDgC8uP52I9zFllQ==", "dev": true, "hasInstallScript": true, From 3f0f86bb5d8e01123d3d42afb5c2428ccb2ba40e Mon Sep 17 00:00:00 2001 From: Rushat Gabhane Date: Fri, 1 Mar 2024 00:27:43 +0300 Subject: [PATCH 106/170] rename sections array --- .../workspace/workflows/WorkspaceWorkflowsApproverPage.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pages/workspace/workflows/WorkspaceWorkflowsApproverPage.tsx b/src/pages/workspace/workflows/WorkspaceWorkflowsApproverPage.tsx index 4cbdedc2be2d..6c282d5c8d3e 100644 --- a/src/pages/workspace/workflows/WorkspaceWorkflowsApproverPage.tsx +++ b/src/pages/workspace/workflows/WorkspaceWorkflowsApproverPage.tsx @@ -111,7 +111,7 @@ function WorkspaceWorkflowsApproverPage({policy, policyMembers, personalDetails, }, [personalDetails, policyMembers, translate, policy?.approver]); const sections: MembersSection[] = useMemo(() => { - const sectionsArr: MembersSection[] = []; + const sectionsArray: MembersSection[] = []; if (searchTerm !== '') { const filteredOptions = [...formattedApprover, ...formattedPolicyMembers].filter((option) => { From 784ef760bf5f5bae5de70e10242d53f795750948 Mon Sep 17 00:00:00 2001 From: Rushat Gabhane Date: Fri, 1 Mar 2024 00:27:48 +0300 Subject: [PATCH 107/170] rename sections array --- .../workspace/workflows/WorkspaceWorkflowsApproverPage.tsx | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/pages/workspace/workflows/WorkspaceWorkflowsApproverPage.tsx b/src/pages/workspace/workflows/WorkspaceWorkflowsApproverPage.tsx index 6c282d5c8d3e..a668787a4775 100644 --- a/src/pages/workspace/workflows/WorkspaceWorkflowsApproverPage.tsx +++ b/src/pages/workspace/workflows/WorkspaceWorkflowsApproverPage.tsx @@ -130,21 +130,21 @@ function WorkspaceWorkflowsApproverPage({policy, policyMembers, personalDetails, ]; } - sectionsArr.push({ + sectionsArray.push({ title: undefined, data: formattedApprover, shouldShow: formattedApprover.length > 0, indexOffset: 0, }); - sectionsArr.push({ + sectionsArray.push({ title: translate('common.all'), data: formattedPolicyMembers, shouldShow: true, indexOffset: formattedApprover.length, }); - return sectionsArr; + return sectionsArray; }, [formattedPolicyMembers, formattedApprover, searchTerm, translate]); const headerMessage = useMemo(() => (searchTerm && !sections[0].data.length ? translate('common.noResultsFound') : ''), [translate, sections]); From 91f53696c5560c3ea0d2e94f18d46dbfa71b5cbe Mon Sep 17 00:00:00 2001 From: Rushat Gabhane Date: Fri, 1 Mar 2024 00:31:04 +0300 Subject: [PATCH 108/170] fix deps arr --- .../workspace/workflows/WorkspaceWorkflowsApproverPage.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pages/workspace/workflows/WorkspaceWorkflowsApproverPage.tsx b/src/pages/workspace/workflows/WorkspaceWorkflowsApproverPage.tsx index a668787a4775..66a595aaad87 100644 --- a/src/pages/workspace/workflows/WorkspaceWorkflowsApproverPage.tsx +++ b/src/pages/workspace/workflows/WorkspaceWorkflowsApproverPage.tsx @@ -108,7 +108,7 @@ function WorkspaceWorkflowsApproverPage({policy, policyMembers, personalDetails, } }); return [policyMemberDetails, approverDetails]; - }, [personalDetails, policyMembers, translate, policy?.approver]); + }, [personalDetails, policyMembers, translate, policy?.approver, StyleUtils, isDeletedPolicyMember, policy?.owner, styles]); const sections: MembersSection[] = useMemo(() => { const sectionsArray: MembersSection[] = []; From 279592b5c7f60200209edf5a56f087271bf48829 Mon Sep 17 00:00:00 2001 From: Ishpaul Singh Date: Fri, 1 Mar 2024 03:10:35 +0530 Subject: [PATCH 109/170] fix user-avatar an share destination issue --- src/libs/OptionsListUtils.ts | 8 ++++++-- src/libs/ReportUtils.ts | 4 ++++ src/pages/home/report/ReportActionItemCreated.tsx | 1 - 3 files changed, 10 insertions(+), 3 deletions(-) diff --git a/src/libs/OptionsListUtils.ts b/src/libs/OptionsListUtils.ts index 98f752703389..ac820b53128d 100644 --- a/src/libs/OptionsListUtils.ts +++ b/src/libs/OptionsListUtils.ts @@ -1465,7 +1465,11 @@ function getOptions( const isPolicyExpenseChat = ReportUtils.isPolicyExpenseChat(report); const isMoneyRequestReport = ReportUtils.isMoneyRequestReport(report); const isSelfDM = ReportUtils.isSelfDM(report); - const accountIDs = report.visibleChatMemberAccountIDs ?? []; + let accountIDs = report.visibleChatMemberAccountIDs ?? []; + + if (isSelfDM) { + accountIDs = [currentUserAccountID ?? 0]; + } if (isPolicyExpenseChat && report.isOwnPolicyExpenseChat && !includeOwnedWorkspaceChats) { return; @@ -1475,7 +1479,7 @@ function getOptions( if (!includeP2P && !isPolicyExpenseChat) { return; } - + console.log('report', isSelfDM, includeSelfDM, report); if (isSelfDM && !includeSelfDM) { return; } diff --git a/src/libs/ReportUtils.ts b/src/libs/ReportUtils.ts index d93b9b89c408..b5179ced8d0d 100644 --- a/src/libs/ReportUtils.ts +++ b/src/libs/ReportUtils.ts @@ -1610,6 +1610,10 @@ function getIcons( return isPayer ? [managerIcon, ownerIcon] : [ownerIcon, managerIcon]; } + if (isSelfDM(report)) { + return getIconsForParticipants([currentUserAccountID ?? 0], personalDetails); + } + return getIconsForParticipants(report?.participantAccountIDs ?? [], personalDetails); } diff --git a/src/pages/home/report/ReportActionItemCreated.tsx b/src/pages/home/report/ReportActionItemCreated.tsx index 95578c10e816..61ee63486700 100644 --- a/src/pages/home/report/ReportActionItemCreated.tsx +++ b/src/pages/home/report/ReportActionItemCreated.tsx @@ -47,7 +47,6 @@ function ReportActionItemCreated(props: ReportActionItemCreatedProps) { if (!ReportUtils.isChatReport(props.report)) { return null; } - const icons = ReportUtils.getIcons(props.report, props.personalDetails); const shouldDisableDetailPage = ReportUtils.shouldDisableDetailPage(props.report); From 266cea694aaa1659449def50d15d26ea59123940 Mon Sep 17 00:00:00 2001 From: Ishpaul Singh Date: Fri, 1 Mar 2024 03:16:07 +0530 Subject: [PATCH 110/170] remove console log --- src/libs/OptionsListUtils.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libs/OptionsListUtils.ts b/src/libs/OptionsListUtils.ts index ac820b53128d..ae89cd202ca7 100644 --- a/src/libs/OptionsListUtils.ts +++ b/src/libs/OptionsListUtils.ts @@ -1479,7 +1479,7 @@ function getOptions( if (!includeP2P && !isPolicyExpenseChat) { return; } - console.log('report', isSelfDM, includeSelfDM, report); + if (isSelfDM && !includeSelfDM) { return; } From 8582f292016075e957b967f4fa6c1bc6d33ee464 Mon Sep 17 00:00:00 2001 From: Rushat Gabhane Date: Fri, 1 Mar 2024 00:46:13 +0300 Subject: [PATCH 111/170] rm unused --- src/pages/workspace/workflows/WorkspaceWorkflowsPage.tsx | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/pages/workspace/workflows/WorkspaceWorkflowsPage.tsx b/src/pages/workspace/workflows/WorkspaceWorkflowsPage.tsx index afcf7351f219..282ddedd650f 100644 --- a/src/pages/workspace/workflows/WorkspaceWorkflowsPage.tsx +++ b/src/pages/workspace/workflows/WorkspaceWorkflowsPage.tsx @@ -11,9 +11,7 @@ import useStyleUtils from '@hooks/useStyleUtils'; import useThemeStyles from '@hooks/useThemeStyles'; import useWindowDimensions from '@hooks/useWindowDimensions'; 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 type {CentralPaneNavigatorParamList} from '@navigation/types'; import withPolicy from '@pages/workspace/withPolicy'; import type {WithPolicyProps} from '@pages/workspace/withPolicy'; From 75e19460ba6b9989c0c9428741b8e0f59cd28591 Mon Sep 17 00:00:00 2001 From: Rushat Gabhane Date: Fri, 1 Mar 2024 01:22:37 +0300 Subject: [PATCH 112/170] show approver display name --- src/libs/PersonalDetailsUtils.ts | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/libs/PersonalDetailsUtils.ts b/src/libs/PersonalDetailsUtils.ts index 55aee10e611a..a1de0945c4c1 100644 --- a/src/libs/PersonalDetailsUtils.ts +++ b/src/libs/PersonalDetailsUtils.ts @@ -56,6 +56,10 @@ function getPersonalDetailsByIDs(accountIDs: number[], currentUserAccountID: num return result; } +function getPersonalDetailByEmail(email: string): PersonalDetails | undefined { + return Object.entries(allPersonalDetails ?? {}).find(([_, detail]) => detail?.login === email) as unknown as PersonalDetails; +} + /** * Given a list of logins, find the associated personal detail and return related accountIDs. * From e717feac0e225b9e50dadf70b5bddbe7d32b09ac Mon Sep 17 00:00:00 2001 From: Rushat Gabhane Date: Fri, 1 Mar 2024 01:22:44 +0300 Subject: [PATCH 113/170] show approver display name --- src/libs/PersonalDetailsUtils.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/src/libs/PersonalDetailsUtils.ts b/src/libs/PersonalDetailsUtils.ts index a1de0945c4c1..f2a375ce5ab8 100644 --- a/src/libs/PersonalDetailsUtils.ts +++ b/src/libs/PersonalDetailsUtils.ts @@ -267,6 +267,7 @@ export { isPersonalDetailsEmpty, getDisplayNameOrDefault, getPersonalDetailsByIDs, + getPersonalDetailByEmail, getAccountIDsByLogins, getLoginsByAccountIDs, getNewPersonalDetailsOnyxData, From 2201a274985f60b2b064de6e30b2477a2df2c6ba Mon Sep 17 00:00:00 2001 From: Rushat Gabhane Date: Fri, 1 Mar 2024 01:22:48 +0300 Subject: [PATCH 114/170] show approver display name --- src/pages/workspace/workflows/WorkspaceWorkflowsPage.tsx | 1 + 1 file changed, 1 insertion(+) diff --git a/src/pages/workspace/workflows/WorkspaceWorkflowsPage.tsx b/src/pages/workspace/workflows/WorkspaceWorkflowsPage.tsx index 282ddedd650f..253bb5073dee 100644 --- a/src/pages/workspace/workflows/WorkspaceWorkflowsPage.tsx +++ b/src/pages/workspace/workflows/WorkspaceWorkflowsPage.tsx @@ -11,6 +11,7 @@ import useStyleUtils from '@hooks/useStyleUtils'; import useThemeStyles from '@hooks/useThemeStyles'; import useWindowDimensions from '@hooks/useWindowDimensions'; import Navigation from '@libs/Navigation/Navigation'; +import * as PersonalDetailsUtils from '@libs/PersonalDetailsUtils'; import * as PolicyUtils from '@libs/PolicyUtils'; import type {CentralPaneNavigatorParamList} from '@navigation/types'; import withPolicy from '@pages/workspace/withPolicy'; From da7246721edf546dbb1503bb94f28b9ae788b8ed Mon Sep 17 00:00:00 2001 From: Rushat Gabhane Date: Fri, 1 Mar 2024 01:22:54 +0300 Subject: [PATCH 115/170] show approver display name --- src/pages/workspace/workflows/WorkspaceWorkflowsPage.tsx | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/pages/workspace/workflows/WorkspaceWorkflowsPage.tsx b/src/pages/workspace/workflows/WorkspaceWorkflowsPage.tsx index 253bb5073dee..55e310db668f 100644 --- a/src/pages/workspace/workflows/WorkspaceWorkflowsPage.tsx +++ b/src/pages/workspace/workflows/WorkspaceWorkflowsPage.tsx @@ -33,7 +33,8 @@ function WorkspaceWorkflowsPage({policy, route}: WorkspaceWorkflowsPageProps) { const {isSmallScreenWidth} = useWindowDimensions(); const {isOffline} = useNetwork(); - const policyApprover = policy?.approver; + const policyApproverEmail = policy?.approver; + const policyApproverName = useMemo(() => PersonalDetailsUtils.getPersonalDetailByEmail(policyApproverEmail ?? '')?.displayName || policyApproverEmail, [policyApproverEmail]); const containerStyle = useMemo(() => [styles.ph8, styles.mhn8, styles.ml11, styles.pv3, styles.pr0, styles.pl4, styles.mr0, styles.widthAuto, styles.mt4], [styles]); const items: ToggleSettingOptionRowProps[] = useMemo( From b00f2c7b916d857479faa5a9a723b11aa33435ee Mon Sep 17 00:00:00 2001 From: Rushat Gabhane Date: Fri, 1 Mar 2024 01:23:01 +0300 Subject: [PATCH 116/170] show approver display name --- src/pages/workspace/workflows/WorkspaceWorkflowsPage.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pages/workspace/workflows/WorkspaceWorkflowsPage.tsx b/src/pages/workspace/workflows/WorkspaceWorkflowsPage.tsx index 55e310db668f..93719ab4130d 100644 --- a/src/pages/workspace/workflows/WorkspaceWorkflowsPage.tsx +++ b/src/pages/workspace/workflows/WorkspaceWorkflowsPage.tsx @@ -74,7 +74,7 @@ function WorkspaceWorkflowsPage({policy, route}: WorkspaceWorkflowsPageProps) { title={translate('workflowsPage.approver')} titleStyle={styles.textLabelSupportingNormal} descriptionTextStyle={styles.textNormalThemeText} - description={policyApprover ?? ''} + description={policyApproverName ?? ''} onPress={() => Navigation.navigate(ROUTES.WORKSPACE_WORKFLOWS_APPROVER.getRoute(route.params.policyID))} // TODO will be done in https://github.com/Expensify/Expensify/issues/368334 shouldShowRightIcon From fd23672aa01098f43a84103aee7b611ff37bbc6d Mon Sep 17 00:00:00 2001 From: Rushat Gabhane Date: Fri, 1 Mar 2024 01:23:05 +0300 Subject: [PATCH 117/170] show approver display name --- src/pages/workspace/workflows/WorkspaceWorkflowsPage.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pages/workspace/workflows/WorkspaceWorkflowsPage.tsx b/src/pages/workspace/workflows/WorkspaceWorkflowsPage.tsx index 93719ab4130d..0219efddd97d 100644 --- a/src/pages/workspace/workflows/WorkspaceWorkflowsPage.tsx +++ b/src/pages/workspace/workflows/WorkspaceWorkflowsPage.tsx @@ -109,7 +109,7 @@ function WorkspaceWorkflowsPage({policy, route}: WorkspaceWorkflowsPageProps) { isActive: false, // TODO will be done in https://github.com/Expensify/Expensify/issues/368335 }, ], - [policy, route.params.policyID, styles, translate, policyApprover, containerStyle, isOffline, StyleUtils], + [policy, route.params.policyID, styles, translate, policyApproverName, containerStyle, isOffline, StyleUtils], ); const renderItem = ({item}: {item: ToggleSettingOptionRowProps}) => ( From e08f21791e7ea9004e9e7629fdb743ddbff29292 Mon Sep 17 00:00:00 2001 From: Rushat Gabhane Date: Fri, 1 Mar 2024 01:38:24 +0300 Subject: [PATCH 118/170] fix func --- src/libs/PersonalDetailsUtils.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libs/PersonalDetailsUtils.ts b/src/libs/PersonalDetailsUtils.ts index f2a375ce5ab8..30d0bab9fb35 100644 --- a/src/libs/PersonalDetailsUtils.ts +++ b/src/libs/PersonalDetailsUtils.ts @@ -57,7 +57,7 @@ function getPersonalDetailsByIDs(accountIDs: number[], currentUserAccountID: num } function getPersonalDetailByEmail(email: string): PersonalDetails | undefined { - return Object.entries(allPersonalDetails ?? {}).find(([_, detail]) => detail?.login === email) as unknown as PersonalDetails; + return Object.values(allPersonalDetails ?? {}).find((detail) => detail?.login === email) as unknown as PersonalDetails; } /** From 3d4e4c727056d197d256a706f07af95310d31cfc Mon Sep 17 00:00:00 2001 From: Ishpaul Singh Date: Fri, 1 Mar 2024 04:28:10 +0530 Subject: [PATCH 119/170] fixes infinite loading when first load --- src/libs/ReportUtils.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libs/ReportUtils.ts b/src/libs/ReportUtils.ts index b5179ced8d0d..69992852d7bb 100644 --- a/src/libs/ReportUtils.ts +++ b/src/libs/ReportUtils.ts @@ -2571,7 +2571,7 @@ function getReportName(report: OnyxEntry, policy: OnyxEntry = nu } if (isSelfDM(report)) { - formattedName = getDisplayNameForParticipant(report?.participantAccountIDs?.[0], undefined, undefined, true); + formattedName = getDisplayNameForParticipant(currentUserAccountID, undefined, undefined, true); } if (formattedName) { From dfc0dde2ed0b190154f66e804ea5d929bb3e4d61 Mon Sep 17 00:00:00 2001 From: Bernhard Owen Josephus Date: Fri, 1 Mar 2024 14:46:02 +0800 Subject: [PATCH 120/170] fix sign in modal closed too early --- .../Navigation/AppNavigator/AuthScreens.tsx | 3 +- src/pages/home/report/ReportFooter.js | 16 +++++++-- src/pages/signin/SignInModal.tsx | 33 +++++++++++++------ 3 files changed, 37 insertions(+), 15 deletions(-) diff --git a/src/libs/Navigation/AppNavigator/AuthScreens.tsx b/src/libs/Navigation/AppNavigator/AuthScreens.tsx index 00c96d436496..30a8010ad801 100644 --- a/src/libs/Navigation/AppNavigator/AuthScreens.tsx +++ b/src/libs/Navigation/AppNavigator/AuthScreens.tsx @@ -81,8 +81,7 @@ Onyx.connect({ currentAccountID = value.accountID ?? -1; if (Navigation.isActiveRoute(ROUTES.SIGN_IN_MODAL)) { - // This means sign in in RHP was successful, so we can dismiss the modal and subscribe to user events - Navigation.dismissModal(); + // This means sign in in RHP was successful, so we can subscribe to user events User.subscribeToUserEvents(); } }, diff --git a/src/pages/home/report/ReportFooter.js b/src/pages/home/report/ReportFooter.js index 1761e135481a..7372d3fb4854 100644 --- a/src/pages/home/report/ReportFooter.js +++ b/src/pages/home/report/ReportFooter.js @@ -16,7 +16,6 @@ import * as ReportUtils from '@libs/ReportUtils'; import reportPropTypes from '@pages/reportPropTypes'; import variables from '@styles/variables'; import * as Report from '@userActions/Report'; -import * as Session from '@userActions/Session'; import * as Task from '@userActions/Task'; import CONST from '@src/CONST'; import ONYXKEYS from '@src/ONYXKEYS'; @@ -43,6 +42,12 @@ const propTypes = { /** Whether to show the compose input */ shouldShowComposeInput: PropTypes.bool, + /** Session info for the currently logged in user. */ + session: PropTypes.shape({ + /** Currently logged in user auth token type */ + authTokenType: PropTypes.string, + }), + ...windowDimensionsPropTypes, }; @@ -54,6 +59,7 @@ const defaultProps = { lastReportAction: null, isEmptyChat: true, shouldShowComposeInput: false, + session: {}, }; function ReportFooter(props) { @@ -61,7 +67,7 @@ function ReportFooter(props) { const {isOffline} = useNetwork(); const chatFooterStyles = {...styles.chatFooter, minHeight: !isOffline ? CONST.CHAT_FOOTER_MIN_HEIGHT : 0}; const isArchivedRoom = ReportUtils.isArchivedRoom(props.report); - const isAnonymousUser = Session.isAnonymousUser(); + const isAnonymousUser = props.session.authTokenType === 'anonymousAccount'; const isSmallSizeLayout = props.windowWidth - (props.isSmallScreenWidth ? 0 : variables.sideBarWidth) < variables.anonymousReportFooterBreakpoint; const hideComposer = !ReportUtils.canUserPerformWriteAction(props.report); @@ -159,6 +165,9 @@ export default compose( key: ONYXKEYS.SHOULD_SHOW_COMPOSE_INPUT, initialValue: false, }, + session: { + key: ONYXKEYS.SESSION, + }, }), )( memo( @@ -173,6 +182,7 @@ export default compose( prevProps.shouldShowComposeInput === nextProps.shouldShowComposeInput && prevProps.windowWidth === nextProps.windowWidth && prevProps.isSmallScreenWidth === nextProps.isSmallScreenWidth && - prevProps.isReportReadyForDisplay === nextProps.isReportReadyForDisplay, + prevProps.isReportReadyForDisplay === nextProps.isReportReadyForDisplay && + isEqual(prevProps.session, nextProps.session), ), ); diff --git a/src/pages/signin/SignInModal.tsx b/src/pages/signin/SignInModal.tsx index 60350adae26a..c850c586af79 100644 --- a/src/pages/signin/SignInModal.tsx +++ b/src/pages/signin/SignInModal.tsx @@ -1,23 +1,34 @@ -import React from 'react'; +import React, {useEffect} from 'react'; +import type {OnyxEntry} from 'react-native-onyx'; +import {withOnyx} from 'react-native-onyx'; import HeaderWithBackButton from '@components/HeaderWithBackButton'; import ScreenWrapper from '@components/ScreenWrapper'; import useStyleUtils from '@hooks/useStyleUtils'; import useTheme from '@hooks/useTheme'; import Navigation from '@libs/Navigation/Navigation'; -import * as Session from '@userActions/Session'; +import ONYXKEYS from '@src/ONYXKEYS'; import SCREENS from '@src/SCREENS'; +import type {Session} from '@src/types/onyx'; import SignInPage from './SignInPage'; -function SignInModal() { +type SignInModalOnyxProps = { + session: OnyxEntry; +}; + +type SignInModalProps = SignInModalOnyxProps; + +function SignInModal({session}: SignInModalProps) { const theme = useTheme(); const StyleUtils = useStyleUtils(); - if (!Session.isAnonymousUser()) { - // Signing in RHP is only for anonymous users - Navigation.isNavigationReady().then(() => { - Navigation.dismissModal(); - }); - } + useEffect(() => { + const isAnonymousUser = session?.authTokenType === 'anonymousAccount'; + if (!isAnonymousUser) { + // Signing in RHP is only for anonymous users + Navigation.isNavigationReady().then(Navigation.dismissModal); + } + }, [session?.authTokenType]); + return ( ({ + session: {key: ONYXKEYS.SESSION}, +})(SignInModal); From d0be45986ea4451c3b6709553d9e624d3b046f67 Mon Sep 17 00:00:00 2001 From: Bernhard Owen Josephus Date: Fri, 1 Mar 2024 14:56:03 +0800 Subject: [PATCH 121/170] fix ts error --- src/pages/signin/SignInModal.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pages/signin/SignInModal.tsx b/src/pages/signin/SignInModal.tsx index c850c586af79..741074fa952b 100644 --- a/src/pages/signin/SignInModal.tsx +++ b/src/pages/signin/SignInModal.tsx @@ -25,7 +25,7 @@ function SignInModal({session}: SignInModalProps) { const isAnonymousUser = session?.authTokenType === 'anonymousAccount'; if (!isAnonymousUser) { // Signing in RHP is only for anonymous users - Navigation.isNavigationReady().then(Navigation.dismissModal); + Navigation.isNavigationReady().then(() => Navigation.dismissModal()); } }, [session?.authTokenType]); From 02db6f01fe95d10c2a11ef686f13c04fc5701d57 Mon Sep 17 00:00:00 2001 From: Ishpaul Singh Date: Fri, 1 Mar 2024 16:11:52 +0530 Subject: [PATCH 122/170] fixes review comments --- src/languages/en.ts | 3 +-- src/languages/es.ts | 4 ++-- src/libs/ReportUtils.ts | 7 ++++++- src/pages/home/HeaderView.js | 11 +++++++---- 4 files changed, 16 insertions(+), 9 deletions(-) diff --git a/src/languages/en.ts b/src/languages/en.ts index 0161495a4490..af2573e7ceae 100755 --- a/src/languages/en.ts +++ b/src/languages/en.ts @@ -492,8 +492,7 @@ export default { beginningOfChatHistoryPolicyExpenseChatPartOne: 'Collaboration between ', beginningOfChatHistoryPolicyExpenseChatPartTwo: ' and ', beginningOfChatHistoryPolicyExpenseChatPartThree: ' starts here! 🎉 This is the place to chat, request money and settle up.', - // todo: confirm this copy - beginningOfChatHistorySelfDM: 'This is your personal space. Use it to chat with yourself, take notes, or save links.', + beginningOfChatHistorySelfDM: 'This is your personal space. Use it for notes, tasks, drafts, and reminders.', chatWithAccountManager: 'Chat with your account manager here', sayHello: 'Say hello!', yourSpace: 'Your space', diff --git a/src/languages/es.ts b/src/languages/es.ts index da2f7ba9c768..daf20cd4cdcf 100644 --- a/src/languages/es.ts +++ b/src/languages/es.ts @@ -485,8 +485,8 @@ export default { beginningOfChatHistoryPolicyExpenseChatPartOne: '¡La colaboración entre ', beginningOfChatHistoryPolicyExpenseChatPartTwo: ' y ', beginningOfChatHistoryPolicyExpenseChatPartThree: ' empieza aquí! 🎉 Este es el lugar donde chatear, pedir dinero y pagar.', - // todo: confirm this copy and ask for the correct translation - beginningOfChatHistorySelfDM: 'This is your personal space. Use it to chat with yourself, take notes, or save links.', + // todo: ask for the correct translation + beginningOfChatHistorySelfDM: 'This is your personal space. Use it for notes, tasks, drafts, and reminders.', chatWithAccountManager: 'Chatea con tu gestor de cuenta aquí', sayHello: '¡Saluda!', // todo: ask for the correct translation diff --git a/src/libs/ReportUtils.ts b/src/libs/ReportUtils.ts index 69992852d7bb..ba4cdc02c83c 100644 --- a/src/libs/ReportUtils.ts +++ b/src/libs/ReportUtils.ts @@ -2630,7 +2630,12 @@ function getParentNavigationSubtitle(report: OnyxEntry): ParentNavigatio function navigateToDetailsPage(report: OnyxEntry) { const participantAccountIDs = report?.participantAccountIDs ?? []; - if (isOneOnOneChat(report) || isSelfDM(report)) { + if (isSelfDM(report)) { + Navigation.navigate(ROUTES.PROFILE.getRoute(currentUserAccountID ?? 0)); + return; + } + + if (isOneOnOneChat(report)) { Navigation.navigate(ROUTES.PROFILE.getRoute(participantAccountIDs[0])); return; } diff --git a/src/pages/home/HeaderView.js b/src/pages/home/HeaderView.js index 20bee42cb89b..a58a8c3834cc 100644 --- a/src/pages/home/HeaderView.js +++ b/src/pages/home/HeaderView.js @@ -93,10 +93,13 @@ function HeaderView(props) { const {translate} = useLocalize(); const theme = useTheme(); const styles = useThemeStyles(); - const participants = lodashGet(props.report, 'participantAccountIDs', []); + const isSelfDM = ReportUtils.isSelfDM(props.report); + let participants = lodashGet(props.report, 'participantAccountIDs', []); + if (isSelfDM) { + participants = [props.session.accountID]; + } const participantPersonalDetails = OptionsListUtils.getPersonalDetailsForAccountIDs(participants, props.personalDetails); const isMultipleParticipant = participants.length > 1; - const isSelfDM = ReportUtils.isSelfDM(props.report, props.session.accountID); const displayNamesWithTooltips = ReportUtils.getDisplayNamesWithTooltips(participantPersonalDetails, isMultipleParticipant, undefined, isSelfDM); const isChatThread = ReportUtils.isChatThread(props.report); @@ -168,7 +171,7 @@ function HeaderView(props) { ), ); - const canJoinOrLeave = isChatThread || isUserCreatedPolicyRoom || canLeaveRoom; + const canJoinOrLeave = isChatThread || !isSelfDM || isUserCreatedPolicyRoom || canLeaveRoom; const canJoin = canJoinOrLeave && !isWhisperAction && props.report.notificationPreference === CONST.REPORT.NOTIFICATION_PREFERENCE.HIDDEN; const canLeave = canJoinOrLeave && ((isChatThread && props.report.notificationPreference.length) || isUserCreatedPolicyRoom || canLeaveRoom); if (canJoin) { @@ -196,7 +199,7 @@ function HeaderView(props) { ); const renderAdditionalText = () => { - if (shouldShowSubtitle() || isPersonalExpenseChat || _.isEmpty(policyName) || !_.isEmpty(parentNavigationSubtitleData)) { + if (shouldShowSubtitle() || isPersonalExpenseChat || _.isEmpty(policyName) || !_.isEmpty(parentNavigationSubtitleData) || isSelfDM) { return null; } return ( From 806c248a6d6d0d826c5d554fb397a8506671abdc Mon Sep 17 00:00:00 2001 From: Ishpaul Singh Date: Fri, 1 Mar 2024 16:55:33 +0530 Subject: [PATCH 123/170] fixes self dm not showing in lhn --- src/libs/ReportUtils.ts | 9 ++++++++- src/libs/SidebarUtils.ts | 9 ++++++++- src/pages/home/sidebar/SidebarLinksData.js | 2 ++ 3 files changed, 18 insertions(+), 2 deletions(-) diff --git a/src/libs/ReportUtils.ts b/src/libs/ReportUtils.ts index ba4cdc02c83c..2aa3733bf400 100644 --- a/src/libs/ReportUtils.ts +++ b/src/libs/ReportUtils.ts @@ -3923,6 +3923,7 @@ function shouldReportBeInOptionList({ policies, excludeEmptyChats, doesReportHaveViolations, + includeSelfDM = false, }: { report: OnyxEntry; currentReportId: string; @@ -3931,6 +3932,7 @@ function shouldReportBeInOptionList({ policies: OnyxCollection; excludeEmptyChats: boolean; doesReportHaveViolations: boolean; + includeSelfDM: boolean; }) { const isInDefaultMode = !isInGSDMode; // Exclude reports that have no data because there wouldn't be anything to show in the option item. @@ -3952,7 +3954,8 @@ function shouldReportBeInOptionList({ !isUserCreatedPolicyRoom(report) && !isArchivedRoom(report) && !isMoneyRequestReport(report) && - !isTaskReport(report)) + !isTaskReport(report) && + !isSelfDM(report)) ) { return false; } @@ -4014,6 +4017,10 @@ function shouldReportBeInOptionList({ return false; } + if (includeSelfDM && isSelfDM(report)) { + return true; + } + return true; } diff --git a/src/libs/SidebarUtils.ts b/src/libs/SidebarUtils.ts index ef14af28e8e9..7b8496fdd74d 100644 --- a/src/libs/SidebarUtils.ts +++ b/src/libs/SidebarUtils.ts @@ -92,6 +92,7 @@ function getOrderedReportIDs( policies, excludeEmptyChats: true, doesReportHaveViolations, + includeSelfDM: true, }); }); @@ -221,7 +222,13 @@ function getOptionData({ isDeletedParentAction: false, }; - const participantPersonalDetailList = Object.values(OptionsListUtils.getPersonalDetailsForAccountIDs(report.participantAccountIDs ?? [], personalDetails)) as PersonalDetails[]; + let participantAccountIDs = report.participantAccountIDs ?? []; + + if (ReportUtils.isSelfDM(report)) { + participantAccountIDs = [report.ownerAccountID ?? 0]; + } + + const participantPersonalDetailList = Object.values(OptionsListUtils.getPersonalDetailsForAccountIDs(participantAccountIDs, personalDetails)) as PersonalDetails[]; const personalDetail = participantPersonalDetailList[0] ?? {}; const hasErrors = Object.keys(result.allReportErrors ?? {}).length !== 0; diff --git a/src/pages/home/sidebar/SidebarLinksData.js b/src/pages/home/sidebar/SidebarLinksData.js index c4cc0713c596..c8b1a7137cab 100644 --- a/src/pages/home/sidebar/SidebarLinksData.js +++ b/src/pages/home/sidebar/SidebarLinksData.js @@ -188,6 +188,8 @@ function SidebarLinksData({ currentReportIDRef.current = currentReportID; const isActiveReport = useCallback((reportID) => currentReportIDRef.current === reportID, []); + console.log('SidebarLinksData', optionListItemsWithCurrentReport); + return ( Date: Fri, 1 Mar 2024 17:02:36 +0530 Subject: [PATCH 124/170] remove console log --- src/pages/home/sidebar/SidebarLinksData.js | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/pages/home/sidebar/SidebarLinksData.js b/src/pages/home/sidebar/SidebarLinksData.js index c8b1a7137cab..c4cc0713c596 100644 --- a/src/pages/home/sidebar/SidebarLinksData.js +++ b/src/pages/home/sidebar/SidebarLinksData.js @@ -188,8 +188,6 @@ function SidebarLinksData({ currentReportIDRef.current = currentReportID; const isActiveReport = useCallback((reportID) => currentReportIDRef.current === reportID, []); - console.log('SidebarLinksData', optionListItemsWithCurrentReport); - return ( Date: Fri, 1 Mar 2024 17:09:03 +0530 Subject: [PATCH 125/170] fixes ts checks --- src/libs/ReportUtils.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libs/ReportUtils.ts b/src/libs/ReportUtils.ts index 2aa3733bf400..865668ecf5bf 100644 --- a/src/libs/ReportUtils.ts +++ b/src/libs/ReportUtils.ts @@ -3932,7 +3932,7 @@ function shouldReportBeInOptionList({ policies: OnyxCollection; excludeEmptyChats: boolean; doesReportHaveViolations: boolean; - includeSelfDM: boolean; + includeSelfDM?: boolean; }) { const isInDefaultMode = !isInGSDMode; // Exclude reports that have no data because there wouldn't be anything to show in the option item. From c186109101584d65152f576c87c124d53b44c16a Mon Sep 17 00:00:00 2001 From: Bernhard Owen Josephus Date: Fri, 1 Mar 2024 20:22:20 +0800 Subject: [PATCH 126/170] move to const --- src/CONST.ts | 4 ++++ src/libs/ReportUtils.ts | 2 +- src/libs/actions/Session/index.ts | 2 +- src/pages/home/report/ReportActionsView.js | 2 +- src/pages/home/report/ReportFooter.js | 2 +- src/pages/signin/SignInModal.tsx | 3 ++- 6 files changed, 10 insertions(+), 5 deletions(-) diff --git a/src/CONST.ts b/src/CONST.ts index 8d4eaac44a38..ba3794659d59 100755 --- a/src/CONST.ts +++ b/src/CONST.ts @@ -3332,6 +3332,10 @@ const CONST = { SESSION_STORAGE_KEYS: { INITIAL_URL: 'INITIAL_URL', }, + + AUTH_TOKEN_TYPE: { + ANONYMOUS: 'anonymousAccount', + }, } as const; type Country = keyof typeof CONST.ALL_COUNTRIES; diff --git a/src/libs/ReportUtils.ts b/src/libs/ReportUtils.ts index a814c91ea8b2..f64123aceaf8 100644 --- a/src/libs/ReportUtils.ts +++ b/src/libs/ReportUtils.ts @@ -438,7 +438,7 @@ Onyx.connect({ currentUserEmail = value.email; currentUserAccountID = value.accountID; - isAnonymousUser = value.authTokenType === 'anonymousAccount'; + isAnonymousUser = value.authTokenType === CONST.AUTH_TOKEN_TYPE.ANONYMOUS; currentUserPrivateDomain = isEmailPublicDomain(currentUserEmail ?? '') ? '' : Str.extractEmailDomain(currentUserEmail ?? ''); }, }); diff --git a/src/libs/actions/Session/index.ts b/src/libs/actions/Session/index.ts index 013d86049150..76f335a3bec0 100644 --- a/src/libs/actions/Session/index.ts +++ b/src/libs/actions/Session/index.ts @@ -107,7 +107,7 @@ function signOut() { * Checks if the account is an anonymous account. */ function isAnonymousUser(): boolean { - return sessionAuthTokenType === 'anonymousAccount'; + return sessionAuthTokenType === CONST.AUTH_TOKEN_TYPE.ANONYMOUS; } function signOutAndRedirectToSignIn(shouldReplaceCurrentScreen?: boolean) { diff --git a/src/pages/home/report/ReportActionsView.js b/src/pages/home/report/ReportActionsView.js index cd625a667a7f..ed414de134f4 100755 --- a/src/pages/home/report/ReportActionsView.js +++ b/src/pages/home/report/ReportActionsView.js @@ -140,7 +140,7 @@ function ReportActionsView(props) { }, [props.network, isReportFullyVisible]); useEffect(() => { - const wasLoginChangedDetected = prevAuthTokenType === 'anonymousAccount' && !props.session.authTokenType; + const wasLoginChangedDetected = prevAuthTokenType === CONST.AUTH_TOKEN_TYPE.ANONYMOUS && !props.session.authTokenType; if (wasLoginChangedDetected && didUserLogInDuringSession() && isUserCreatedPolicyRoom(props.report)) { if (isReportFullyVisible) { openReportIfNecessary(); diff --git a/src/pages/home/report/ReportFooter.js b/src/pages/home/report/ReportFooter.js index 7372d3fb4854..3b9f8f03c320 100644 --- a/src/pages/home/report/ReportFooter.js +++ b/src/pages/home/report/ReportFooter.js @@ -67,7 +67,7 @@ function ReportFooter(props) { const {isOffline} = useNetwork(); const chatFooterStyles = {...styles.chatFooter, minHeight: !isOffline ? CONST.CHAT_FOOTER_MIN_HEIGHT : 0}; const isArchivedRoom = ReportUtils.isArchivedRoom(props.report); - const isAnonymousUser = props.session.authTokenType === 'anonymousAccount'; + const isAnonymousUser = props.session.authTokenType === CONST.AUTH_TOKEN_TYPE.ANONYMOUS; const isSmallSizeLayout = props.windowWidth - (props.isSmallScreenWidth ? 0 : variables.sideBarWidth) < variables.anonymousReportFooterBreakpoint; const hideComposer = !ReportUtils.canUserPerformWriteAction(props.report); diff --git a/src/pages/signin/SignInModal.tsx b/src/pages/signin/SignInModal.tsx index 741074fa952b..e71ee6e9a988 100644 --- a/src/pages/signin/SignInModal.tsx +++ b/src/pages/signin/SignInModal.tsx @@ -6,6 +6,7 @@ import ScreenWrapper from '@components/ScreenWrapper'; import useStyleUtils from '@hooks/useStyleUtils'; import useTheme from '@hooks/useTheme'; import Navigation from '@libs/Navigation/Navigation'; +import CONST from '@src/CONST'; import ONYXKEYS from '@src/ONYXKEYS'; import SCREENS from '@src/SCREENS'; import type {Session} from '@src/types/onyx'; @@ -22,7 +23,7 @@ function SignInModal({session}: SignInModalProps) { const StyleUtils = useStyleUtils(); useEffect(() => { - const isAnonymousUser = session?.authTokenType === 'anonymousAccount'; + const isAnonymousUser = session?.authTokenType === CONST.AUTH_TOKEN_TYPE.ANONYMOUS; if (!isAnonymousUser) { // Signing in RHP is only for anonymous users Navigation.isNavigationReady().then(() => Navigation.dismissModal()); From 01b12a5b4c40e26f859229543f8e15ff17605e49 Mon Sep 17 00:00:00 2001 From: Rushat Gabhane Date: Fri, 1 Mar 2024 17:42:54 +0300 Subject: [PATCH 127/170] fix center pane refresh bug --- src/libs/Navigation/linkingConfig/CENTRAL_PANE_TO_RHP_MAPPING.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/src/libs/Navigation/linkingConfig/CENTRAL_PANE_TO_RHP_MAPPING.ts b/src/libs/Navigation/linkingConfig/CENTRAL_PANE_TO_RHP_MAPPING.ts index 7e38ed99105e..618eddc9f62c 100755 --- a/src/libs/Navigation/linkingConfig/CENTRAL_PANE_TO_RHP_MAPPING.ts +++ b/src/libs/Navigation/linkingConfig/CENTRAL_PANE_TO_RHP_MAPPING.ts @@ -5,6 +5,7 @@ const CENTRAL_PANE_TO_RHP_MAPPING: Partial> = [SCREENS.WORKSPACE.PROFILE]: [SCREENS.WORKSPACE.NAME, SCREENS.WORKSPACE.CURRENCY, SCREENS.WORKSPACE.DESCRIPTION, SCREENS.WORKSPACE.SHARE], [SCREENS.WORKSPACE.REIMBURSE]: [SCREENS.WORKSPACE.RATE_AND_UNIT, SCREENS.WORKSPACE.RATE_AND_UNIT_RATE, SCREENS.WORKSPACE.RATE_AND_UNIT_UNIT], [SCREENS.WORKSPACE.MEMBERS]: [SCREENS.WORKSPACE.INVITE, SCREENS.WORKSPACE.INVITE_MESSAGE], + [SCREENS.WORKSPACE.WORKFLOWS]: [SCREENS.WORKSPACE.WORKFLOWS_APPROVER], }; export default CENTRAL_PANE_TO_RHP_MAPPING; From 675d514ac188135a5d548dc5c0cb75d5e25eb64a Mon Sep 17 00:00:00 2001 From: Rushat Gabhane Date: Fri, 1 Mar 2024 17:45:31 +0300 Subject: [PATCH 128/170] fix center pane refresh bug --- src/libs/Navigation/linkingConfig/CENTRAL_PANE_TO_RHP_MAPPING.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/src/libs/Navigation/linkingConfig/CENTRAL_PANE_TO_RHP_MAPPING.ts b/src/libs/Navigation/linkingConfig/CENTRAL_PANE_TO_RHP_MAPPING.ts index 618eddc9f62c..7e38ed99105e 100755 --- a/src/libs/Navigation/linkingConfig/CENTRAL_PANE_TO_RHP_MAPPING.ts +++ b/src/libs/Navigation/linkingConfig/CENTRAL_PANE_TO_RHP_MAPPING.ts @@ -5,7 +5,6 @@ const CENTRAL_PANE_TO_RHP_MAPPING: Partial> = [SCREENS.WORKSPACE.PROFILE]: [SCREENS.WORKSPACE.NAME, SCREENS.WORKSPACE.CURRENCY, SCREENS.WORKSPACE.DESCRIPTION, SCREENS.WORKSPACE.SHARE], [SCREENS.WORKSPACE.REIMBURSE]: [SCREENS.WORKSPACE.RATE_AND_UNIT, SCREENS.WORKSPACE.RATE_AND_UNIT_RATE, SCREENS.WORKSPACE.RATE_AND_UNIT_UNIT], [SCREENS.WORKSPACE.MEMBERS]: [SCREENS.WORKSPACE.INVITE, SCREENS.WORKSPACE.INVITE_MESSAGE], - [SCREENS.WORKSPACE.WORKFLOWS]: [SCREENS.WORKSPACE.WORKFLOWS_APPROVER], }; export default CENTRAL_PANE_TO_RHP_MAPPING; From 98f1b1ad908bc8369a04c0a73d59680c3d1282f6 Mon Sep 17 00:00:00 2001 From: Rushat Gabhane Date: Fri, 1 Mar 2024 17:46:05 +0300 Subject: [PATCH 129/170] fix center pane refresh bug --- src/libs/Navigation/linkingConfig/CENTRAL_PANE_TO_RHP_MAPPING.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/src/libs/Navigation/linkingConfig/CENTRAL_PANE_TO_RHP_MAPPING.ts b/src/libs/Navigation/linkingConfig/CENTRAL_PANE_TO_RHP_MAPPING.ts index 7e38ed99105e..618eddc9f62c 100755 --- a/src/libs/Navigation/linkingConfig/CENTRAL_PANE_TO_RHP_MAPPING.ts +++ b/src/libs/Navigation/linkingConfig/CENTRAL_PANE_TO_RHP_MAPPING.ts @@ -5,6 +5,7 @@ const CENTRAL_PANE_TO_RHP_MAPPING: Partial> = [SCREENS.WORKSPACE.PROFILE]: [SCREENS.WORKSPACE.NAME, SCREENS.WORKSPACE.CURRENCY, SCREENS.WORKSPACE.DESCRIPTION, SCREENS.WORKSPACE.SHARE], [SCREENS.WORKSPACE.REIMBURSE]: [SCREENS.WORKSPACE.RATE_AND_UNIT, SCREENS.WORKSPACE.RATE_AND_UNIT_RATE, SCREENS.WORKSPACE.RATE_AND_UNIT_UNIT], [SCREENS.WORKSPACE.MEMBERS]: [SCREENS.WORKSPACE.INVITE, SCREENS.WORKSPACE.INVITE_MESSAGE], + [SCREENS.WORKSPACE.WORKFLOWS]: [SCREENS.WORKSPACE.WORKFLOWS_APPROVER], }; export default CENTRAL_PANE_TO_RHP_MAPPING; From 4b2ccaf304300f35f2685bdb902e95d55bbeae96 Mon Sep 17 00:00:00 2001 From: Rushat Gabhane Date: Fri, 1 Mar 2024 18:23:25 +0300 Subject: [PATCH 130/170] rm todo --- src/pages/workspace/workflows/WorkspaceWorkflowsPage.tsx | 1 - 1 file changed, 1 deletion(-) diff --git a/src/pages/workspace/workflows/WorkspaceWorkflowsPage.tsx b/src/pages/workspace/workflows/WorkspaceWorkflowsPage.tsx index 6c98ef406cf9..e5cbc9119dca 100644 --- a/src/pages/workspace/workflows/WorkspaceWorkflowsPage.tsx +++ b/src/pages/workspace/workflows/WorkspaceWorkflowsPage.tsx @@ -98,7 +98,6 @@ function WorkspaceWorkflowsPage({policy, betas, route}: WorkspaceWorkflowsPagePr descriptionTextStyle={styles.textNormalThemeText} description={policyApproverName ?? ''} onPress={() => Navigation.navigate(ROUTES.WORKSPACE_WORKFLOWS_APPROVER.getRoute(route.params.policyID))} - // TODO will be done in https://github.com/Expensify/Expensify/issues/368334 shouldShowRightIcon wrapperStyle={containerStyle} hoverAndPressStyle={[styles.mr0, styles.br2]} From 740c93ff27cfa636fb2c804dff74501c78b216e4 Mon Sep 17 00:00:00 2001 From: Rushat Gabhane Date: Fri, 1 Mar 2024 18:25:53 +0300 Subject: [PATCH 131/170] cleanup type --- src/libs/PersonalDetailsUtils.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libs/PersonalDetailsUtils.ts b/src/libs/PersonalDetailsUtils.ts index 1e1f1a14e861..4be9ad81184b 100644 --- a/src/libs/PersonalDetailsUtils.ts +++ b/src/libs/PersonalDetailsUtils.ts @@ -57,7 +57,7 @@ function getPersonalDetailsByIDs(accountIDs: number[], currentUserAccountID: num } function getPersonalDetailByEmail(email: string): PersonalDetails | undefined { - return Object.values(allPersonalDetails ?? {}).find((detail) => detail?.login === email) as unknown as PersonalDetails; + return (Object.values(allPersonalDetails ?? {}) as PersonalDetails[]).find((detail) => detail?.login === email); } /** From 511a5ffc93e9afea65070e727d7df59093f10a40 Mon Sep 17 00:00:00 2001 From: Rushat Gabhane Date: Fri, 1 Mar 2024 18:50:01 +0300 Subject: [PATCH 132/170] cleanup using optional chain --- .../workspace/workflows/WorkspaceWorkflowsApproverPage.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pages/workspace/workflows/WorkspaceWorkflowsApproverPage.tsx b/src/pages/workspace/workflows/WorkspaceWorkflowsApproverPage.tsx index 66a595aaad87..a0226965d5b6 100644 --- a/src/pages/workspace/workflows/WorkspaceWorkflowsApproverPage.tsx +++ b/src/pages/workspace/workflows/WorkspaceWorkflowsApproverPage.tsx @@ -150,7 +150,7 @@ function WorkspaceWorkflowsApproverPage({policy, policyMembers, personalDetails, const headerMessage = useMemo(() => (searchTerm && !sections[0].data.length ? translate('common.noResultsFound') : ''), [translate, sections]); const setPolicyApprover = (member: MemberOption) => { - if (!policy || !policy.approvalMode || !personalDetails?.[member.accountID]?.login) { + if (!policy?.approvalMode || !personalDetails?.[member.accountID]?.login) { return; } const approver: string = personalDetails?.[member.accountID]?.login ?? policy.approver ?? policy.owner; From 86e3c777e2c216dad3090f4bbb58d5c7884298d5 Mon Sep 17 00:00:00 2001 From: Rushat Gabhane Date: Fri, 1 Mar 2024 18:58:23 +0300 Subject: [PATCH 133/170] cleanup --- .../workspace/workflows/WorkspaceWorkflowsApproverPage.tsx | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/pages/workspace/workflows/WorkspaceWorkflowsApproverPage.tsx b/src/pages/workspace/workflows/WorkspaceWorkflowsApproverPage.tsx index a0226965d5b6..6bc4dedb9d09 100644 --- a/src/pages/workspace/workflows/WorkspaceWorkflowsApproverPage.tsx +++ b/src/pages/workspace/workflows/WorkspaceWorkflowsApproverPage.tsx @@ -118,8 +118,7 @@ function WorkspaceWorkflowsApproverPage({policy, policyMembers, personalDetails, const parsedPhoneNumber = parsePhoneNumber(LoginUtils.appendCountryCode(Str.removeSMSDomain(searchTerm))); const searchValue = parsedPhoneNumber.possible ? parsedPhoneNumber.number?.e164 ?? '' : searchTerm.toLowerCase(); - const isPartOfSearchTerm = !!option.text?.toLowerCase().includes(searchValue) || !!option.login?.toLowerCase().includes(searchValue); - return isPartOfSearchTerm; + return !!option.text?.toLowerCase().includes(searchValue) || !!option.login?.toLowerCase().includes(searchValue); }); return [ { From 73cb58ce16dc1aefbd2095ade186b1860d69f00a Mon Sep 17 00:00:00 2001 From: Rushat Gabhane Date: Fri, 1 Mar 2024 19:07:39 +0300 Subject: [PATCH 134/170] fix lint --- src/pages/workspace/workflows/WorkspaceWorkflowsPage.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pages/workspace/workflows/WorkspaceWorkflowsPage.tsx b/src/pages/workspace/workflows/WorkspaceWorkflowsPage.tsx index e5cbc9119dca..dbfb114586a1 100644 --- a/src/pages/workspace/workflows/WorkspaceWorkflowsPage.tsx +++ b/src/pages/workspace/workflows/WorkspaceWorkflowsPage.tsx @@ -46,7 +46,7 @@ function WorkspaceWorkflowsPage({policy, betas, route}: WorkspaceWorkflowsPagePr const {isOffline} = useNetwork(); const policyApproverEmail = policy?.approver; - const policyApproverName = useMemo(() => PersonalDetailsUtils.getPersonalDetailByEmail(policyApproverEmail ?? '')?.displayName || policyApproverEmail, [policyApproverEmail]); + const policyApproverName = useMemo(() => PersonalDetailsUtils.getPersonalDetailByEmail(policyApproverEmail ?? '')?.displayName ?? policyApproverEmail, [policyApproverEmail]); const containerStyle = useMemo(() => [styles.ph8, styles.mhn8, styles.ml11, styles.pv3, styles.pr0, styles.pl4, styles.mr0, styles.widthAuto, styles.mt4], [styles]); const canUseDelayedSubmission = Permissions.canUseWorkflowsDelayedSubmission(betas); From 07e69d183499e9f32285115af6b878d183d0705d Mon Sep 17 00:00:00 2001 From: Rushat Gabhane Date: Fri, 1 Mar 2024 19:08:09 +0300 Subject: [PATCH 135/170] rm unused --- src/pages/workspace/workflows/WorkspaceWorkflowsPage.tsx | 1 - 1 file changed, 1 deletion(-) diff --git a/src/pages/workspace/workflows/WorkspaceWorkflowsPage.tsx b/src/pages/workspace/workflows/WorkspaceWorkflowsPage.tsx index dbfb114586a1..0d8b1d2aced2 100644 --- a/src/pages/workspace/workflows/WorkspaceWorkflowsPage.tsx +++ b/src/pages/workspace/workflows/WorkspaceWorkflowsPage.tsx @@ -13,7 +13,6 @@ import useStyleUtils from '@hooks/useStyleUtils'; import useThemeStyles from '@hooks/useThemeStyles'; import useWindowDimensions from '@hooks/useWindowDimensions'; import Navigation from '@libs/Navigation/Navigation'; -import * as OptionsListUtils from '@libs/OptionsListUtils'; import Permissions from '@libs/Permissions'; import * as PersonalDetailsUtils from '@libs/PersonalDetailsUtils'; import * as PolicyUtils from '@libs/PolicyUtils'; From 66e81e6634b579c4938a465289217ea3e49da316 Mon Sep 17 00:00:00 2001 From: Rushat Gabhane Date: Fri, 1 Mar 2024 20:15:39 +0300 Subject: [PATCH 136/170] dry parse phone --- src/libs/PhoneNumber.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/src/libs/PhoneNumber.ts b/src/libs/PhoneNumber.ts index 787b3634030a..532fbf305fd3 100644 --- a/src/libs/PhoneNumber.ts +++ b/src/libs/PhoneNumber.ts @@ -2,6 +2,7 @@ import {parsePhoneNumber as originalParsePhoneNumber} from 'awesome-phonenumber'; import type {ParsedPhoneNumber, ParsedPhoneNumberInvalid, PhoneNumberParseOptions} from 'awesome-phonenumber'; import Str from 'expensify-common/lib/str'; +import * as LoginUtils from '@libs/LoginUtils'; import CONST from '@src/CONST'; /** From 449e7a6ce810c67fd249c3c33dde8c70be391bc3 Mon Sep 17 00:00:00 2001 From: Rushat Gabhane Date: Fri, 1 Mar 2024 20:15:44 +0300 Subject: [PATCH 137/170] dry parse phone --- src/libs/PhoneNumber.ts | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/libs/PhoneNumber.ts b/src/libs/PhoneNumber.ts index 532fbf305fd3..2e793695b523 100644 --- a/src/libs/PhoneNumber.ts +++ b/src/libs/PhoneNumber.ts @@ -52,5 +52,10 @@ function addSMSDomainIfPhoneNumber(login: string): string { return login; } +function getSearchValueForPhoneOrEmail(searchTerm: string) { + const parsedPhoneNumber = parsePhoneNumber(LoginUtils.appendCountryCode(Str.removeSMSDomain(searchTerm))); + return parsedPhoneNumber.possible ? parsedPhoneNumber.number?.e164 ?? '' : searchTerm.toLowerCase(); +} + // eslint-disable-next-line import/prefer-default-export -export {parsePhoneNumber, addSMSDomainIfPhoneNumber}; +export {parsePhoneNumber, addSMSDomainIfPhoneNumber, getSearchValueForPhoneOrEmail}; From 74591dca74949a2246476b9f5b74315d0273cb69 Mon Sep 17 00:00:00 2001 From: Rushat Gabhane Date: Fri, 1 Mar 2024 20:15:49 +0300 Subject: [PATCH 138/170] dry parse phone --- src/pages/workspace/WorkspaceInvitePage.tsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/pages/workspace/WorkspaceInvitePage.tsx b/src/pages/workspace/WorkspaceInvitePage.tsx index 03fa78367eda..c4db248af108 100644 --- a/src/pages/workspace/WorkspaceInvitePage.tsx +++ b/src/pages/workspace/WorkspaceInvitePage.tsx @@ -176,8 +176,8 @@ function WorkspaceInvitePage({ filterSelectedOptions = selectedOptions.filter((option) => { const accountID = option.accountID; const isOptionInPersonalDetails = Object.values(personalDetails).some((personalDetail) => personalDetail.accountID === accountID); - const parsedPhoneNumber = PhoneNumber.parsePhoneNumber(LoginUtils.appendCountryCode(Str.removeSMSDomain(searchTerm))); - const searchValue = parsedPhoneNumber.possible ? parsedPhoneNumber.number?.e164 ?? '' : searchTerm.toLowerCase(); + + const searchValue = PhoneNumber.getSearchValueForPhoneOrEmail(searchTerm); const isPartOfSearchTerm = !!option.text?.toLowerCase().includes(searchValue) || !!option.login?.toLowerCase().includes(searchValue); return isPartOfSearchTerm || isOptionInPersonalDetails; From 8c74efcad8411fb2d354b02dbe8dd8f3ee5a81d3 Mon Sep 17 00:00:00 2001 From: Rushat Gabhane Date: Fri, 1 Mar 2024 20:15:55 +0300 Subject: [PATCH 139/170] dry parse phone --- .../workspace/workflows/WorkspaceWorkflowsApproverPage.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pages/workspace/workflows/WorkspaceWorkflowsApproverPage.tsx b/src/pages/workspace/workflows/WorkspaceWorkflowsApproverPage.tsx index 6bc4dedb9d09..c316beb27bda 100644 --- a/src/pages/workspace/workflows/WorkspaceWorkflowsApproverPage.tsx +++ b/src/pages/workspace/workflows/WorkspaceWorkflowsApproverPage.tsx @@ -20,7 +20,7 @@ import Log from '@libs/Log'; import * as LoginUtils from '@libs/LoginUtils'; import Navigation from '@libs/Navigation/Navigation'; import * as PersonalDetailsUtils from '@libs/PersonalDetailsUtils'; -import {parsePhoneNumber} from '@libs/PhoneNumber'; +import {getSearchValueForPhoneOrEmail} from '@libs/PhoneNumber'; import * as PolicyUtils from '@libs/PolicyUtils'; import * as UserUtils from '@libs/UserUtils'; import withPolicyAndFullscreenLoading from '@pages/workspace/withPolicyAndFullscreenLoading'; From d4b03448f648cf979e2526d64c6a11d0c1b35480 Mon Sep 17 00:00:00 2001 From: Rushat Gabhane Date: Fri, 1 Mar 2024 20:15:59 +0300 Subject: [PATCH 140/170] dry parse phone --- .../workspace/workflows/WorkspaceWorkflowsApproverPage.tsx | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/pages/workspace/workflows/WorkspaceWorkflowsApproverPage.tsx b/src/pages/workspace/workflows/WorkspaceWorkflowsApproverPage.tsx index c316beb27bda..42b03e12dcee 100644 --- a/src/pages/workspace/workflows/WorkspaceWorkflowsApproverPage.tsx +++ b/src/pages/workspace/workflows/WorkspaceWorkflowsApproverPage.tsx @@ -115,9 +115,7 @@ function WorkspaceWorkflowsApproverPage({policy, policyMembers, personalDetails, if (searchTerm !== '') { const filteredOptions = [...formattedApprover, ...formattedPolicyMembers].filter((option) => { - const parsedPhoneNumber = parsePhoneNumber(LoginUtils.appendCountryCode(Str.removeSMSDomain(searchTerm))); - const searchValue = parsedPhoneNumber.possible ? parsedPhoneNumber.number?.e164 ?? '' : searchTerm.toLowerCase(); - + const searchValue = getSearchValueForPhoneOrEmail(searchTerm); return !!option.text?.toLowerCase().includes(searchValue) || !!option.login?.toLowerCase().includes(searchValue); }); return [ From 5c6423c257fa58407a2efbc9bdc18c2b09a2221a Mon Sep 17 00:00:00 2001 From: Rushat Gabhane Date: Fri, 1 Mar 2024 20:37:23 +0300 Subject: [PATCH 141/170] fix lint --- src/libs/PhoneNumber.ts | 2 +- src/pages/workspace/WorkspaceInvitePage.tsx | 1 - .../workspace/workflows/WorkspaceWorkflowsApproverPage.tsx | 2 -- 3 files changed, 1 insertion(+), 4 deletions(-) diff --git a/src/libs/PhoneNumber.ts b/src/libs/PhoneNumber.ts index 2e793695b523..6ed96fde304d 100644 --- a/src/libs/PhoneNumber.ts +++ b/src/libs/PhoneNumber.ts @@ -2,8 +2,8 @@ import {parsePhoneNumber as originalParsePhoneNumber} from 'awesome-phonenumber'; import type {ParsedPhoneNumber, ParsedPhoneNumberInvalid, PhoneNumberParseOptions} from 'awesome-phonenumber'; import Str from 'expensify-common/lib/str'; -import * as LoginUtils from '@libs/LoginUtils'; import CONST from '@src/CONST'; +import * as LoginUtils from './LoginUtils'; /** * Wraps awesome-phonenumber's parsePhoneNumber function to handle the case where we want to treat diff --git a/src/pages/workspace/WorkspaceInvitePage.tsx b/src/pages/workspace/WorkspaceInvitePage.tsx index c4db248af108..0813acd8b5a4 100644 --- a/src/pages/workspace/WorkspaceInvitePage.tsx +++ b/src/pages/workspace/WorkspaceInvitePage.tsx @@ -1,6 +1,5 @@ import {useNavigation} from '@react-navigation/native'; import type {StackNavigationProp, StackScreenProps} from '@react-navigation/stack'; -import Str from 'expensify-common/lib/str'; import React, {useEffect, useMemo, useState} from 'react'; import type {SectionListData} from 'react-native'; import {View} from 'react-native'; diff --git a/src/pages/workspace/workflows/WorkspaceWorkflowsApproverPage.tsx b/src/pages/workspace/workflows/WorkspaceWorkflowsApproverPage.tsx index 42b03e12dcee..fd223e25ca46 100644 --- a/src/pages/workspace/workflows/WorkspaceWorkflowsApproverPage.tsx +++ b/src/pages/workspace/workflows/WorkspaceWorkflowsApproverPage.tsx @@ -1,4 +1,3 @@ -import Str from 'expensify-common/lib/str'; import React, {useMemo, useState} from 'react'; import type {SectionListData} from 'react-native'; import {withOnyx} from 'react-native-onyx'; @@ -17,7 +16,6 @@ import useThemeStyles from '@hooks/useThemeStyles'; import compose from '@libs/compose'; import {formatPhoneNumber} from '@libs/LocalePhoneNumber'; import Log from '@libs/Log'; -import * as LoginUtils from '@libs/LoginUtils'; import Navigation from '@libs/Navigation/Navigation'; import * as PersonalDetailsUtils from '@libs/PersonalDetailsUtils'; import {getSearchValueForPhoneOrEmail} from '@libs/PhoneNumber'; From 1c9866003a5aacc54ebb5fc605360be54e5f53d0 Mon Sep 17 00:00:00 2001 From: Rushat Gabhane Date: Fri, 1 Mar 2024 20:50:49 +0300 Subject: [PATCH 142/170] fix deps cycle --- src/libs/OptionsListUtils.ts | 6 ++++++ src/libs/PhoneNumber.ts | 8 +------- src/pages/workspace/WorkspaceInvitePage.tsx | 2 +- .../workflows/WorkspaceWorkflowsApproverPage.tsx | 4 ++-- 4 files changed, 10 insertions(+), 10 deletions(-) diff --git a/src/libs/OptionsListUtils.ts b/src/libs/OptionsListUtils.ts index 91fce003d19e..89a087005cff 100644 --- a/src/libs/OptionsListUtils.ts +++ b/src/libs/OptionsListUtils.ts @@ -785,6 +785,11 @@ function getEnabledCategoriesCount(options: PolicyCategories): number { return Object.values(options).filter((option) => option.enabled).length; } +function getSearchValueForPhoneOrEmail(searchTerm: string) { + const parsedPhoneNumber = PhoneNumber.parsePhoneNumber(LoginUtils.appendCountryCode(Str.removeSMSDomain(searchTerm))); + return parsedPhoneNumber.possible ? parsedPhoneNumber.number?.e164 ?? '' : searchTerm.toLowerCase(); +} + /** * Verifies that there is at least one enabled option */ @@ -2007,6 +2012,7 @@ export { getMemberInviteOptions, getHeaderMessage, getHeaderMessageForNonUserList, + getSearchValueForPhoneOrEmail, getPersonalDetailsForAccountIDs, getIOUConfirmationOptionsFromPayeePersonalDetail, getIOUConfirmationOptionsFromParticipants, diff --git a/src/libs/PhoneNumber.ts b/src/libs/PhoneNumber.ts index 6ed96fde304d..787b3634030a 100644 --- a/src/libs/PhoneNumber.ts +++ b/src/libs/PhoneNumber.ts @@ -3,7 +3,6 @@ import {parsePhoneNumber as originalParsePhoneNumber} from 'awesome-phonenumber' import type {ParsedPhoneNumber, ParsedPhoneNumberInvalid, PhoneNumberParseOptions} from 'awesome-phonenumber'; import Str from 'expensify-common/lib/str'; import CONST from '@src/CONST'; -import * as LoginUtils from './LoginUtils'; /** * Wraps awesome-phonenumber's parsePhoneNumber function to handle the case where we want to treat @@ -52,10 +51,5 @@ function addSMSDomainIfPhoneNumber(login: string): string { return login; } -function getSearchValueForPhoneOrEmail(searchTerm: string) { - const parsedPhoneNumber = parsePhoneNumber(LoginUtils.appendCountryCode(Str.removeSMSDomain(searchTerm))); - return parsedPhoneNumber.possible ? parsedPhoneNumber.number?.e164 ?? '' : searchTerm.toLowerCase(); -} - // eslint-disable-next-line import/prefer-default-export -export {parsePhoneNumber, addSMSDomainIfPhoneNumber, getSearchValueForPhoneOrEmail}; +export {parsePhoneNumber, addSMSDomainIfPhoneNumber}; diff --git a/src/pages/workspace/WorkspaceInvitePage.tsx b/src/pages/workspace/WorkspaceInvitePage.tsx index 0813acd8b5a4..67bf6f8064da 100644 --- a/src/pages/workspace/WorkspaceInvitePage.tsx +++ b/src/pages/workspace/WorkspaceInvitePage.tsx @@ -176,7 +176,7 @@ function WorkspaceInvitePage({ const accountID = option.accountID; const isOptionInPersonalDetails = Object.values(personalDetails).some((personalDetail) => personalDetail.accountID === accountID); - const searchValue = PhoneNumber.getSearchValueForPhoneOrEmail(searchTerm); + const searchValue = OptionsListUtils.getSearchValueForPhoneOrEmail(searchTerm); const isPartOfSearchTerm = !!option.text?.toLowerCase().includes(searchValue) || !!option.login?.toLowerCase().includes(searchValue); return isPartOfSearchTerm || isOptionInPersonalDetails; diff --git a/src/pages/workspace/workflows/WorkspaceWorkflowsApproverPage.tsx b/src/pages/workspace/workflows/WorkspaceWorkflowsApproverPage.tsx index fd223e25ca46..b64d752d228e 100644 --- a/src/pages/workspace/workflows/WorkspaceWorkflowsApproverPage.tsx +++ b/src/pages/workspace/workflows/WorkspaceWorkflowsApproverPage.tsx @@ -17,8 +17,8 @@ import compose from '@libs/compose'; import {formatPhoneNumber} from '@libs/LocalePhoneNumber'; import Log from '@libs/Log'; import Navigation from '@libs/Navigation/Navigation'; +import * as OptionsListUtils from '@libs/OptionsListUtils'; import * as PersonalDetailsUtils from '@libs/PersonalDetailsUtils'; -import {getSearchValueForPhoneOrEmail} from '@libs/PhoneNumber'; import * as PolicyUtils from '@libs/PolicyUtils'; import * as UserUtils from '@libs/UserUtils'; import withPolicyAndFullscreenLoading from '@pages/workspace/withPolicyAndFullscreenLoading'; @@ -113,7 +113,7 @@ function WorkspaceWorkflowsApproverPage({policy, policyMembers, personalDetails, if (searchTerm !== '') { const filteredOptions = [...formattedApprover, ...formattedPolicyMembers].filter((option) => { - const searchValue = getSearchValueForPhoneOrEmail(searchTerm); + const searchValue = OptionsListUtils.getSearchValueForPhoneOrEmail(searchTerm); return !!option.text?.toLowerCase().includes(searchValue) || !!option.login?.toLowerCase().includes(searchValue); }); return [ From 25a5b0ffd57d52bfdc36467d3e8c57d20ad029f6 Mon Sep 17 00:00:00 2001 From: Rushat Gabhane Date: Fri, 1 Mar 2024 21:11:43 +0300 Subject: [PATCH 143/170] memoize deletedpolicy member --- .../workflows/WorkspaceWorkflowsApproverPage.tsx | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/pages/workspace/workflows/WorkspaceWorkflowsApproverPage.tsx b/src/pages/workspace/workflows/WorkspaceWorkflowsApproverPage.tsx index b64d752d228e..f163913ce4d6 100644 --- a/src/pages/workspace/workflows/WorkspaceWorkflowsApproverPage.tsx +++ b/src/pages/workspace/workflows/WorkspaceWorkflowsApproverPage.tsx @@ -1,4 +1,4 @@ -import React, {useMemo, useState} from 'react'; +import React, {useCallback, useMemo, useState} from 'react'; import type {SectionListData} from 'react-native'; import {withOnyx} from 'react-native-onyx'; import type {OnyxEntry} from 'react-native-onyx'; @@ -46,8 +46,10 @@ function WorkspaceWorkflowsApproverPage({policy, policyMembers, personalDetails, const styles = useThemeStyles(); const StyleUtils = useStyleUtils(); - const isDeletedPolicyMember = (policyMember: PolicyMember): boolean => - !isOffline && policyMember.pendingAction === CONST.RED_BRICK_ROAD_PENDING_ACTION.DELETE && isEmptyObject(policyMember.errors); + const isDeletedPolicyMember = useCallback( + (policyMember: PolicyMember) => !isOffline && policyMember.pendingAction === CONST.RED_BRICK_ROAD_PENDING_ACTION.DELETE && isEmptyObject(policyMember.errors), + [isOffline], + ); const [formattedPolicyMembers, formattedApprover] = useMemo(() => { const policyMemberDetails: MemberOption[] = []; From 47738f60023ab3deed7df35a3f60f43c7943b860 Mon Sep 17 00:00:00 2001 From: Rushat Gabhane Date: Fri, 1 Mar 2024 21:28:52 +0300 Subject: [PATCH 144/170] fix lint --- src/libs/Navigation/types.ts | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/libs/Navigation/types.ts b/src/libs/Navigation/types.ts index 6d680ac7e190..a1e558869ebe 100644 --- a/src/libs/Navigation/types.ts +++ b/src/libs/Navigation/types.ts @@ -63,6 +63,9 @@ type CentralPaneNavigatorParamList = { [SCREENS.WORKSPACE.WORKFLOWS]: { policyID: string; }; + [SCREENS.WORKSPACE.WORKFLOWS_APPROVER]: { + policyID: string; + }; [SCREENS.WORKSPACE.WORKFLOWS_AUTO_REPORTING_FREQUENCY]: { policyID: string; }; From e60a960b7b5a49b57ff93e1c98e46ac7a23e93d3 Mon Sep 17 00:00:00 2001 From: Rushat Gabhane Date: Fri, 1 Mar 2024 21:34:14 +0300 Subject: [PATCH 145/170] ignore deps rule --- .../workspace/workflows/WorkspaceWorkflowsApproverPage.tsx | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/pages/workspace/workflows/WorkspaceWorkflowsApproverPage.tsx b/src/pages/workspace/workflows/WorkspaceWorkflowsApproverPage.tsx index f163913ce4d6..93128ea8e953 100644 --- a/src/pages/workspace/workflows/WorkspaceWorkflowsApproverPage.tsx +++ b/src/pages/workspace/workflows/WorkspaceWorkflowsApproverPage.tsx @@ -144,7 +144,11 @@ function WorkspaceWorkflowsApproverPage({policy, policyMembers, personalDetails, return sectionsArray; }, [formattedPolicyMembers, formattedApprover, searchTerm, translate]); - const headerMessage = useMemo(() => (searchTerm && !sections[0].data.length ? translate('common.noResultsFound') : ''), [translate, sections]); + const headerMessage = useMemo( + () => (searchTerm && !sections[0].data.length ? translate('common.noResultsFound') : ''), + //eslint-disable-next-line react-hooks/exhaustive-deps + [translate, sections], + ); const setPolicyApprover = (member: MemberOption) => { if (!policy?.approvalMode || !personalDetails?.[member.accountID]?.login) { From 8b0d41722fa05b0931f3c817b2552782fd83596e Mon Sep 17 00:00:00 2001 From: Rushat Gabhane Date: Fri, 1 Mar 2024 21:40:46 +0300 Subject: [PATCH 146/170] ignore deps rule --- .../workflows/WorkspaceWorkflowsApproverPage.tsx | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/pages/workspace/workflows/WorkspaceWorkflowsApproverPage.tsx b/src/pages/workspace/workflows/WorkspaceWorkflowsApproverPage.tsx index 93128ea8e953..692a24ee2c66 100644 --- a/src/pages/workspace/workflows/WorkspaceWorkflowsApproverPage.tsx +++ b/src/pages/workspace/workflows/WorkspaceWorkflowsApproverPage.tsx @@ -144,11 +144,11 @@ function WorkspaceWorkflowsApproverPage({policy, policyMembers, personalDetails, return sectionsArray; }, [formattedPolicyMembers, formattedApprover, searchTerm, translate]); - const headerMessage = useMemo( - () => (searchTerm && !sections[0].data.length ? translate('common.noResultsFound') : ''), + const headerMessage = useMemo(() => { + return searchTerm && !sections[0].data.length ? translate('common.noResultsFound') : ''; + //eslint-disable-next-line react-hooks/exhaustive-deps - [translate, sections], - ); + }, [translate, sections]); const setPolicyApprover = (member: MemberOption) => { if (!policy?.approvalMode || !personalDetails?.[member.accountID]?.login) { From cddfe68cb546c883862146ad9c0af6d6ef2d3800 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lucas=20M=C3=B3rawski?= Date: Fri, 1 Mar 2024 19:44:03 +0100 Subject: [PATCH 147/170] adding deprecated flag to OptionsSelector --- src/components/OptionsSelector/index.android.js | 3 +++ src/components/OptionsSelector/index.js | 3 +++ 2 files changed, 6 insertions(+) diff --git a/src/components/OptionsSelector/index.android.js b/src/components/OptionsSelector/index.android.js index ace5a5614ffb..1ed2d56e8742 100644 --- a/src/components/OptionsSelector/index.android.js +++ b/src/components/OptionsSelector/index.android.js @@ -1,6 +1,9 @@ import React, {forwardRef} from 'react'; import BaseOptionsSelector from './BaseOptionsSelector'; +/** + * @deprecated Please use `SelectionList` instead. + */ const OptionsSelector = forwardRef((props, ref) => ( ( Date: Fri, 1 Mar 2024 21:46:28 +0300 Subject: [PATCH 148/170] ignore deps rule --- .../workflows/WorkspaceWorkflowsApproverPage.tsx | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/pages/workspace/workflows/WorkspaceWorkflowsApproverPage.tsx b/src/pages/workspace/workflows/WorkspaceWorkflowsApproverPage.tsx index 692a24ee2c66..52406a8033d2 100644 --- a/src/pages/workspace/workflows/WorkspaceWorkflowsApproverPage.tsx +++ b/src/pages/workspace/workflows/WorkspaceWorkflowsApproverPage.tsx @@ -144,11 +144,12 @@ function WorkspaceWorkflowsApproverPage({policy, policyMembers, personalDetails, return sectionsArray; }, [formattedPolicyMembers, formattedApprover, searchTerm, translate]); - const headerMessage = useMemo(() => { - return searchTerm && !sections[0].data.length ? translate('common.noResultsFound') : ''; + const headerMessage = useMemo( + () => (searchTerm && !sections[0].data.length ? translate('common.noResultsFound') : ''), - //eslint-disable-next-line react-hooks/exhaustive-deps - }, [translate, sections]); + // eslint-disable-next-line react-hooks/exhaustive-deps + [translate, sections], + ); const setPolicyApprover = (member: MemberOption) => { if (!policy?.approvalMode || !personalDetails?.[member.accountID]?.login) { From 4f86857bd017177a84a7353918829cc969faebd6 Mon Sep 17 00:00:00 2001 From: OSBotify Date: Fri, 1 Mar 2024 19:32:34 +0000 Subject: [PATCH 149/170] Update version to 1.4.46-1 --- android/app/build.gradle | 4 ++-- ios/NewExpensify/Info.plist | 2 +- ios/NewExpensifyTests/Info.plist | 2 +- ios/NotificationServiceExtension/Info.plist | 2 +- package-lock.json | 4 ++-- package.json | 2 +- 6 files changed, 8 insertions(+), 8 deletions(-) diff --git a/android/app/build.gradle b/android/app/build.gradle index 9886cd5cccec..e285d0bff26f 100644 --- a/android/app/build.gradle +++ b/android/app/build.gradle @@ -98,8 +98,8 @@ android { minSdkVersion rootProject.ext.minSdkVersion targetSdkVersion rootProject.ext.targetSdkVersion multiDexEnabled rootProject.ext.multiDexEnabled - versionCode 1001044600 - versionName "1.4.46-0" + versionCode 1001044601 + versionName "1.4.46-1" } flavorDimensions "default" diff --git a/ios/NewExpensify/Info.plist b/ios/NewExpensify/Info.plist index dff05f61933e..374594698200 100644 --- a/ios/NewExpensify/Info.plist +++ b/ios/NewExpensify/Info.plist @@ -40,7 +40,7 @@ CFBundleVersion - 1.4.46.0 + 1.4.46.1 ITSAppUsesNonExemptEncryption LSApplicationQueriesSchemes diff --git a/ios/NewExpensifyTests/Info.plist b/ios/NewExpensifyTests/Info.plist index fa6995f65b5a..e314ea1595e1 100644 --- a/ios/NewExpensifyTests/Info.plist +++ b/ios/NewExpensifyTests/Info.plist @@ -19,6 +19,6 @@ CFBundleSignature ???? CFBundleVersion - 1.4.46.0 + 1.4.46.1 diff --git a/ios/NotificationServiceExtension/Info.plist b/ios/NotificationServiceExtension/Info.plist index e8cd0ebb4e0a..aaec6344175f 100644 --- a/ios/NotificationServiceExtension/Info.plist +++ b/ios/NotificationServiceExtension/Info.plist @@ -13,7 +13,7 @@ CFBundleShortVersionString 1.4.46 CFBundleVersion - 1.4.46.0 + 1.4.46.1 NSExtension NSExtensionPointIdentifier diff --git a/package-lock.json b/package-lock.json index cafbead8f5eb..a18846dec51a 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "new.expensify", - "version": "1.4.46-0", + "version": "1.4.46-1", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "new.expensify", - "version": "1.4.46-0", + "version": "1.4.46-1", "hasInstallScript": true, "license": "MIT", "dependencies": { diff --git a/package.json b/package.json index 46ff187bf64c..e6d311934524 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "new.expensify", - "version": "1.4.46-0", + "version": "1.4.46-1", "author": "Expensify, Inc.", "homepage": "https://new.expensify.com", "description": "New Expensify is the next generation of Expensify: a reimagination of payments based atop a foundation of chat.", From 6fd105107c0fa80e9fef3c406957b209251545b1 Mon Sep 17 00:00:00 2001 From: Rocio Perez-Cano Date: Fri, 1 Mar 2024 16:41:36 -0500 Subject: [PATCH 150/170] Update browserify-sign to fix vulnerabilities --- package-lock.json | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/package-lock.json b/package-lock.json index 14895a47ffc1..80d3d1c6e911 100644 --- a/package-lock.json +++ b/package-lock.json @@ -24894,20 +24894,22 @@ } }, "node_modules/browserify-sign": { - "version": "4.2.1", - "resolved": "https://registry.npmjs.org/browserify-sign/-/browserify-sign-4.2.1.tgz", - "integrity": "sha512-/vrA5fguVAKKAVTNJjgSm1tRQDHUU6DbwO9IROu/0WAzC8PKhucDSh18J0RMvVeHAn5puMd+QHC2erPRNf8lmg==", - "license": "ISC", + "version": "4.2.2", + "resolved": "https://registry.npmjs.org/browserify-sign/-/browserify-sign-4.2.2.tgz", + "integrity": "sha512-1rudGyeYY42Dk6texmv7c4VcQ0EsvVbLwZkA+AQB7SxvXxmcD93jcHie8bzecJ+ChDlmAm2Qyu0+Ccg5uhZXCg==", "dependencies": { - "bn.js": "^5.1.1", - "browserify-rsa": "^4.0.1", + "bn.js": "^5.2.1", + "browserify-rsa": "^4.1.0", "create-hash": "^1.2.0", "create-hmac": "^1.1.7", - "elliptic": "^6.5.3", + "elliptic": "^6.5.4", "inherits": "^2.0.4", - "parse-asn1": "^5.1.5", - "readable-stream": "^3.6.0", - "safe-buffer": "^5.2.0" + "parse-asn1": "^5.1.6", + "readable-stream": "^3.6.2", + "safe-buffer": "^5.2.1" + }, + "engines": { + "node": ">= 4" } }, "node_modules/browserify-sign/node_modules/readable-stream": { From c6b2614b5b2f59480d10097150e6544e5b43ebee Mon Sep 17 00:00:00 2001 From: Ishpaul Singh Date: Sat, 2 Mar 2024 05:05:16 +0530 Subject: [PATCH 151/170] fixes private note comment --- src/pages/home/report/withReportAndPrivateNotesOrNotFound.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pages/home/report/withReportAndPrivateNotesOrNotFound.tsx b/src/pages/home/report/withReportAndPrivateNotesOrNotFound.tsx index 6bf88849e8b8..2c0edc77aad9 100644 --- a/src/pages/home/report/withReportAndPrivateNotesOrNotFound.tsx +++ b/src/pages/home/report/withReportAndPrivateNotesOrNotFound.tsx @@ -56,7 +56,7 @@ export default function (pageTitle: TranslationPaths) { // eslint-disable-next-line rulesdir/no-negated-variables const shouldShowNotFoundPage = useMemo(() => { - // Show not found view if the report is archived, or if the note is not of current user. + // Show not found view if the report is archived, or if the note is not of current user or if report is a self DM. if (ReportUtils.isArchivedRoom(report) || isOtherUserNote || ReportUtils.isSelfDM(report)) { return true; } From 2e30497242e3e6875675bdaff421fc5edce85e47 Mon Sep 17 00:00:00 2001 From: Ishpaul Singh Date: Sat, 2 Mar 2024 05:06:44 +0530 Subject: [PATCH 152/170] remove unnecessary whitespace change --- src/pages/home/report/ReportActionItemCreated.tsx | 1 + 1 file changed, 1 insertion(+) diff --git a/src/pages/home/report/ReportActionItemCreated.tsx b/src/pages/home/report/ReportActionItemCreated.tsx index 61ee63486700..95578c10e816 100644 --- a/src/pages/home/report/ReportActionItemCreated.tsx +++ b/src/pages/home/report/ReportActionItemCreated.tsx @@ -47,6 +47,7 @@ function ReportActionItemCreated(props: ReportActionItemCreatedProps) { if (!ReportUtils.isChatReport(props.report)) { return null; } + const icons = ReportUtils.getIcons(props.report, props.personalDetails); const shouldDisableDetailPage = ReportUtils.shouldDisableDetailPage(props.report); From 144fb48738a89c73980a16e0558fd49c57d236a7 Mon Sep 17 00:00:00 2001 From: Ishpaul Singh Date: Sat, 2 Mar 2024 05:08:49 +0530 Subject: [PATCH 153/170] fixes spanish translation --- src/languages/es.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/languages/es.ts b/src/languages/es.ts index b9c331660aa9..ff9919bc3f11 100644 --- a/src/languages/es.ts +++ b/src/languages/es.ts @@ -486,11 +486,11 @@ export default { beginningOfChatHistoryPolicyExpenseChatPartTwo: ' y ', beginningOfChatHistoryPolicyExpenseChatPartThree: ' empieza aquí! 🎉 Este es el lugar donde chatear, pedir dinero y pagar.', // todo: ask for the correct translation - beginningOfChatHistorySelfDM: 'This is your personal space. Use it for notes, tasks, drafts, and reminders.', + beginningOfChatHistorySelfDM: 'Este es tu espacio personal. Úsalo para notas, tareas, borradores y recordatorios.', chatWithAccountManager: 'Chatea con tu gestor de cuenta aquí', sayHello: '¡Saluda!', // todo: ask for the correct translation - yourSpace: 'Your space', + yourSpace: 'Tu espacio', welcomeToRoom: ({roomName}: WelcomeToRoomParams) => `¡Bienvenido a ${roomName}!`, usePlusButton: ({additionalText}: UsePlusButtonParams) => `\n¡También puedes usar el botón + de abajo para ${additionalText}, o asignar una tarea!`, iouTypes: { From 339a6a8bc0cbf6d6537fc651412c64370d63a3cc Mon Sep 17 00:00:00 2001 From: Ishpaul Singh Date: Sat, 2 Mar 2024 05:13:10 +0530 Subject: [PATCH 154/170] fixes comment --- src/libs/ReportUtils.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libs/ReportUtils.ts b/src/libs/ReportUtils.ts index cd68456d98ac..32e9c527f084 100644 --- a/src/libs/ReportUtils.ts +++ b/src/libs/ReportUtils.ts @@ -1657,7 +1657,7 @@ function getDisplayNameForParticipant(accountID?: number, shouldUseShortForm = f return formattedLogin; } - // for selfDm, we show user dispalyName + (You) as postfix + // For selfDM, we display the user's displayName followed by '(you)' as a postfix const shouldAddPostfix = shouldAddCurrentUserPostfix && accountID === currentUserAccountID; const longName = PersonalDetailsUtils.getDisplayNameOrDefault(personalDetails, formattedLogin, shouldFallbackToHidden, shouldAddPostfix); From 5acf3c874366ab66ee5d8e86f7b117a05494ed66 Mon Sep 17 00:00:00 2001 From: Ishpaul Singh <104348397+ishpaul777@users.noreply.github.com> Date: Sat, 2 Mar 2024 05:13:53 +0530 Subject: [PATCH 155/170] Update src/libs/ReportUtils.ts Co-authored-by: Pavlo Tsimura --- src/libs/ReportUtils.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/libs/ReportUtils.ts b/src/libs/ReportUtils.ts index 32e9c527f084..f3e74de29bca 100644 --- a/src/libs/ReportUtils.ts +++ b/src/libs/ReportUtils.ts @@ -4042,8 +4042,8 @@ function shouldReportBeInOptionList({ return false; } - if (includeSelfDM && isSelfDM(report)) { - return true; + if (isSelfDM(report)) { + return includeSelfDM; } return true; From 01820f89a96bf5e6a664bbaa334116d845950077 Mon Sep 17 00:00:00 2001 From: Ishpaul Singh Date: Sat, 2 Mar 2024 05:17:08 +0530 Subject: [PATCH 156/170] getMoneyRequestOptions --- src/libs/ReportUtils.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/libs/ReportUtils.ts b/src/libs/ReportUtils.ts index 32e9c527f084..ba6d644f8eac 100644 --- a/src/libs/ReportUtils.ts +++ b/src/libs/ReportUtils.ts @@ -4333,7 +4333,7 @@ function canRequestMoney(report: OnyxEntry, policy: OnyxEntry, o */ function getMoneyRequestOptions(report: OnyxEntry, policy: OnyxEntry, reportParticipants: number[]): Array> { // In any thread or task report, we do not allow any new money requests yet - if (isChatThread(report) || isTaskReport(report)) { + if (isChatThread(report) || isTaskReport(report) || isSelfDM(report)){ return []; } @@ -4356,7 +4356,7 @@ function getMoneyRequestOptions(report: OnyxEntry, policy: OnyxEntry 0) || (isDM(report) && hasMultipleOtherParticipants) || - (isPolicyExpenseChat(report) && report?.isOwnPolicyExpenseChat && !isSelfDM(report)) + (isPolicyExpenseChat(report) && report?.isOwnPolicyExpenseChat) ) { options = [CONST.IOU.TYPE.SPLIT]; } @@ -4366,7 +4366,7 @@ function getMoneyRequestOptions(report: OnyxEntry, policy: OnyxEntry Date: Sat, 2 Mar 2024 05:20:15 +0530 Subject: [PATCH 157/170] modify for readibility Co-authored-by: Pavlo Tsimura --- src/pages/ProfilePage.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pages/ProfilePage.js b/src/pages/ProfilePage.js index 21ff7a20a472..504a9d28a086 100755 --- a/src/pages/ProfilePage.js +++ b/src/pages/ProfilePage.js @@ -131,7 +131,7 @@ function ProfilePage(props) { const navigateBackTo = lodashGet(props.route, 'params.backTo'); - const shouldShowNotificationPreference = !_.isEmpty(props.report) && props.report.notificationPreference !== CONST.REPORT.NOTIFICATION_PREFERENCE.HIDDEN && !isSelfDM; + const shouldShowNotificationPreference = !_.isEmpty(props.report) && !isSelfDM && props.report.notificationPreference !== CONST.REPORT.NOTIFICATION_PREFERENCE.HIDDEN; const notificationPreference = shouldShowNotificationPreference ? props.translate(`notificationPreferencesPage.notificationPreferences.${props.report.notificationPreference}`) : ''; // eslint-disable-next-line rulesdir/prefer-early-return From f33be378306bac233401d02c483aa004d1626ecb Mon Sep 17 00:00:00 2001 From: Ishpaul Singh Date: Sat, 2 Mar 2024 05:27:52 +0530 Subject: [PATCH 158/170] remove comments --- src/languages/es.ts | 2 -- src/libs/PersonalDetailsUtils.ts | 6 +++--- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/src/languages/es.ts b/src/languages/es.ts index ff9919bc3f11..83ed2ca1c89c 100644 --- a/src/languages/es.ts +++ b/src/languages/es.ts @@ -485,11 +485,9 @@ export default { beginningOfChatHistoryPolicyExpenseChatPartOne: '¡La colaboración entre ', beginningOfChatHistoryPolicyExpenseChatPartTwo: ' y ', beginningOfChatHistoryPolicyExpenseChatPartThree: ' empieza aquí! 🎉 Este es el lugar donde chatear, pedir dinero y pagar.', - // todo: ask for the correct translation beginningOfChatHistorySelfDM: 'Este es tu espacio personal. Úsalo para notas, tareas, borradores y recordatorios.', chatWithAccountManager: 'Chatea con tu gestor de cuenta aquí', sayHello: '¡Saluda!', - // todo: ask for the correct translation yourSpace: 'Tu espacio', welcomeToRoom: ({roomName}: WelcomeToRoomParams) => `¡Bienvenido a ${roomName}!`, usePlusButton: ({additionalText}: UsePlusButtonParams) => `\n¡También puedes usar el botón + de abajo para ${additionalText}, o asignar una tarea!`, diff --git a/src/libs/PersonalDetailsUtils.ts b/src/libs/PersonalDetailsUtils.ts index e140dc24a975..2b36ea4e2123 100644 --- a/src/libs/PersonalDetailsUtils.ts +++ b/src/libs/PersonalDetailsUtils.ts @@ -24,10 +24,10 @@ Onyx.connect({ }, }); -function getDisplayNameOrDefault(passedPersonalDetails?: Partial | null, defaultValue = '', shouldFallbackToHidden = true, shouldAddCurrentUserPostfix = false): string { +function getDisplayNameOrDefault(passedPersonalDetails?: Partial | null, defaultValue = '', shouldFallbackToHidden = true, shouldUsePostfix = false, postfix = Localize.translateLocal('common.you').toLowerCase()): string { let displayName = passedPersonalDetails?.displayName ? passedPersonalDetails.displayName.replace(CONST.REGEX.MERGED_ACCOUNT_PREFIX, '') : ''; - if (shouldAddCurrentUserPostfix) { - displayName = `${displayName} (${Localize.translateLocal('common.you').toLowerCase()})`; + if (shouldUsePostfix && !!displayName) { + displayName = `${displayName} (${postfix})`; } const fallbackValue = shouldFallbackToHidden ? Localize.translateLocal('common.hidden') : ''; From c0b06bbe36faa79a1da3f44417367cdd709a5a39 Mon Sep 17 00:00:00 2001 From: Ishpaul Singh Date: Sat, 2 Mar 2024 05:31:49 +0530 Subject: [PATCH 159/170] fixes you postfix not showing up in profilepage --- src/pages/ProfilePage.js | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/pages/ProfilePage.js b/src/pages/ProfilePage.js index 504a9d28a086..46d67371a1a1 100755 --- a/src/pages/ProfilePage.js +++ b/src/pages/ProfilePage.js @@ -95,10 +95,10 @@ const getPhoneNumber = (details) => { function ProfilePage(props) { const styles = useThemeStyles(); const accountID = Number(lodashGet(props.route.params, 'accountID', 0)); - const isSelfDM = ReportUtils.isSelfDM(props.report); + const isCurrentUser = props.session.accountID === accountID; const details = lodashGet(props.personalDetails, accountID, ValidationUtils.isValidAccountRoute(accountID) ? {} : {isloading: false}); - const displayName = PersonalDetailsUtils.getDisplayNameOrDefault(details, undefined, undefined, isSelfDM); + const displayName = PersonalDetailsUtils.getDisplayNameOrDefault(details, undefined, undefined, isCurrentUser); const avatar = lodashGet(details, 'avatar', UserUtils.getDefaultAvatar()); const fallbackIcon = lodashGet(details, 'fallbackIcon', ''); const login = lodashGet(details, 'login', ''); @@ -117,7 +117,6 @@ function ProfilePage(props) { const phoneNumber = getPhoneNumber(details); const phoneOrEmail = isSMSLogin ? getPhoneNumber(details) : login; - const isCurrentUser = props.session.accountID === accountID; const hasMinimumDetails = !_.isEmpty(details.avatar); const isLoading = lodashGet(details, 'isLoading', false) || _.isEmpty(details); From c8e1e029cbaad4e181a00db7b957c72953f88514 Mon Sep 17 00:00:00 2001 From: Ishpaul Singh <104348397+ishpaul777@users.noreply.github.com> Date: Sat, 2 Mar 2024 05:33:03 +0530 Subject: [PATCH 160/170] fixes comment as per suggestion Co-authored-by: Pavlo Tsimura --- src/pages/ReportDetailsPage.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pages/ReportDetailsPage.tsx b/src/pages/ReportDetailsPage.tsx index ae896b4298bf..b604f19b29b4 100644 --- a/src/pages/ReportDetailsPage.tsx +++ b/src/pages/ReportDetailsPage.tsx @@ -86,7 +86,7 @@ function ReportDetailsPage({policies, report, session, personalDetails}: ReportD const isSelfDM = useMemo(() => ReportUtils.isSelfDM(report), [report]); useEffect(() => { - // Do not fetch private notes if isLoadingPrivateNotes is already defined, or if network is offline or if report is a self DM + // Do not fetch private notes if isLoadingPrivateNotes is already defined, or if the network is offline, or if the report is a self DM. if (isPrivateNotesFetchTriggered || isOffline || isSelfDM) { return; } From c8127259eff706a82e08b15fa9fcf6e858b3cb5e Mon Sep 17 00:00:00 2001 From: Ishpaul Singh Date: Sat, 2 Mar 2024 05:40:28 +0530 Subject: [PATCH 161/170] formatting --- src/libs/PersonalDetailsUtils.ts | 8 +++++++- src/libs/ReportUtils.ts | 8 ++------ src/pages/ProfilePage.js | 6 +++--- 3 files changed, 12 insertions(+), 10 deletions(-) diff --git a/src/libs/PersonalDetailsUtils.ts b/src/libs/PersonalDetailsUtils.ts index 2b36ea4e2123..5a4aed787cd3 100644 --- a/src/libs/PersonalDetailsUtils.ts +++ b/src/libs/PersonalDetailsUtils.ts @@ -24,7 +24,13 @@ Onyx.connect({ }, }); -function getDisplayNameOrDefault(passedPersonalDetails?: Partial | null, defaultValue = '', shouldFallbackToHidden = true, shouldUsePostfix = false, postfix = Localize.translateLocal('common.you').toLowerCase()): string { +function getDisplayNameOrDefault( + passedPersonalDetails?: Partial | null, + defaultValue = '', + shouldFallbackToHidden = true, + shouldUsePostfix = false, + postfix = Localize.translateLocal('common.you').toLowerCase(), +): string { let displayName = passedPersonalDetails?.displayName ? passedPersonalDetails.displayName.replace(CONST.REGEX.MERGED_ACCOUNT_PREFIX, '') : ''; if (shouldUsePostfix && !!displayName) { displayName = `${displayName} (${postfix})`; diff --git a/src/libs/ReportUtils.ts b/src/libs/ReportUtils.ts index a4935dbea9b7..b2fb456681cf 100644 --- a/src/libs/ReportUtils.ts +++ b/src/libs/ReportUtils.ts @@ -4333,7 +4333,7 @@ function canRequestMoney(report: OnyxEntry, policy: OnyxEntry, o */ function getMoneyRequestOptions(report: OnyxEntry, policy: OnyxEntry, reportParticipants: number[]): Array> { // In any thread or task report, we do not allow any new money requests yet - if (isChatThread(report) || isTaskReport(report) || isSelfDM(report)){ + if (isChatThread(report) || isTaskReport(report) || isSelfDM(report)) { return []; } @@ -4353,11 +4353,7 @@ function getMoneyRequestOptions(report: OnyxEntry, policy: OnyxEntry 0) || - (isDM(report) && hasMultipleOtherParticipants) || - (isPolicyExpenseChat(report) && report?.isOwnPolicyExpenseChat) - ) { + if ((isChatRoom(report) && otherParticipants.length > 0) || (isDM(report) && hasMultipleOtherParticipants) || (isPolicyExpenseChat(report) && report?.isOwnPolicyExpenseChat)) { options = [CONST.IOU.TYPE.SPLIT]; } diff --git a/src/pages/ProfilePage.js b/src/pages/ProfilePage.js index 46d67371a1a1..cf05b8e4ab28 100755 --- a/src/pages/ProfilePage.js +++ b/src/pages/ProfilePage.js @@ -130,7 +130,7 @@ function ProfilePage(props) { const navigateBackTo = lodashGet(props.route, 'params.backTo'); - const shouldShowNotificationPreference = !_.isEmpty(props.report) && !isSelfDM && props.report.notificationPreference !== CONST.REPORT.NOTIFICATION_PREFERENCE.HIDDEN; + const shouldShowNotificationPreference = !_.isEmpty(props.report) && !isCurrentUser && props.report.notificationPreference !== CONST.REPORT.NOTIFICATION_PREFERENCE.HIDDEN; const notificationPreference = shouldShowNotificationPreference ? props.translate(`notificationPreferencesPage.notificationPreferences.${props.report.notificationPreference}`) : ''; // eslint-disable-next-line rulesdir/prefer-early-return @@ -224,7 +224,7 @@ function ProfilePage(props) { wrapperStyle={[styles.mtn6, styles.mb5]} /> )} - {!isCurrentUser && !Session.isAnonymousUser() && !isSelfDM && ( + {!isCurrentUser && !Session.isAnonymousUser() && ( )} - {!_.isEmpty(props.report) && !isSelfDM && ( + {!_.isEmpty(props.report) && !isCurrentUser && ( Date: Sat, 2 Mar 2024 05:42:57 +0530 Subject: [PATCH 162/170] revert back changes --- src/libs/PersonalDetailsUtils.ts | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/libs/PersonalDetailsUtils.ts b/src/libs/PersonalDetailsUtils.ts index 5a4aed787cd3..c5772e77ae8f 100644 --- a/src/libs/PersonalDetailsUtils.ts +++ b/src/libs/PersonalDetailsUtils.ts @@ -28,12 +28,11 @@ function getDisplayNameOrDefault( passedPersonalDetails?: Partial | null, defaultValue = '', shouldFallbackToHidden = true, - shouldUsePostfix = false, - postfix = Localize.translateLocal('common.you').toLowerCase(), + shouldAddCurrentUserPostfix = false, ): string { let displayName = passedPersonalDetails?.displayName ? passedPersonalDetails.displayName.replace(CONST.REGEX.MERGED_ACCOUNT_PREFIX, '') : ''; - if (shouldUsePostfix && !!displayName) { - displayName = `${displayName} (${postfix})`; + if (shouldAddCurrentUserPostfix && !!displayName) { + displayName = `${displayName} (${Localize.translateLocal('common.you').toLowerCase()})`; } const fallbackValue = shouldFallbackToHidden ? Localize.translateLocal('common.hidden') : ''; From 68a348fc3b167e636500a4025d47b1bbbec7d8ad Mon Sep 17 00:00:00 2001 From: Ishpaul Singh <104348397+ishpaul777@users.noreply.github.com> Date: Sat, 2 Mar 2024 05:43:37 +0530 Subject: [PATCH 163/170] Update src/pages/ReportDetailsPage.tsx Co-authored-by: Pavlo Tsimura --- src/pages/ReportDetailsPage.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pages/ReportDetailsPage.tsx b/src/pages/ReportDetailsPage.tsx index b604f19b29b4..e94c0cc80952 100644 --- a/src/pages/ReportDetailsPage.tsx +++ b/src/pages/ReportDetailsPage.tsx @@ -98,7 +98,7 @@ function ReportDetailsPage({policies, report, session, personalDetails}: ReportD const items: ReportDetailsPageMenuItem[] = []; if (isSelfDM) { - return items; + return []; } if (!isGroupDMChat) { From 5d167b0b9036563b99beae30986ea6bff0601b33 Mon Sep 17 00:00:00 2001 From: Ishpaul Singh <104348397+ishpaul777@users.noreply.github.com> Date: Sat, 2 Mar 2024 05:44:26 +0530 Subject: [PATCH 164/170] Update src/pages/home/HeaderView.js Co-authored-by: Pavlo Tsimura --- src/pages/home/HeaderView.js | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/src/pages/home/HeaderView.js b/src/pages/home/HeaderView.js index a58a8c3834cc..8cc2661f8f45 100644 --- a/src/pages/home/HeaderView.js +++ b/src/pages/home/HeaderView.js @@ -94,10 +94,7 @@ function HeaderView(props) { const theme = useTheme(); const styles = useThemeStyles(); const isSelfDM = ReportUtils.isSelfDM(props.report); - let participants = lodashGet(props.report, 'participantAccountIDs', []); - if (isSelfDM) { - participants = [props.session.accountID]; - } + const participants = isSelfDM ? [props.session.accountID] : lodashGet(props.report, 'participantAccountIDs', []); const participantPersonalDetails = OptionsListUtils.getPersonalDetailsForAccountIDs(participants, props.personalDetails); const isMultipleParticipant = participants.length > 1; const displayNamesWithTooltips = ReportUtils.getDisplayNamesWithTooltips(participantPersonalDetails, isMultipleParticipant, undefined, isSelfDM); From a67cbc898b5642f777c41f32e58b9b28592b0d0e Mon Sep 17 00:00:00 2001 From: Ishpaul Singh <104348397+ishpaul777@users.noreply.github.com> Date: Sat, 2 Mar 2024 05:44:56 +0530 Subject: [PATCH 165/170] Update src/libs/OptionsListUtils.ts Co-authored-by: Pavlo Tsimura --- src/libs/OptionsListUtils.ts | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/src/libs/OptionsListUtils.ts b/src/libs/OptionsListUtils.ts index 3be4b87316f9..4cd43ee57322 100644 --- a/src/libs/OptionsListUtils.ts +++ b/src/libs/OptionsListUtils.ts @@ -1477,11 +1477,7 @@ function getOptions( const isPolicyExpenseChat = ReportUtils.isPolicyExpenseChat(report); const isMoneyRequestReport = ReportUtils.isMoneyRequestReport(report); const isSelfDM = ReportUtils.isSelfDM(report); - let accountIDs = report.visibleChatMemberAccountIDs ?? []; - - if (isSelfDM) { - accountIDs = [currentUserAccountID ?? 0]; - } + const accountIDs = isSelfDM ? [currentUserAccountID ?? 0] : report.visibleChatMemberAccountIDs ?? []; if (isPolicyExpenseChat && report.isOwnPolicyExpenseChat && !includeOwnedWorkspaceChats) { return; From 80a0e448795b4de66496013e60e588f7bc4cf558 Mon Sep 17 00:00:00 2001 From: Ishpaul Singh Date: Sat, 2 Mar 2024 05:46:05 +0530 Subject: [PATCH 166/170] fixes review comment --- src/components/ReportWelcomeText.tsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/components/ReportWelcomeText.tsx b/src/components/ReportWelcomeText.tsx index 1650a24fdb98..e9bbd0f27bdc 100644 --- a/src/components/ReportWelcomeText.tsx +++ b/src/components/ReportWelcomeText.tsx @@ -55,7 +55,7 @@ function ReportWelcomeText({report, policy, personalDetails}: ReportWelcomeTextP Navigation.navigate(ROUTES.REPORT_WITH_ID_DETAILS.getRoute(report.reportID)); }; - const getWelcomeHeroText = useMemo(() => { + const welcomeHeroText = useMemo(() => { if (isChatRoom) { return translate('reportActionsView.welcomeToRoom', {roomName: reportName}); } @@ -70,7 +70,7 @@ function ReportWelcomeText({report, policy, personalDetails}: ReportWelcomeTextP return ( <> - {getWelcomeHeroText} + {welcomeHeroText} {isPolicyExpenseChat && From a4d858fcc4063ce312c5c2eef190ce81c01ac317 Mon Sep 17 00:00:00 2001 From: Ishpaul Singh Date: Sat, 2 Mar 2024 05:56:06 +0530 Subject: [PATCH 167/170] lint fix --- src/libs/PersonalDetailsUtils.ts | 7 +------ src/libs/SidebarUtils.ts | 1 + 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/src/libs/PersonalDetailsUtils.ts b/src/libs/PersonalDetailsUtils.ts index c5772e77ae8f..9dd60eeebcef 100644 --- a/src/libs/PersonalDetailsUtils.ts +++ b/src/libs/PersonalDetailsUtils.ts @@ -24,12 +24,7 @@ Onyx.connect({ }, }); -function getDisplayNameOrDefault( - passedPersonalDetails?: Partial | null, - defaultValue = '', - shouldFallbackToHidden = true, - shouldAddCurrentUserPostfix = false, -): string { +function getDisplayNameOrDefault(passedPersonalDetails?: Partial | null, defaultValue = '', shouldFallbackToHidden = true, shouldAddCurrentUserPostfix = false): string { let displayName = passedPersonalDetails?.displayName ? passedPersonalDetails.displayName.replace(CONST.REGEX.MERGED_ACCOUNT_PREFIX, '') : ''; if (shouldAddCurrentUserPostfix && !!displayName) { displayName = `${displayName} (${Localize.translateLocal('common.you').toLowerCase()})`; diff --git a/src/libs/SidebarUtils.ts b/src/libs/SidebarUtils.ts index 7b8496fdd74d..b22e502bfecd 100644 --- a/src/libs/SidebarUtils.ts +++ b/src/libs/SidebarUtils.ts @@ -224,6 +224,7 @@ function getOptionData({ let participantAccountIDs = report.participantAccountIDs ?? []; + // At present, the currentUser is not included in the participantAccountIDs. so for selfDM, we need to add the currentUser as participants. if (ReportUtils.isSelfDM(report)) { participantAccountIDs = [report.ownerAccountID ?? 0]; } From 7c2b9989e72d7afe5fa659343cbdcb1dc7db2512 Mon Sep 17 00:00:00 2001 From: rayane-djouah <77965000+rayane-djouah@users.noreply.github.com> Date: Sat, 2 Mar 2024 01:38:11 +0100 Subject: [PATCH 168/170] Fix type error --- src/components/TaxPicker.tsx | 4 ++-- src/libs/OptionsListUtils.ts | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/components/TaxPicker.tsx b/src/components/TaxPicker.tsx index 11c46ee33e0a..664aa741c400 100644 --- a/src/components/TaxPicker.tsx +++ b/src/components/TaxPicker.tsx @@ -4,14 +4,14 @@ import useLocalize from '@hooks/useLocalize'; import useStyleUtils from '@hooks/useStyleUtils'; import useThemeStyles from '@hooks/useThemeStyles'; import * as OptionsListUtils from '@libs/OptionsListUtils'; -import type {PolicyTaxRateWithDefault} from '@libs/OptionsListUtils'; import * as TransactionUtils from '@libs/TransactionUtils'; import CONST from '@src/CONST'; +import type {TaxRatesWithDefault} from '@src/types/onyx'; import OptionsSelector from './OptionsSelector'; type TaxPickerProps = { /** Collection of tax rates attached to a policy */ - taxRates: PolicyTaxRateWithDefault; + taxRates: TaxRatesWithDefault; /** The selected tax rate of an expense */ selectedTaxRate?: string; diff --git a/src/libs/OptionsListUtils.ts b/src/libs/OptionsListUtils.ts index 313897c5c023..342006eca710 100644 --- a/src/libs/OptionsListUtils.ts +++ b/src/libs/OptionsListUtils.ts @@ -2054,4 +2054,4 @@ export { getShareLogOptions, }; -export type {MemberForList, CategorySection, GetOptions, PolicyTaxRateWithDefault}; +export type {MemberForList, CategorySection, GetOptions}; From 5cfb38d0323a1d93d069f5d2d6ea9fb65c7121d3 Mon Sep 17 00:00:00 2001 From: Ishpaul Singh Date: Sat, 2 Mar 2024 06:08:43 +0530 Subject: [PATCH 169/170] add comment for workaround --- src/libs/OptionsListUtils.ts | 1 + src/libs/SidebarUtils.ts | 2 +- src/pages/home/HeaderView.js | 1 + 3 files changed, 3 insertions(+), 1 deletion(-) diff --git a/src/libs/OptionsListUtils.ts b/src/libs/OptionsListUtils.ts index 4cd43ee57322..706263774b01 100644 --- a/src/libs/OptionsListUtils.ts +++ b/src/libs/OptionsListUtils.ts @@ -1477,6 +1477,7 @@ function getOptions( const isPolicyExpenseChat = ReportUtils.isPolicyExpenseChat(report); const isMoneyRequestReport = ReportUtils.isMoneyRequestReport(report); const isSelfDM = ReportUtils.isSelfDM(report); + // Currently, currentUser is not included in visibleChatMemberAccountIDs, so for selfDM we need to add the currentUser as participants. const accountIDs = isSelfDM ? [currentUserAccountID ?? 0] : report.visibleChatMemberAccountIDs ?? []; if (isPolicyExpenseChat && report.isOwnPolicyExpenseChat && !includeOwnedWorkspaceChats) { diff --git a/src/libs/SidebarUtils.ts b/src/libs/SidebarUtils.ts index b22e502bfecd..a9cbefddec94 100644 --- a/src/libs/SidebarUtils.ts +++ b/src/libs/SidebarUtils.ts @@ -224,7 +224,7 @@ function getOptionData({ let participantAccountIDs = report.participantAccountIDs ?? []; - // At present, the currentUser is not included in the participantAccountIDs. so for selfDM, we need to add the currentUser as participants. + // Currently, currentUser is not included in participantAccountIDs, so for selfDM we need to add the currentUser(report owner) as participants. if (ReportUtils.isSelfDM(report)) { participantAccountIDs = [report.ownerAccountID ?? 0]; } diff --git a/src/pages/home/HeaderView.js b/src/pages/home/HeaderView.js index 8cc2661f8f45..4f09a2da6243 100644 --- a/src/pages/home/HeaderView.js +++ b/src/pages/home/HeaderView.js @@ -94,6 +94,7 @@ function HeaderView(props) { const theme = useTheme(); const styles = useThemeStyles(); const isSelfDM = ReportUtils.isSelfDM(props.report); + // Currently, currentUser is not included in participantAccountIDs, so for selfDM, we need to add the currentUser as participants. const participants = isSelfDM ? [props.session.accountID] : lodashGet(props.report, 'participantAccountIDs', []); const participantPersonalDetails = OptionsListUtils.getPersonalDetailsForAccountIDs(participants, props.personalDetails); const isMultipleParticipant = participants.length > 1; From 0ac94f428c7a8597f727108d972dab3f6c797e72 Mon Sep 17 00:00:00 2001 From: Ishpaul Singh Date: Sat, 2 Mar 2024 06:49:33 +0530 Subject: [PATCH 170/170] fixes report not showing in search --- src/libs/OptionsListUtils.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libs/OptionsListUtils.ts b/src/libs/OptionsListUtils.ts index 706263774b01..bdf1ba90583d 100644 --- a/src/libs/OptionsListUtils.ts +++ b/src/libs/OptionsListUtils.ts @@ -1448,8 +1448,8 @@ function getOptions( policies, doesReportHaveViolations, isInGSDMode: false, - excludeEmptyChats: false, + includeSelfDM, }); });