From f7275e04e6d5aa07438760e51f1532fd165423df Mon Sep 17 00:00:00 2001 From: Robert Kozik Date: Fri, 19 Apr 2024 11:11:35 +0200 Subject: [PATCH 001/137] introduce OnyxAwareParser --- src/libs/OnyxAwareParser.ts | 39 +++++++++++++++++++ .../report/ContextMenu/ContextMenuActions.tsx | 4 +- 2 files changed, 41 insertions(+), 2 deletions(-) create mode 100644 src/libs/OnyxAwareParser.ts diff --git a/src/libs/OnyxAwareParser.ts b/src/libs/OnyxAwareParser.ts new file mode 100644 index 000000000000..4a8d0045abe8 --- /dev/null +++ b/src/libs/OnyxAwareParser.ts @@ -0,0 +1,39 @@ +import ONYXKEYS from "@src/ONYXKEYS"; +import ExpensiMark from "expensify-common/lib/ExpensiMark"; +import Onyx from "react-native-onyx"; + +const parser = new ExpensiMark(); + +const reportIDToNameMap: Record = {}; +const accountIDToNameMap: Record = {}; + +Onyx.connect({ + key: ONYXKEYS.COLLECTION.REPORT, + callback: (report) => { + if (!report) { + return; + } + + reportIDToNameMap[report.reportID] = report.reportName ?? ''; + }, +}) + +Onyx.connect({ + key: ONYXKEYS.PERSONAL_DETAILS_LIST, + callback: (personalDetailsList) => { + Object.values(personalDetailsList ?? {}).forEach((personalDetails) => { + if (!personalDetails) { + return; + } + + accountIDToNameMap[personalDetails.accountID] = personalDetails.displayName ?? ''; + }); + }, +}) + + +function parseHtmlToMarkdown(html: string): string { + return parser.htmlToMarkdown(html, {reportIdToName: reportIDToNameMap, accountIDToName: accountIDToNameMap}); +}; + +export default parseHtmlToMarkdown; diff --git a/src/pages/home/report/ContextMenu/ContextMenuActions.tsx b/src/pages/home/report/ContextMenu/ContextMenuActions.tsx index b5cb9d911ef5..efe728148887 100644 --- a/src/pages/home/report/ContextMenu/ContextMenuActions.tsx +++ b/src/pages/home/report/ContextMenu/ContextMenuActions.tsx @@ -30,6 +30,7 @@ import type {TranslationPaths} from '@src/languages/types'; import ROUTES from '@src/ROUTES'; import type {Beta, ReportAction, ReportActionReactions, Transaction} from '@src/types/onyx'; import type IconAsset from '@src/types/utils/IconAsset'; +import parseHtmlToMarkdown from '@libs/OnyxAwareParser'; import type {ContextMenuAnchor} from './ReportActionContextMenu'; import {hideContextMenu, showDeleteModal} from './ReportActionContextMenu'; @@ -232,8 +233,7 @@ const ContextMenuActions: ContextMenuAction[] = [ } const editAction = () => { if (!draftMessage) { - const parser = new ExpensiMark(); - Report.saveReportActionDraft(reportID, reportAction, parser.htmlToMarkdown(getActionHtml(reportAction))); + Report.saveReportActionDraft(reportID, reportAction, parseHtmlToMarkdown(getActionHtml(reportAction))); } else { Report.deleteReportActionDraft(reportID, reportAction); } From 7b3fe65b72567ec3bb7f516f531263b57a5914f8 Mon Sep 17 00:00:00 2001 From: war-in Date: Fri, 19 Apr 2024 15:06:04 +0200 Subject: [PATCH 002/137] `parser.htmlTo` -> `parseHtmlTo` --- package-lock.json | 6 +++--- package.json | 2 +- src/hooks/useCopySelectionHelper.ts | 7 +++---- src/hooks/useHtmlPaste/index.ts | 5 ++--- src/libs/OnyxAwareParser.ts | 19 +++++++++++-------- src/libs/ReportUtils.ts | 10 ++++------ src/libs/actions/Report.ts | 5 +++-- .../PrivateNotes/PrivateNotesEditPage.tsx | 7 +++---- src/pages/RoomDescriptionPage.tsx | 5 ++--- .../report/ContextMenu/ContextMenuActions.tsx | 8 +++----- .../ComposerWithSuggestions.tsx | 5 ++--- .../report/ReportActionItemMessageEdit.tsx | 5 ++--- src/pages/tasks/NewTaskDescriptionPage.tsx | 3 ++- src/pages/tasks/NewTaskDetailsPage.tsx | 5 +++-- src/pages/tasks/TaskDescriptionPage.tsx | 5 +++-- .../workspace/WorkspaceInviteMessagePage.tsx | 3 ++- .../WorkspaceProfileDescriptionPage.tsx | 3 ++- src/pages/workspace/taxes/NamePage.tsx | 6 ++---- 18 files changed, 53 insertions(+), 56 deletions(-) diff --git a/package-lock.json b/package-lock.json index 52a975e3a83e..80484c07a6fa 100644 --- a/package-lock.json +++ b/package-lock.json @@ -57,7 +57,7 @@ "date-fns-tz": "^2.0.0", "dom-serializer": "^0.2.2", "domhandler": "^4.3.0", - "expensify-common": "git+ssh://git@github.com/Expensify/expensify-common.git#c0f7f3b6558fbeda0527c80d68460d418afef219", + "expensify-common": "git+ssh://git@github.com:software-mansion-labs/expensify-common.git#7596ae07c9cd5a6b5265897034898b4526d681dc", "expo": "^50.0.3", "expo-av": "~13.10.4", "expo-image": "1.11.0", @@ -20213,8 +20213,8 @@ }, "node_modules/expensify-common": { "version": "1.0.0", - "resolved": "git+ssh://git@github.com/Expensify/expensify-common.git#c0f7f3b6558fbeda0527c80d68460d418afef219", - "integrity": "sha512-zz0/y0apISP1orxXEQOgn+Uod45O4wVypwwtaqcDPV4dH1tC3i4L98NoLSZvLn7Y17EcceSkfN6QCEsscgFTDQ==", + "resolved": "git+ssh://git@github.com/software-mansion-labs/expensify-common.git#7596ae07c9cd5a6b5265897034898b4526d681dc", + "integrity": "sha512-Ns7qkMuJ4SeLj0lrj3i+KqHBzjlym8baDlS7CUIqq2tuNXkgxwO4D+5d6U3ooLOf0CyWb56KaGy5TOTFqpJDZA==", "license": "MIT", "dependencies": { "classnames": "2.5.0", diff --git a/package.json b/package.json index 1cef7d94fcba..50029f0e22c3 100644 --- a/package.json +++ b/package.json @@ -108,7 +108,7 @@ "date-fns-tz": "^2.0.0", "dom-serializer": "^0.2.2", "domhandler": "^4.3.0", - "expensify-common": "git+ssh://git@github.com/Expensify/expensify-common.git#c0f7f3b6558fbeda0527c80d68460d418afef219", + "expensify-common": "git+ssh://git@github.com:software-mansion-labs/expensify-common.git#7596ae07c9cd5a6b5265897034898b4526d681dc", "expo": "^50.0.3", "expo-av": "~13.10.4", "expo-image": "1.11.0", diff --git a/src/hooks/useCopySelectionHelper.ts b/src/hooks/useCopySelectionHelper.ts index be7830dc6170..ed379bfcf2e6 100644 --- a/src/hooks/useCopySelectionHelper.ts +++ b/src/hooks/useCopySelectionHelper.ts @@ -1,7 +1,7 @@ -import ExpensiMark from 'expensify-common/lib/ExpensiMark'; import {useEffect} from 'react'; import Clipboard from '@libs/Clipboard'; import KeyboardShortcut from '@libs/KeyboardShortcut'; +import {parseHtmlToMarkdown, parseHtmlToText} from '@libs/OnyxAwareParser'; import SelectionScraper from '@libs/SelectionScraper'; import CONST from '@src/CONST'; @@ -10,12 +10,11 @@ function copySelectionToClipboard() { if (!selection) { return; } - const parser = new ExpensiMark(); if (!Clipboard.canSetHtml()) { - Clipboard.setString(parser.htmlToMarkdown(selection)); + Clipboard.setString(parseHtmlToMarkdown(selection)); return; } - Clipboard.setHtml(selection, parser.htmlToText(selection)); + Clipboard.setHtml(selection, parseHtmlToText(selection)); } export default function useCopySelectionHelper() { diff --git a/src/hooks/useHtmlPaste/index.ts b/src/hooks/useHtmlPaste/index.ts index 925a3db518ae..82a52dbb0fef 100644 --- a/src/hooks/useHtmlPaste/index.ts +++ b/src/hooks/useHtmlPaste/index.ts @@ -1,6 +1,6 @@ import {useNavigation} from '@react-navigation/native'; -import ExpensiMark from 'expensify-common/lib/ExpensiMark'; import {useCallback, useEffect} from 'react'; +import {parseHtmlToMarkdown} from '@libs/OnyxAwareParser'; import type UseHtmlPaste from './types'; const insertByCommand = (text: string) => { @@ -62,8 +62,7 @@ const useHtmlPaste: UseHtmlPaste = (textInputRef, preHtmlPasteCallback, removeLi */ const handlePastedHTML = useCallback( (html: string) => { - const parser = new ExpensiMark(); - paste(parser.htmlToMarkdown(html)); + paste(parseHtmlToMarkdown(html)); }, [paste], ); diff --git a/src/libs/OnyxAwareParser.ts b/src/libs/OnyxAwareParser.ts index 4a8d0045abe8..853f94d7189f 100644 --- a/src/libs/OnyxAwareParser.ts +++ b/src/libs/OnyxAwareParser.ts @@ -1,6 +1,6 @@ -import ONYXKEYS from "@src/ONYXKEYS"; -import ExpensiMark from "expensify-common/lib/ExpensiMark"; -import Onyx from "react-native-onyx"; +import ExpensiMark from 'expensify-common/lib/ExpensiMark'; +import Onyx from 'react-native-onyx'; +import ONYXKEYS from '@src/ONYXKEYS'; const parser = new ExpensiMark(); @@ -16,7 +16,7 @@ Onyx.connect({ reportIDToNameMap[report.reportID] = report.reportName ?? ''; }, -}) +}); Onyx.connect({ key: ONYXKEYS.PERSONAL_DETAILS_LIST, @@ -29,11 +29,14 @@ Onyx.connect({ accountIDToNameMap[personalDetails.accountID] = personalDetails.displayName ?? ''; }); }, -}) - +}); function parseHtmlToMarkdown(html: string): string { return parser.htmlToMarkdown(html, {reportIdToName: reportIDToNameMap, accountIDToName: accountIDToNameMap}); -}; +} + +function parseHtmlToText(html: string): string { + return parser.htmlToText(html, {reportIdToName: reportIDToNameMap, accountIDToName: accountIDToNameMap}); +} -export default parseHtmlToMarkdown; +export {parseHtmlToMarkdown, parseHtmlToText}; diff --git a/src/libs/ReportUtils.ts b/src/libs/ReportUtils.ts index a15e1937dbe2..42c14c820f0d 100644 --- a/src/libs/ReportUtils.ts +++ b/src/libs/ReportUtils.ts @@ -69,6 +69,7 @@ import ModifiedExpenseMessage from './ModifiedExpenseMessage'; import linkingConfig from './Navigation/linkingConfig'; import Navigation from './Navigation/Navigation'; import * as NumberUtils from './NumberUtils'; +import {parseHtmlToText} from './OnyxAwareParser'; import Permissions from './Permissions'; import * as PersonalDetailsUtils from './PersonalDetailsUtils'; import * as PhoneNumber from './PhoneNumber'; @@ -3174,8 +3175,7 @@ function getReportDescriptionText(report: Report): string { return ''; } - const parser = new ExpensiMark(); - return parser.htmlToText(report.description); + return parseHtmlToText(report.description); } function getPolicyDescriptionText(policy: OnyxEntry): string { @@ -3183,12 +3183,10 @@ function getPolicyDescriptionText(policy: OnyxEntry): string { return ''; } - const parser = new ExpensiMark(); - return parser.htmlToText(policy.description); + return parseHtmlToText(policy.description); } function buildOptimisticAddCommentReportAction(text?: string, file?: FileObject, actorAccountID?: number): OptimisticReportAction { - const parser = new ExpensiMark(); const commentText = getParsedComment(text ?? ''); const isAttachmentOnly = file && !text; const isTextOnly = text && !file; @@ -3200,7 +3198,7 @@ function buildOptimisticAddCommentReportAction(text?: string, file?: FileObject, textForNewComment = CONST.ATTACHMENT_UPLOADING_MESSAGE_HTML; } else if (isTextOnly) { htmlForNewComment = commentText; - textForNewComment = parser.htmlToText(htmlForNewComment); + textForNewComment = parseHtmlToText(htmlForNewComment); } else { htmlForNewComment = `${commentText}\n${CONST.ATTACHMENT_UPLOADING_MESSAGE_HTML}`; textForNewComment = `${commentText}\n${CONST.ATTACHMENT_UPLOADING_MESSAGE_HTML}`; diff --git a/src/libs/actions/Report.ts b/src/libs/actions/Report.ts index a4afff17d972..c4c140e0a85a 100644 --- a/src/libs/actions/Report.ts +++ b/src/libs/actions/Report.ts @@ -57,6 +57,7 @@ import * as ErrorUtils from '@libs/ErrorUtils'; import Log from '@libs/Log'; import Navigation from '@libs/Navigation/Navigation'; import LocalNotification from '@libs/Notification/LocalNotification'; +import {parseHtmlToMarkdown, parseHtmlToText} from '@libs/OnyxAwareParser'; import * as PersonalDetailsUtils from '@libs/PersonalDetailsUtils'; import * as PhoneNumber from '@libs/PhoneNumber'; import getPolicyEmployeeAccountIDs from '@libs/PolicyEmployeeListUtils'; @@ -1331,7 +1332,7 @@ function editReportComment(reportID: string, originalReportAction: OnyxEntry ReportActions.getDraftPrivateNote(report.reportID).trim() || parser.htmlToMarkdown(report?.privateNotes?.[Number(route.params.accountID)]?.note ?? '').trim(), + () => ReportActions.getDraftPrivateNote(report.reportID).trim() || parseHtmlToMarkdown(report?.privateNotes?.[Number(route.params.accountID)]?.note ?? '').trim(), ); /** @@ -93,7 +92,7 @@ function PrivateNotesEditPage({route, personalDetailsList, report}: PrivateNotes const originalNote = report?.privateNotes?.[Number(route.params.accountID)]?.note ?? ''; let editedNote = ''; if (privateNote.trim() !== originalNote.trim()) { - editedNote = ReportActions.handleUserDeletedLinksInHtml(privateNote.trim(), parser.htmlToMarkdown(originalNote).trim()); + editedNote = ReportActions.handleUserDeletedLinksInHtml(privateNote.trim(), parseHtmlToMarkdown(originalNote).trim()); ReportActions.updatePrivateNotes(report.reportID, Number(route.params.accountID), editedNote); } diff --git a/src/pages/RoomDescriptionPage.tsx b/src/pages/RoomDescriptionPage.tsx index 9d26de1da9f1..4641ed8c1c4f 100644 --- a/src/pages/RoomDescriptionPage.tsx +++ b/src/pages/RoomDescriptionPage.tsx @@ -1,5 +1,4 @@ import {useFocusEffect} from '@react-navigation/native'; -import ExpensiMark from 'expensify-common/lib/ExpensiMark'; import React, {useCallback, useRef, useState} from 'react'; import {View} from 'react-native'; import type {OnyxCollection} from 'react-native-onyx'; @@ -13,6 +12,7 @@ import TextInput from '@components/TextInput'; import type {BaseTextInputRef} from '@components/TextInput/BaseTextInput/types'; import useLocalize from '@hooks/useLocalize'; import useThemeStyles from '@hooks/useThemeStyles'; +import {parseHtmlToMarkdown} from '@libs/OnyxAwareParser'; import * as ReportUtils from '@libs/ReportUtils'; import updateMultilineInputRange from '@libs/updateMultilineInputRange'; import * as Report from '@userActions/Report'; @@ -31,8 +31,7 @@ type RoomDescriptionPageProps = { function RoomDescriptionPage({report, policies}: RoomDescriptionPageProps) { const styles = useThemeStyles(); - const parser = new ExpensiMark(); - const [description, setDescription] = useState(() => parser.htmlToMarkdown(report?.description ?? '')); + const [description, setDescription] = useState(() => parseHtmlToMarkdown(report?.description ?? '')); const reportDescriptionInputRef = useRef(null); const focusTimeoutRef = useRef | null>(null); const {translate} = useLocalize(); diff --git a/src/pages/home/report/ContextMenu/ContextMenuActions.tsx b/src/pages/home/report/ContextMenu/ContextMenuActions.tsx index bd3bedb2a83c..db096e26cd30 100644 --- a/src/pages/home/report/ContextMenu/ContextMenuActions.tsx +++ b/src/pages/home/report/ContextMenu/ContextMenuActions.tsx @@ -1,4 +1,3 @@ -import ExpensiMark from 'expensify-common/lib/ExpensiMark'; import Str from 'expensify-common/lib/str'; import type {MutableRefObject} from 'react'; import React from 'react'; @@ -19,6 +18,7 @@ import getAttachmentDetails from '@libs/fileDownload/getAttachmentDetails'; import * as Localize from '@libs/Localize'; import ModifiedExpenseMessage from '@libs/ModifiedExpenseMessage'; import Navigation from '@libs/Navigation/Navigation'; +import {parseHtmlToMarkdown, parseHtmlToText} from '@libs/OnyxAwareParser'; import ReportActionComposeFocusManager from '@libs/ReportActionComposeFocusManager'; import * as ReportActionsUtils from '@libs/ReportActionsUtils'; import * as ReportUtils from '@libs/ReportUtils'; @@ -30,7 +30,6 @@ import type {TranslationPaths} from '@src/languages/types'; import ROUTES from '@src/ROUTES'; import type {Beta, ReportAction, ReportActionReactions, Transaction} from '@src/types/onyx'; import type IconAsset from '@src/types/utils/IconAsset'; -import parseHtmlToMarkdown from '@libs/OnyxAwareParser'; import type {ContextMenuAnchor} from './ReportActionContextMenu'; import {hideContextMenu, showDeleteModal} from './ReportActionContextMenu'; @@ -42,11 +41,10 @@ function getActionHtml(reportAction: OnyxEntry): string { /** Sets the HTML string to Clipboard */ function setClipboardMessage(content: string) { - const parser = new ExpensiMark(); if (!Clipboard.canSetHtml()) { - Clipboard.setString(parser.htmlToMarkdown(content)); + Clipboard.setString(parseHtmlToMarkdown(content)); } else { - const plainText = parser.htmlToText(content); + const plainText = parseHtmlToText(content); Clipboard.setHtml(content, plainText); } } diff --git a/src/pages/home/report/ReportActionCompose/ComposerWithSuggestions/ComposerWithSuggestions.tsx b/src/pages/home/report/ReportActionCompose/ComposerWithSuggestions/ComposerWithSuggestions.tsx index 8f42da5a1575..6fc09fb1b15b 100644 --- a/src/pages/home/report/ReportActionCompose/ComposerWithSuggestions/ComposerWithSuggestions.tsx +++ b/src/pages/home/report/ReportActionCompose/ComposerWithSuggestions/ComposerWithSuggestions.tsx @@ -1,5 +1,4 @@ import {useIsFocused, useNavigation} from '@react-navigation/native'; -import ExpensiMark from 'expensify-common/lib/ExpensiMark'; import lodashDebounce from 'lodash/debounce'; import type {ForwardedRef, MutableRefObject, RefAttributes, RefObject} from 'react'; import React, {forwardRef, memo, useCallback, useEffect, useImperativeHandle, useMemo, useRef, useState} from 'react'; @@ -35,6 +34,7 @@ import * as EmojiUtils from '@libs/EmojiUtils'; import focusComposerWithDelay from '@libs/focusComposerWithDelay'; import getPlatform from '@libs/getPlatform'; import * as KeyDownListener from '@libs/KeyboardShortcut/KeyDownPressListener'; +import {parseHtmlToMarkdown} from '@libs/OnyxAwareParser'; import ReportActionComposeFocusManager from '@libs/ReportActionComposeFocusManager'; import * as ReportActionsUtils from '@libs/ReportActionsUtils'; import * as ReportUtils from '@libs/ReportUtils'; @@ -536,8 +536,7 @@ function ComposerWithSuggestions( ) { event.preventDefault(); if (lastReportAction) { - const parser = new ExpensiMark(); - Report.saveReportActionDraft(reportID, lastReportAction, parser.htmlToMarkdown(lastReportAction.message?.at(-1)?.html ?? '')); + Report.saveReportActionDraft(reportID, lastReportAction, parseHtmlToMarkdown(lastReportAction.message?.at(-1)?.html ?? '')); } } }, diff --git a/src/pages/home/report/ReportActionItemMessageEdit.tsx b/src/pages/home/report/ReportActionItemMessageEdit.tsx index fc3c92434fc4..cc1d2789a09a 100644 --- a/src/pages/home/report/ReportActionItemMessageEdit.tsx +++ b/src/pages/home/report/ReportActionItemMessageEdit.tsx @@ -1,4 +1,3 @@ -import ExpensiMark from 'expensify-common/lib/ExpensiMark'; import lodashDebounce from 'lodash/debounce'; import type {ForwardedRef} from 'react'; import React, {forwardRef, useCallback, useEffect, useMemo, useRef, useState} from 'react'; @@ -28,6 +27,7 @@ import * as EmojiUtils from '@libs/EmojiUtils'; import focusComposerWithDelay from '@libs/focusComposerWithDelay'; import type {Selection} from '@libs/focusComposerWithDelay/types'; import focusEditAfterCancelDelete from '@libs/focusEditAfterCancelDelete'; +import {parseHtmlToMarkdown} from '@libs/OnyxAwareParser'; import onyxSubscribe from '@libs/onyxSubscribe'; import ReportActionComposeFocusManager from '@libs/ReportActionComposeFocusManager'; import * as ReportActionsUtils from '@libs/ReportActionsUtils'; @@ -117,8 +117,7 @@ function ReportActionItemMessageEdit( const isCommentPendingSaved = useRef(false); useEffect(() => { - const parser = new ExpensiMark(); - const originalMessage = parser.htmlToMarkdown(action.message?.[0]?.html ?? ''); + const originalMessage = parseHtmlToMarkdown(action.message?.[0]?.html ?? ''); if ( ReportActionsUtils.isDeletedAction(action) || Boolean(action.message && draftMessage === originalMessage) || diff --git a/src/pages/tasks/NewTaskDescriptionPage.tsx b/src/pages/tasks/NewTaskDescriptionPage.tsx index e33241c52f4a..4bca46213671 100644 --- a/src/pages/tasks/NewTaskDescriptionPage.tsx +++ b/src/pages/tasks/NewTaskDescriptionPage.tsx @@ -16,6 +16,7 @@ import useThemeStyles from '@hooks/useThemeStyles'; import * as ErrorUtils from '@libs/ErrorUtils'; import Navigation from '@libs/Navigation/Navigation'; import type {NewTaskNavigatorParamList} from '@libs/Navigation/types'; +import {parseHtmlToMarkdown} from '@libs/OnyxAwareParser'; import updateMultilineInputRange from '@libs/updateMultilineInputRange'; import * as TaskActions from '@userActions/Task'; import CONST from '@src/CONST'; @@ -77,7 +78,7 @@ function NewTaskDescriptionPage({task}: NewTaskDescriptionPageProps) { { setTaskTitle(task?.title ?? ''); - setTaskDescription(parser.htmlToMarkdown(parser.replace(task?.description ?? ''))); + setTaskDescription(parseHtmlToMarkdown(parser.replace(task?.description ?? ''))); }, [task]); const validate = (values: FormOnyxValues): FormInputErrors => { @@ -132,7 +133,7 @@ function NewTaskDetailsPage({task}: NewTaskDetailsPageProps) { autoGrowHeight shouldSubmitForm containerStyles={styles.autoGrowHeightMultilineInput} - defaultValue={parser.htmlToMarkdown(parser.replace(taskDescription))} + defaultValue={parseHtmlToMarkdown(parser.replace(taskDescription))} value={taskDescription} onValueChange={setTaskDescription} isMarkdownEnabled diff --git a/src/pages/tasks/TaskDescriptionPage.tsx b/src/pages/tasks/TaskDescriptionPage.tsx index 9abe15a5bb80..63bff1073698 100644 --- a/src/pages/tasks/TaskDescriptionPage.tsx +++ b/src/pages/tasks/TaskDescriptionPage.tsx @@ -16,6 +16,7 @@ import useLocalize from '@hooks/useLocalize'; import useThemeStyles from '@hooks/useThemeStyles'; import * as ErrorUtils from '@libs/ErrorUtils'; import Navigation from '@libs/Navigation/Navigation'; +import {parseHtmlToMarkdown} from '@libs/OnyxAwareParser'; import * as ReportUtils from '@libs/ReportUtils'; import updateMultilineInputRange from '@libs/updateMultilineInputRange'; import withReportOrNotFound from '@pages/home/report/withReportOrNotFound'; @@ -46,7 +47,7 @@ function TaskDescriptionPage({report, currentUserPersonalDetails}: TaskDescripti const submit = useCallback( (values: FormOnyxValues) => { - if (parser.htmlToMarkdown(parser.replace(values.description)) !== parser.htmlToMarkdown(parser.replace(report?.description ?? '')) && !isEmptyObject(report)) { + if (parseHtmlToMarkdown(parser.replace(values.description)) !== parseHtmlToMarkdown(parser.replace(report?.description ?? '')) && !isEmptyObject(report)) { // Set the description of the report in the store and then call EditTask API // to update the description of the report on the server Task.editTask(report, {description: values.description}); @@ -109,7 +110,7 @@ function TaskDescriptionPage({report, currentUserPersonalDetails}: TaskDescripti name={INPUT_IDS.DESCRIPTION} label={translate('newTaskPage.descriptionOptional')} accessibilityLabel={translate('newTaskPage.descriptionOptional')} - defaultValue={parser.htmlToMarkdown((report && parser.replace(report?.description ?? '')) || '')} + defaultValue={parseHtmlToMarkdown((report && parser.replace(report?.description ?? '')) || '')} ref={(element: AnimatedTextInputRef) => { if (!element) { return; diff --git a/src/pages/workspace/WorkspaceInviteMessagePage.tsx b/src/pages/workspace/WorkspaceInviteMessagePage.tsx index 30d66662b996..56e2d5a2c257 100644 --- a/src/pages/workspace/WorkspaceInviteMessagePage.tsx +++ b/src/pages/workspace/WorkspaceInviteMessagePage.tsx @@ -23,6 +23,7 @@ import useAutoFocusInput from '@hooks/useAutoFocusInput'; import useLocalize from '@hooks/useLocalize'; import useThemeStyles from '@hooks/useThemeStyles'; import Navigation from '@libs/Navigation/Navigation'; +import {parseHtmlToMarkdown} from '@libs/OnyxAwareParser'; import * as OptionsListUtils from '@libs/OptionsListUtils'; import * as PolicyUtils from '@libs/PolicyUtils'; import updateMultilineInputRange from '@libs/updateMultilineInputRange'; @@ -93,7 +94,7 @@ function WorkspaceInviteMessagePage({ useEffect(() => { if (!isEmptyObject(invitedEmailsToAccountIDsDraft)) { - setWelcomeNote(parser.htmlToMarkdown(getDefaultWelcomeNote())); + setWelcomeNote(parseHtmlToMarkdown(getDefaultWelcomeNote())); return; } Navigation.goBack(ROUTES.WORKSPACE_INVITE.getRoute(route.params.policyID), true); diff --git a/src/pages/workspace/WorkspaceProfileDescriptionPage.tsx b/src/pages/workspace/WorkspaceProfileDescriptionPage.tsx index 8086f2414e42..52066d8313d6 100644 --- a/src/pages/workspace/WorkspaceProfileDescriptionPage.tsx +++ b/src/pages/workspace/WorkspaceProfileDescriptionPage.tsx @@ -12,6 +12,7 @@ import useLocalize from '@hooks/useLocalize'; import useThemeStyles from '@hooks/useThemeStyles'; import * as ErrorUtils from '@libs/ErrorUtils'; import Navigation from '@libs/Navigation/Navigation'; +import {parseHtmlToMarkdown} from '@libs/OnyxAwareParser'; import updateMultilineInputRange from '@libs/updateMultilineInputRange'; import * as Policy from '@userActions/Policy'; import CONST from '@src/CONST'; @@ -27,7 +28,7 @@ function WorkspaceProfileDescriptionPage({policy}: Props) { const styles = useThemeStyles(); const {translate} = useLocalize(); const [description, setDescription] = useState(() => - parser.htmlToMarkdown( + parseHtmlToMarkdown( // policy?.description can be an empty string // eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing policy?.description || diff --git a/src/pages/workspace/taxes/NamePage.tsx b/src/pages/workspace/taxes/NamePage.tsx index 5c77295a9664..3e5902b140ac 100644 --- a/src/pages/workspace/taxes/NamePage.tsx +++ b/src/pages/workspace/taxes/NamePage.tsx @@ -1,5 +1,4 @@ import type {StackScreenProps} from '@react-navigation/stack'; -import ExpensiMark from 'expensify-common/lib/ExpensiMark'; import React, {useCallback, useState} from 'react'; import {View} from 'react-native'; import FormProvider from '@components/Form/FormProvider'; @@ -14,6 +13,7 @@ import useThemeStyles from '@hooks/useThemeStyles'; import {renamePolicyTax, validateTaxName} from '@libs/actions/TaxRate'; import Navigation from '@libs/Navigation/Navigation'; import type {SettingsNavigatorParamList} from '@libs/Navigation/types'; +import {parseHtmlToMarkdown} from '@libs/OnyxAwareParser'; import * as PolicyUtils from '@libs/PolicyUtils'; import NotFoundPage from '@pages/ErrorPage/NotFoundPage'; import AdminPolicyAccessOrNotFoundWrapper from '@pages/workspace/AdminPolicyAccessOrNotFoundWrapper'; @@ -29,8 +29,6 @@ import INPUT_IDS from '@src/types/form/WorkspaceTaxNameForm'; type NamePageProps = WithPolicyAndFullscreenLoadingProps & StackScreenProps; -const parser = new ExpensiMark(); - function NamePage({ route: { params: {policyID, taxID}, @@ -42,7 +40,7 @@ function NamePage({ const currentTaxRate = PolicyUtils.getTaxByID(policy, taxID); const {inputCallbackRef} = useAutoFocusInput(); - const [name, setName] = useState(() => parser.htmlToMarkdown(currentTaxRate?.name ?? '')); + const [name, setName] = useState(() => parseHtmlToMarkdown(currentTaxRate?.name ?? '')); const goBack = useCallback(() => Navigation.goBack(ROUTES.WORKSPACE_TAX_EDIT.getRoute(policyID ?? '', taxID)), [policyID, taxID]); From baf2a8c18cd41f58b7fdd098a48b53d022e074fa Mon Sep 17 00:00:00 2001 From: war-in Date: Fri, 19 Apr 2024 15:21:18 +0200 Subject: [PATCH 003/137] add fallback when displayName does not exist --- src/libs/OnyxAwareParser.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/libs/OnyxAwareParser.ts b/src/libs/OnyxAwareParser.ts index 853f94d7189f..586b914216be 100644 --- a/src/libs/OnyxAwareParser.ts +++ b/src/libs/OnyxAwareParser.ts @@ -14,7 +14,7 @@ Onyx.connect({ return; } - reportIDToNameMap[report.reportID] = report.reportName ?? ''; + reportIDToNameMap[report.reportID] = report.reportName ?? report.displayName ?? report.reportID; }, }); @@ -26,7 +26,7 @@ Onyx.connect({ return; } - accountIDToNameMap[personalDetails.accountID] = personalDetails.displayName ?? ''; + accountIDToNameMap[personalDetails.accountID] = personalDetails.displayName ?? String(personalDetails.accountID); }); }, }); From 63a70982f9293675e1ce66070b9f1744b03d41b7 Mon Sep 17 00:00:00 2001 From: war-in Date: Fri, 19 Apr 2024 15:25:32 +0200 Subject: [PATCH 004/137] bring back removed trim --- src/libs/actions/Report.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libs/actions/Report.ts b/src/libs/actions/Report.ts index c4c140e0a85a..734078078126 100644 --- a/src/libs/actions/Report.ts +++ b/src/libs/actions/Report.ts @@ -1332,7 +1332,7 @@ function editReportComment(reportID: string, originalReportAction: OnyxEntry Date: Tue, 23 Apr 2024 13:00:15 +0200 Subject: [PATCH 005/137] update expensify-common --- package-lock.json | 6 +++--- package.json | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/package-lock.json b/package-lock.json index 0c30f6c1a74c..17bb60a22ef1 100644 --- a/package-lock.json +++ b/package-lock.json @@ -56,7 +56,7 @@ "date-fns-tz": "^2.0.0", "dom-serializer": "^0.2.2", "domhandler": "^4.3.0", - "expensify-common": "git+ssh://git@github.com:software-mansion-labs/expensify-common.git#7596ae07c9cd5a6b5265897034898b4526d681dc", + "expensify-common": "git+ssh://git@github.com/Expensify/expensify-common.git#9a68635cdcef4c81593c0f816a007bc9c707d46a", "expo": "^50.0.3", "expo-av": "~13.10.4", "expo-image": "1.11.0", @@ -20202,8 +20202,8 @@ }, "node_modules/expensify-common": { "version": "1.0.0", - "resolved": "git+ssh://git@github.com/software-mansion-labs/expensify-common.git#7596ae07c9cd5a6b5265897034898b4526d681dc", - "integrity": "sha512-Ns7qkMuJ4SeLj0lrj3i+KqHBzjlym8baDlS7CUIqq2tuNXkgxwO4D+5d6U3ooLOf0CyWb56KaGy5TOTFqpJDZA==", + "resolved": "git+ssh://git@github.com/Expensify/expensify-common.git#9a68635cdcef4c81593c0f816a007bc9c707d46a", + "integrity": "sha512-9BHjM3kZs7/dil0oykEQFkEhXjVD5liTttmO7ZYtPZkl4j6g97mubY2p9lYpWwpkWckUfvU7nGuZQjahw9xSFA==", "license": "MIT", "dependencies": { "classnames": "2.5.0", diff --git a/package.json b/package.json index 571b1638e266..39c6132711cc 100644 --- a/package.json +++ b/package.json @@ -108,7 +108,7 @@ "date-fns-tz": "^2.0.0", "dom-serializer": "^0.2.2", "domhandler": "^4.3.0", - "expensify-common": "git+ssh://git@github.com:software-mansion-labs/expensify-common.git#7596ae07c9cd5a6b5265897034898b4526d681dc", + "expensify-common": "git+ssh://git@github.com/Expensify/expensify-common.git#9a68635cdcef4c81593c0f816a007bc9c707d46a", "expo": "^50.0.3", "expo-av": "~13.10.4", "expo-image": "1.11.0", From 46a1f6e72cd3b3b069cdb1fcd72e845c63ee3716 Mon Sep 17 00:00:00 2001 From: war-in Date: Mon, 29 Apr 2024 14:04:57 +0200 Subject: [PATCH 006/137] fix failing typecheck --- 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 cb9f449c14f9..ad683903fd5c 100644 --- a/src/libs/ReportUtils.ts +++ b/src/libs/ReportUtils.ts @@ -3324,7 +3324,7 @@ function buildOptimisticAddCommentReportAction(text?: string, file?: FileObject, textForNewComment = parseHtmlToText(htmlForNewComment); } else { htmlForNewComment = `${commentText}\n${CONST.ATTACHMENT_UPLOADING_MESSAGE_HTML}`; - textForNewComment = `${parser.htmlToText(commentText)}\n${CONST.ATTACHMENT_UPLOADING_MESSAGE_HTML}`; + textForNewComment = `${parseHtmlToText(commentText)}\n${CONST.ATTACHMENT_UPLOADING_MESSAGE_HTML}`; } const isAttachment = !text && file !== undefined; From 65ae4fc83b29659687fbe6dc35cbcac4146289d0 Mon Sep 17 00:00:00 2001 From: Bernhard Owen Josephus Date: Wed, 8 May 2024 18:46:01 +0800 Subject: [PATCH 007/137] set the initial value of the status bar --- web/index.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/web/index.html b/web/index.html index 115803573bbd..013d87ec64a4 100644 --- a/web/index.html +++ b/web/index.html @@ -4,7 +4,7 @@ New Expensify - + From 4400aca0b2948f8a2945e16335975152851df5b6 Mon Sep 17 00:00:00 2001 From: Abdelrahman Khattab Date: Fri, 10 May 2024 12:13:24 +0200 Subject: [PATCH 008/137] Removing compose.ts --- src/components/LocaleContextProvider.tsx | 12 +++---- src/components/MapView/MapView.tsx | 8 ++--- src/components/TestToolMenu.tsx | 8 ++--- .../withReportAndReportActionOrNotFound.tsx | 8 ++--- .../WorkspaceRateAndUnitPage/InitialPage.tsx | 31 +++++++++---------- .../WorkspaceRateAndUnitPage/RatePage.tsx | 12 +++---- .../WorkspaceRateAndUnitPage/UnitPage.tsx | 13 +++----- .../withPolicyAndFullscreenLoading.tsx | 8 ++--- 8 files changed, 42 insertions(+), 58 deletions(-) diff --git a/src/components/LocaleContextProvider.tsx b/src/components/LocaleContextProvider.tsx index eb7d9324d2ab..e0e30d14d2a2 100644 --- a/src/components/LocaleContextProvider.tsx +++ b/src/components/LocaleContextProvider.tsx @@ -2,7 +2,6 @@ import React, {createContext, useMemo} from 'react'; import type {OnyxEntry} from 'react-native-onyx'; import {withOnyx} from 'react-native-onyx'; import type {ValueOf} from 'type-fest'; -import compose from '@libs/compose'; import DateUtils from '@libs/DateUtils'; import * as LocaleDigitUtils from '@libs/LocaleDigitUtils'; import * as LocalePhoneNumber from '@libs/LocalePhoneNumber'; @@ -125,18 +124,17 @@ function LocaleContextProvider({preferredLocale, currentUserPersonalDetails = {} return {children}; } -const Provider = compose( +const Provider = withCurrentUserPersonalDetails( withOnyx({ preferredLocale: { key: ONYXKEYS.NVP_PREFERRED_LOCALE, selector: (preferredLocale) => preferredLocale, }, - }), - withCurrentUserPersonalDetails, -)(LocaleContextProvider); + })(LocaleContextProvider), +); Provider.displayName = 'withOnyx(LocaleContextProvider)'; -export {Provider as LocaleContextProvider, LocaleContext}; +export {LocaleContext, Provider as LocaleContextProvider}; -export type {LocaleContextProps, Locale}; +export type {Locale, LocaleContextProps}; diff --git a/src/components/MapView/MapView.tsx b/src/components/MapView/MapView.tsx index b1021350435c..05a7cd221c1e 100644 --- a/src/components/MapView/MapView.tsx +++ b/src/components/MapView/MapView.tsx @@ -6,7 +6,6 @@ import {View} from 'react-native'; import {withOnyx} from 'react-native-onyx'; import useThemeStyles from '@hooks/useThemeStyles'; import setUserLocation from '@libs/actions/UserLocation'; -import compose from '@libs/compose'; import getCurrentPosition from '@libs/getCurrentPosition'; import CONST from '@src/CONST'; import useLocalize from '@src/hooks/useLocalize'; @@ -196,11 +195,10 @@ const MapView = forwardRef( }, ); -export default compose( +export default memo( withOnyx({ userLocation: { key: ONYXKEYS.USER_LOCATION, }, - }), - memo, -)(MapView); + })(MapView), +); diff --git a/src/components/TestToolMenu.tsx b/src/components/TestToolMenu.tsx index e4d33957f7f1..85a2a975fc76 100644 --- a/src/components/TestToolMenu.tsx +++ b/src/components/TestToolMenu.tsx @@ -4,7 +4,6 @@ import {withOnyx} from 'react-native-onyx'; import useLocalize from '@hooks/useLocalize'; import useThemeStyles from '@hooks/useThemeStyles'; import * as ApiUtils from '@libs/ApiUtils'; -import compose from '@libs/compose'; import Navigation from '@libs/Navigation/Navigation'; import * as Network from '@userActions/Network'; import * as Session from '@userActions/Session'; @@ -109,11 +108,10 @@ function TestToolMenu({user = USER_DEFAULT, network}: TestToolMenuProps) { TestToolMenu.displayName = 'TestToolMenu'; -export default compose( +export default withNetwork()( withOnyx({ user: { key: ONYXKEYS.USER, }, - }), - withNetwork(), -)(TestToolMenu); + })(TestToolMenu), +); diff --git a/src/pages/home/report/withReportAndReportActionOrNotFound.tsx b/src/pages/home/report/withReportAndReportActionOrNotFound.tsx index e5e203fb5030..123f7b12cb22 100644 --- a/src/pages/home/report/withReportAndReportActionOrNotFound.tsx +++ b/src/pages/home/report/withReportAndReportActionOrNotFound.tsx @@ -7,7 +7,6 @@ import {withOnyx} from 'react-native-onyx'; import FullscreenLoadingIndicator from '@components/FullscreenLoadingIndicator'; import withWindowDimensions from '@components/withWindowDimensions'; import type {WindowDimensionsProps} from '@components/withWindowDimensions/types'; -import compose from '@libs/compose'; import getComponentDisplayName from '@libs/getComponentDisplayName'; import type {FlagCommentNavigatorParamList, SplitDetailsNavigatorParamList} from '@libs/Navigation/types'; import * as ReportUtils from '@libs/ReportUtils'; @@ -103,7 +102,7 @@ export default function , OnyxProps>({ report: { key: ({route}) => `${ONYXKEYS.COLLECTION.REPORT}${route.params.reportID}`, @@ -138,9 +137,8 @@ export default function ({ - // @ts-expect-error: ONYXKEYS.REIMBURSEMENT_ACCOUNT is conflicting with ONYXKEYS.FORMS.REIMBURSEMENT_ACCOUNT_FORM - reimbursementAccount: { - key: ONYXKEYS.REIMBURSEMENT_ACCOUNT, - }, - workspaceRateAndUnit: { - key: ONYXKEYS.WORKSPACE_RATE_AND_UNIT, - }, - }), - withPolicy, - withNetwork(), -)(WorkspaceRateAndUnitPage); +export default withNetwork()( + withPolicy( + withOnyx({ + // @ts-expect-error: ONYXKEYS.REIMBURSEMENT_ACCOUNT is conflicting with ONYXKEYS.FORMS.REIMBURSEMENT_ACCOUNT_FORM + reimbursementAccount: { + key: ONYXKEYS.REIMBURSEMENT_ACCOUNT, + }, + workspaceRateAndUnit: { + key: ONYXKEYS.WORKSPACE_RATE_AND_UNIT, + }, + })(WorkspaceRateAndUnitPage), + ), +); diff --git a/src/pages/workspace/reimburse/WorkspaceRateAndUnitPage/RatePage.tsx b/src/pages/workspace/reimburse/WorkspaceRateAndUnitPage/RatePage.tsx index 8685cd3b1aee..e265e261b6b8 100644 --- a/src/pages/workspace/reimburse/WorkspaceRateAndUnitPage/RatePage.tsx +++ b/src/pages/workspace/reimburse/WorkspaceRateAndUnitPage/RatePage.tsx @@ -1,17 +1,16 @@ import React, {useCallback, useEffect, useMemo} from 'react'; -import {withOnyx} from 'react-native-onyx'; import type {OnyxEntry} from 'react-native-onyx'; +import {withOnyx} from 'react-native-onyx'; import AmountForm from '@components/AmountForm'; import FormProvider from '@components/Form/FormProvider'; import InputWrapperWithRef from '@components/Form/InputWrapper'; import type {FormOnyxValues} from '@components/Form/types'; import useLocalize from '@hooks/useLocalize'; import useThemeStyles from '@hooks/useThemeStyles'; -import compose from '@libs/compose'; import Navigation from '@libs/Navigation/Navigation'; import {validateRateValue} from '@libs/PolicyDistanceRatesUtils'; -import withPolicy from '@pages/workspace/withPolicy'; import type {WithPolicyProps} from '@pages/workspace/withPolicy'; +import withPolicy from '@pages/workspace/withPolicy'; import WorkspacePageWithSections from '@pages/workspace/WorkspacePageWithSections'; import * as Policy from '@userActions/Policy'; import CONST from '@src/CONST'; @@ -99,11 +98,10 @@ function WorkspaceRatePage(props: WorkspaceRatePageProps) { WorkspaceRatePage.displayName = 'WorkspaceRatePage'; -export default compose( +export default withPolicy( withOnyx({ workspaceRateAndUnit: { key: ONYXKEYS.WORKSPACE_RATE_AND_UNIT, }, - }), - withPolicy, -)(WorkspaceRatePage); + })(WorkspaceRatePage), +); diff --git a/src/pages/workspace/reimburse/WorkspaceRateAndUnitPage/UnitPage.tsx b/src/pages/workspace/reimburse/WorkspaceRateAndUnitPage/UnitPage.tsx index 1d30c068e30d..6337fa2c461e 100644 --- a/src/pages/workspace/reimburse/WorkspaceRateAndUnitPage/UnitPage.tsx +++ b/src/pages/workspace/reimburse/WorkspaceRateAndUnitPage/UnitPage.tsx @@ -1,15 +1,14 @@ import React, {useEffect, useMemo} from 'react'; -import {withOnyx} from 'react-native-onyx'; import type {OnyxEntry} from 'react-native-onyx'; +import {withOnyx} from 'react-native-onyx'; import Text from '@components/Text'; import type {UnitItemType} from '@components/UnitPicker'; import UnitPicker from '@components/UnitPicker'; import useLocalize from '@hooks/useLocalize'; import useThemeStyles from '@hooks/useThemeStyles'; -import compose from '@libs/compose'; import Navigation from '@libs/Navigation/Navigation'; -import withPolicy from '@pages/workspace/withPolicy'; import type {WithPolicyProps} from '@pages/workspace/withPolicy'; +import withPolicy from '@pages/workspace/withPolicy'; import WorkspacePageWithSections from '@pages/workspace/WorkspacePageWithSections'; import * as Policy from '@userActions/Policy'; import CONST from '@src/CONST'; @@ -70,12 +69,10 @@ function WorkspaceUnitPage(props: WorkspaceUnitPageProps) { } WorkspaceUnitPage.displayName = 'WorkspaceUnitPage'; - -export default compose( +export default withPolicy( withOnyx({ workspaceRateAndUnit: { key: ONYXKEYS.WORKSPACE_RATE_AND_UNIT, }, - }), - withPolicy, -)(WorkspaceUnitPage); + })(WorkspaceUnitPage), +); diff --git a/src/pages/workspace/withPolicyAndFullscreenLoading.tsx b/src/pages/workspace/withPolicyAndFullscreenLoading.tsx index 161320441843..2467136a382b 100644 --- a/src/pages/workspace/withPolicyAndFullscreenLoading.tsx +++ b/src/pages/workspace/withPolicyAndFullscreenLoading.tsx @@ -4,7 +4,6 @@ import React, {forwardRef} from 'react'; import type {OnyxEntry} from 'react-native-onyx'; import {withOnyx} from 'react-native-onyx'; import FullscreenLoadingIndicator from '@components/FullscreenLoadingIndicator'; -import compose from '@libs/compose'; import ONYXKEYS from '@src/ONYXKEYS'; import type {PersonalDetailsList} from '@src/types/onyx'; import type {WithPolicyOnyxProps, WithPolicyProps} from './withPolicy'; @@ -49,7 +48,7 @@ export default function withPolicyAndFullscreenLoading, WithPolicyAndFullscreenLoadingOnyxProps>({ isLoadingReportData: { key: ONYXKEYS.IS_LOADING_REPORT_DATA, @@ -57,9 +56,8 @@ export default function withPolicyAndFullscreenLoading Date: Mon, 13 May 2024 15:33:53 +0200 Subject: [PATCH 009/137] remove leftovers --- src/pages/tasks/TaskDescriptionPage.tsx | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/src/pages/tasks/TaskDescriptionPage.tsx b/src/pages/tasks/TaskDescriptionPage.tsx index 4a9a7f870230..7b3dd8813540 100644 --- a/src/pages/tasks/TaskDescriptionPage.tsx +++ b/src/pages/tasks/TaskDescriptionPage.tsx @@ -1,5 +1,4 @@ import {useFocusEffect} from '@react-navigation/native'; -import ExpensiMark from 'expensify-common/lib/ExpensiMark'; import React, {useCallback, useRef} from 'react'; import {View} from 'react-native'; import FullPageNotFoundView from '@components/BlockingViews/FullPageNotFoundView'; @@ -30,8 +29,6 @@ import {isEmptyObject} from '@src/types/utils/EmptyObject'; type TaskDescriptionPageProps = WithReportOrNotFoundProps & WithCurrentUserPersonalDetailsProps; -const parser = new ExpensiMark(); - function TaskDescriptionPage({report, currentUserPersonalDetails}: TaskDescriptionPageProps) { const styles = useThemeStyles(); const {translate} = useLocalize(); @@ -48,7 +45,7 @@ function TaskDescriptionPage({report, currentUserPersonalDetails}: TaskDescripti const submit = useCallback( (values: FormOnyxValues) => { - if (values.description !== parseHtmlToMarkdown(parser.replace(report?.description ?? '')) && !isEmptyObject(report)) { + if (values.description !== parseHtmlToMarkdown(report?.description ?? '') && !isEmptyObject(report)) { // Set the description of the report in the store and then call EditTask API // to update the description of the report on the server Task.editTask(report, {description: values.description}); From 7556c6027f6529a49f688b40f98d0a24968f2ff0 Mon Sep 17 00:00:00 2001 From: Abdelrahman Khattab Date: Mon, 13 May 2024 16:09:38 +0200 Subject: [PATCH 010/137] removing compose.ts --- src/libs/compose.ts | 71 --------------------------------------------- 1 file changed, 71 deletions(-) delete mode 100644 src/libs/compose.ts diff --git a/src/libs/compose.ts b/src/libs/compose.ts deleted file mode 100644 index dadc586d0f0d..000000000000 --- a/src/libs/compose.ts +++ /dev/null @@ -1,71 +0,0 @@ -/* eslint-disable @typescript-eslint/ban-types */ -/* eslint-disable import/export */ - -/** - * This is a utility function taken directly from Redux. (We don't want to add Redux as a dependency) - * It enables functional composition, useful for the chaining/composition of HOCs. - * - * For example, instead of: - * - * export default hoc1(config1, hoc2(config2, hoc3(config3)))(Component); - * - * Use this instead: - * - * export default compose( - * hoc1(config1), - * hoc2(config2), - * hoc3(config3), - * )(Component) - */ -export default function compose(): (a: R) => R; - -export default function compose(f: F): F; - -/* two functions */ -export default function compose(f1: (...args: A) => R1, f2: (a: R1) => R2): (...args: A) => R2; - -/* three functions */ -export default function compose(f1: (...args: A) => R1, f2: (a: R1) => R2, f3: (a: R2) => R3): (...args: A) => R3; - -/* four functions */ -export default function compose(f1: (...args: A) => R1, f2: (a: R1) => R2, f3: (a: R2) => R3, f4: (a: R3) => R4): (...args: A) => R4; - -/* five functions */ -export default function compose( - f1: (...args: A) => R1, - f2: (a: R1) => R2, - f3: (a: R2) => R3, - f4: (a: R3) => R4, - f5: (a: R4) => R5, -): (...args: A) => R5; - -/* six functions */ -export default function compose( - f1: (...args: A) => R1, - f2: (a: R1) => R2, - f3: (a: R2) => R3, - f4: (a: R3) => R4, - f5: (a: R4) => R5, - f6: (a: R5) => R6, -): (...args: A) => R6; - -/* rest */ -export default function compose(f1: (a: unknown) => R, ...funcs: Function[]): (...args: unknown[]) => R; - -export default function compose(...funcs: Function[]): Function { - if (funcs.length === 0) { - // infer the argument type so it is usable in inference down the line - return (arg: T) => arg; - } - - if (funcs.length === 1) { - return funcs[0]; - } - - return funcs.reduce( - (a, b) => - (...args: unknown[]) => - // eslint-disable-next-line @typescript-eslint/no-unsafe-return - a(b(...args)), - ); -} From dafa5a4f22b9412b3f6ce64a69e796a427c3563d Mon Sep 17 00:00:00 2001 From: war-in Date: Tue, 14 May 2024 18:11:30 +0200 Subject: [PATCH 011/137] replace htmlToText in `OptionRowLHN` --- src/components/LHNOptionsList/OptionRowLHN.tsx | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/components/LHNOptionsList/OptionRowLHN.tsx b/src/components/LHNOptionsList/OptionRowLHN.tsx index b665c305f5cf..fe234eb629a4 100644 --- a/src/components/LHNOptionsList/OptionRowLHN.tsx +++ b/src/components/LHNOptionsList/OptionRowLHN.tsx @@ -1,5 +1,4 @@ import {useFocusEffect} from '@react-navigation/native'; -import ExpensiMark from 'expensify-common/lib/ExpensiMark'; import React, {useCallback, useRef, useState} from 'react'; import type {GestureResponderEvent, ViewStyle} from 'react-native'; import {StyleSheet, View} from 'react-native'; @@ -20,6 +19,7 @@ import useThemeStyles from '@hooks/useThemeStyles'; import useWindowDimensions from '@hooks/useWindowDimensions'; import DateUtils from '@libs/DateUtils'; import DomUtils from '@libs/DomUtils'; +import {parseHtmlToText} from '@libs/OnyxAwareParser'; import * as OptionsListUtils from '@libs/OptionsListUtils'; import Performance from '@libs/Performance'; import ReportActionComposeFocusManager from '@libs/ReportActionComposeFocusManager'; @@ -29,8 +29,6 @@ import CONST from '@src/CONST'; import {isEmptyObject} from '@src/types/utils/EmptyObject'; import type {OptionRowLHNProps} from './types'; -const parser = new ExpensiMark(); - function OptionRowLHN({reportID, isFocused = false, onSelectRow = () => {}, optionItem, viewMode = 'default', style, onLayout = () => {}, hasDraftComment}: OptionRowLHNProps) { const theme = useTheme(); const styles = useThemeStyles(); @@ -228,7 +226,7 @@ function OptionRowLHN({reportID, isFocused = false, onSelectRow = () => {}, opti numberOfLines={1} accessibilityLabel={translate('accessibilityHints.lastChatMessagePreview')} > - {parser.htmlToText(optionItem.alternateText)} + {parseHtmlToText(optionItem.alternateText)} ) : null} From 3a2f068f2f0d6ead4a085f695e083265f03c36a9 Mon Sep 17 00:00:00 2001 From: gijoe0295 Date: Fri, 24 May 2024 01:47:53 +0700 Subject: [PATCH 012/137] ordered mention suggestions --- .../ReportActionCompose/SuggestionMention.tsx | 54 ++++++++++++++++--- 1 file changed, 47 insertions(+), 7 deletions(-) diff --git a/src/pages/home/report/ReportActionCompose/SuggestionMention.tsx b/src/pages/home/report/ReportActionCompose/SuggestionMention.tsx index 05e1163da200..cef1c0990c59 100644 --- a/src/pages/home/report/ReportActionCompose/SuggestionMention.tsx +++ b/src/pages/home/report/ReportActionCompose/SuggestionMention.tsx @@ -1,7 +1,8 @@ import Str from 'expensify-common/lib/str'; +import lodashMapValues from 'lodash/mapValues'; import lodashSortBy from 'lodash/sortBy'; import type {ForwardedRef} from 'react'; -import React, {forwardRef, useCallback, useEffect, useImperativeHandle, useRef, useState} from 'react'; +import React, {forwardRef, useCallback, useEffect, useImperativeHandle, useMemo, useRef, useState} from 'react'; import {useOnyx} from 'react-native-onyx'; import type {OnyxCollection} from 'react-native-onyx'; import * as Expensicons from '@components/Icon/Expensicons'; @@ -9,11 +10,13 @@ import type {Mention} from '@components/MentionSuggestions'; import MentionSuggestions from '@components/MentionSuggestions'; import {usePersonalDetails} from '@components/OnyxProvider'; import useArrowKeyFocusManager from '@hooks/useArrowKeyFocusManager'; +import useCurrentReportID from '@hooks/useCurrentReportID'; import useCurrentUserPersonalDetails from '@hooks/useCurrentUserPersonalDetails'; import useDebounce from '@hooks/useDebounce'; import useLocalize from '@hooks/useLocalize'; import * as LoginUtils from '@libs/LoginUtils'; import * as PersonalDetailsUtils from '@libs/PersonalDetailsUtils'; +import getPolicyEmployeeAccountIDs from '@libs/PolicyEmployeeListUtils'; import * as ReportUtils from '@libs/ReportUtils'; import * as SuggestionsUtils from '@libs/SuggestionUtils'; import * as UserUtils from '@libs/UserUtils'; @@ -21,7 +24,7 @@ import {isValidRoomName} from '@libs/ValidationUtils'; import * as ReportUserActions from '@userActions/Report'; import CONST from '@src/CONST'; import ONYXKEYS from '@src/ONYXKEYS'; -import type {PersonalDetailsList, Report} from '@src/types/onyx'; +import type {PersonalDetails, PersonalDetailsList, Report} from '@src/types/onyx'; import type {SuggestionsRef} from './ReportActionCompose'; import type {SuggestionProps} from './Suggestions'; @@ -46,6 +49,14 @@ const defaultSuggestionsValues: SuggestionValues = { prefixType: '', }; +type SuggestionPersonalDetailsList = Record< + string, + | (PersonalDetails & { + weight: number; + }) + | null +>; + function SuggestionMention( {value, selection, setSelection, updateComment, isAutoSuggestionPickerLarge, measureParentContainer, isComposerFocused, isGroupPolicyReport, policyID}: SuggestionProps, ref: ForwardedRef, @@ -59,6 +70,36 @@ function SuggestionMention( const currentUserPersonalDetails = useCurrentUserPersonalDetails(); const isMentionSuggestionsMenuVisible = !!suggestionValues.suggestedMentions.length && suggestionValues.shouldShowSuggestionMenu; + const currentReportID = useCurrentReportID(); + const currentReport = reports?.[`${ONYXKEYS.COLLECTION.REPORT}${currentReportID?.currentReportID}`] ?? null; + // Smaller weight means higher order in suggestion list + const getPersonalDetailsWeight = useCallback( + (detail: PersonalDetails, policyEmployeeAccountIDs: number[]): number => { + if (ReportUtils.isReportParticipant(detail.accountID, currentReport)) { + return 0; + } + if (policyEmployeeAccountIDs.includes(detail.accountID)) { + return 1; + } + return 2; + }, + [currentReport], + ); + const weightedPersonalDetails: PersonalDetailsList | SuggestionPersonalDetailsList = useMemo(() => { + const policyEmployeeAccountIDs = getPolicyEmployeeAccountIDs(policyID); + if (!ReportUtils.isGroupChat(currentReport) && !ReportUtils.doesReportBelongToWorkspace(currentReport, policyEmployeeAccountIDs, policyID)) { + return personalDetails; + } + return lodashMapValues(personalDetails, (detail) => + detail + ? { + ...detail, + weight: getPersonalDetailsWeight(detail, policyEmployeeAccountIDs), + } + : null, + ); + }, [policyID, currentReport, personalDetails, getPersonalDetailsWeight]); + const [highlightedMentionIndex, setHighlightedMentionIndex] = useArrowKeyFocusManager({ isActive: isMentionSuggestionsMenuVisible, maxIndex: suggestionValues.suggestedMentions.length - 1, @@ -191,7 +232,7 @@ function SuggestionMention( ); const getUserMentionOptions = useCallback( - (personalDetailsParam: PersonalDetailsList, searchValue = ''): Mention[] => { + (personalDetailsParam: PersonalDetailsList | SuggestionPersonalDetailsList, searchValue = ''): Mention[] => { const suggestions = []; if (CONST.AUTO_COMPLETE_SUGGESTER.HERE_TEXT.includes(searchValue.toLowerCase())) { @@ -232,8 +273,7 @@ function SuggestionMention( return true; }); - // eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing -- nullish coalescing cannot be used if left side can be empty string - const sortedPersonalDetails = lodashSortBy(filteredPersonalDetails, (detail) => detail?.displayName || detail?.login); + const sortedPersonalDetails = lodashSortBy(filteredPersonalDetails, ['weight', 'displayName', 'login']); sortedPersonalDetails.slice(0, CONST.AUTO_COMPLETE_SUGGESTER.MAX_AMOUNT_OF_SUGGESTIONS - suggestions.length).forEach((detail) => { suggestions.push({ text: formatLoginPrivateDomain(PersonalDetailsUtils.getDisplayNameOrDefault(detail), detail?.login), @@ -320,7 +360,7 @@ function SuggestionMention( }; if (isMentionCode(suggestionWord) && prefixType === '@') { - const suggestions = getUserMentionOptions(personalDetails, prefix); + const suggestions = getUserMentionOptions(weightedPersonalDetails, prefix); nextState.suggestedMentions = suggestions; nextState.shouldShowSuggestionMenu = !!suggestions.length; } @@ -340,7 +380,7 @@ function SuggestionMention( })); setHighlightedMentionIndex(0); }, - [isComposerFocused, value, isGroupPolicyReport, setHighlightedMentionIndex, resetSuggestions, getUserMentionOptions, personalDetails, getRoomMentionOptions, reports], + [isComposerFocused, value, isGroupPolicyReport, setHighlightedMentionIndex, resetSuggestions, getUserMentionOptions, weightedPersonalDetails, getRoomMentionOptions, reports], ); useEffect(() => { From 6f730812c3d81f109873ef037c9f81a895ac3a6e Mon Sep 17 00:00:00 2001 From: Abdelrahman Khattab Date: Tue, 28 May 2024 16:12:07 +0200 Subject: [PATCH 013/137] Reversing dependencies order --- src/components/MapView/MapView.tsx | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/src/components/MapView/MapView.tsx b/src/components/MapView/MapView.tsx index 05a7cd221c1e..fa885160d881 100644 --- a/src/components/MapView/MapView.tsx +++ b/src/components/MapView/MapView.tsx @@ -195,10 +195,8 @@ const MapView = forwardRef( }, ); -export default memo( - withOnyx({ - userLocation: { - key: ONYXKEYS.USER_LOCATION, - }, - })(MapView), -); +export default withOnyx({ + userLocation: { + key: ONYXKEYS.USER_LOCATION, + }, +})(memo(MapView)); From 3539dbd0dfa689b16296d75466b96f8e5c013545 Mon Sep 17 00:00:00 2001 From: Bernhard Owen Josephus Date: Tue, 28 May 2024 23:23:23 +0800 Subject: [PATCH 014/137] update splashBG color --- src/libs/getSplashBackgroundColor/index.native.ts | 7 ------- src/libs/getSplashBackgroundColor/index.ts | 7 ------- src/styles/theme/themes/dark.ts | 3 +-- src/styles/theme/themes/light.ts | 3 +-- 4 files changed, 2 insertions(+), 18 deletions(-) delete mode 100644 src/libs/getSplashBackgroundColor/index.native.ts delete mode 100644 src/libs/getSplashBackgroundColor/index.ts diff --git a/src/libs/getSplashBackgroundColor/index.native.ts b/src/libs/getSplashBackgroundColor/index.native.ts deleted file mode 100644 index 1d21b7a004e1..000000000000 --- a/src/libs/getSplashBackgroundColor/index.native.ts +++ /dev/null @@ -1,7 +0,0 @@ -import colors from '@styles/theme/colors'; - -function getSplashBackgroundColor() { - return colors.green400; -} - -export default getSplashBackgroundColor; diff --git a/src/libs/getSplashBackgroundColor/index.ts b/src/libs/getSplashBackgroundColor/index.ts deleted file mode 100644 index 97484d49163e..000000000000 --- a/src/libs/getSplashBackgroundColor/index.ts +++ /dev/null @@ -1,7 +0,0 @@ -import colors from '@styles/theme/colors'; - -function getSplashBackgroundColor() { - return colors.productDark100; -} - -export default getSplashBackgroundColor; diff --git a/src/styles/theme/themes/dark.ts b/src/styles/theme/themes/dark.ts index f0493a815747..73d7fa969214 100644 --- a/src/styles/theme/themes/dark.ts +++ b/src/styles/theme/themes/dark.ts @@ -1,4 +1,3 @@ -import getSplashBackgroundColor from '@libs/getSplashBackgroundColor'; import colors from '@styles/theme/colors'; import type {ThemeColors} from '@styles/theme/types'; import CONST from '@src/CONST'; @@ -7,7 +6,7 @@ import SCREENS from '@src/SCREENS'; const darkTheme = { // Figma keys appBG: colors.productDark100, - splashBG: getSplashBackgroundColor(), + splashBG: colors.green400, highlightBG: colors.productDark200, border: colors.productDark400, borderLighter: colors.productDark400, diff --git a/src/styles/theme/themes/light.ts b/src/styles/theme/themes/light.ts index cf490a90a7f7..16339c70bafe 100644 --- a/src/styles/theme/themes/light.ts +++ b/src/styles/theme/themes/light.ts @@ -1,4 +1,3 @@ -import getSplashBackgroundColor from '@libs/getSplashBackgroundColor'; import colors from '@styles/theme/colors'; import type {ThemeColors} from '@styles/theme/types'; import CONST from '@src/CONST'; @@ -7,7 +6,7 @@ import SCREENS from '@src/SCREENS'; const lightTheme = { // Figma keys appBG: colors.productLight100, - splashBG: getSplashBackgroundColor(), + splashBG: colors.green400, highlightBG: colors.productLight200, border: colors.productLight400, borderLighter: colors.productLight400, From 21f55c7be031f3b2024482e5a2f895cda2a08dd7 Mon Sep 17 00:00:00 2001 From: Bernhard Owen Josephus Date: Tue, 28 May 2024 23:23:36 +0800 Subject: [PATCH 015/137] don't update status bar color on mount --- src/components/CustomStatusBarAndBackground/index.tsx | 5 ----- 1 file changed, 5 deletions(-) diff --git a/src/components/CustomStatusBarAndBackground/index.tsx b/src/components/CustomStatusBarAndBackground/index.tsx index 524c8a3903e0..356fbd3726a3 100644 --- a/src/components/CustomStatusBarAndBackground/index.tsx +++ b/src/components/CustomStatusBarAndBackground/index.tsx @@ -114,11 +114,6 @@ function CustomStatusBarAndBackground({isNested = false}: CustomStatusBarAndBack [prevIsRootStatusBarEnabled, isRootStatusBarEnabled, statusBarAnimation, statusBarStyle, theme.PAGE_THEMES, theme.appBG, theme.statusBarStyle], ); - useEffect(() => { - updateStatusBarAppearance({backgroundColor: theme.appBG}); - // eslint-disable-next-line react-hooks/exhaustive-deps -- we only want this to run on first render - }, []); - useEffect(() => { didForceUpdateStatusBarRef.current = false; }, [isRootStatusBarEnabled]); From ef67dad60c342a14c2c4eee89ddb8b02195bb83c Mon Sep 17 00:00:00 2001 From: ShridharGoel <35566748+ShridharGoel@users.noreply.github.com> Date: Thu, 30 May 2024 02:12:46 +0530 Subject: [PATCH 016/137] Align inline icons with text in Android LHN --- .../LHNOptionsList/LHNOptionsList.tsx | 60 ++++++++++++------- src/styles/index.ts | 8 +++ 2 files changed, 46 insertions(+), 22 deletions(-) diff --git a/src/components/LHNOptionsList/LHNOptionsList.tsx b/src/components/LHNOptionsList/LHNOptionsList.tsx index 6405e3026b1a..d04b40002302 100644 --- a/src/components/LHNOptionsList/LHNOptionsList.tsx +++ b/src/components/LHNOptionsList/LHNOptionsList.tsx @@ -69,36 +69,52 @@ function LHNOptionsList({ const emptyLHNSubtitle = useMemo( () => ( - + {translate('common.emptyLHN.subtitleText1')} - + + + {translate('common.emptyLHN.subtitleText2')} - + + + {translate('common.emptyLHN.subtitleText3')} ), - [theme, styles.alignItemsCenter, styles.textAlignCenter, translate], + [styles.emptyLHNDetailsContainer, styles.mh1, styles.textAlignCenter, theme.icon, theme.placeholderText, translate], ); /** diff --git a/src/styles/index.ts b/src/styles/index.ts index 5627adb01834..0d1bac489fa0 100644 --- a/src/styles/index.ts +++ b/src/styles/index.ts @@ -4939,6 +4939,14 @@ const styles = (theme: ThemeColors) => reportListItemActionButtonMargin: { marginLeft: variables.searchTypeColumnWidth, }, + + emptyLHNDetailsContainer: { + flexDirection: 'row', + alignItems: 'center', + justifyContent: 'center', + flexWrap: 'wrap', + textAlign: 'center', + }, } satisfies Styles); type ThemeStyles = ReturnType; From f4659e14d9db2ff2af079655346c220bbe471d51 Mon Sep 17 00:00:00 2001 From: tienifr Date: Thu, 30 May 2024 04:16:23 +0700 Subject: [PATCH 017/137] fix LHN - Thread chat with violation is not removed from LHN --- src/libs/ReportUtils.ts | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/libs/ReportUtils.ts b/src/libs/ReportUtils.ts index a6fe52f4c7b2..6c9259ec6939 100644 --- a/src/libs/ReportUtils.ts +++ b/src/libs/ReportUtils.ts @@ -5265,7 +5265,10 @@ function shouldReportBeInOptionList({ if (isSelfDM(report)) { return includeSelfDM; } - + const parentReportAction = ReportActionsUtils.getParentReportAction(report); + if (parentReportAction && ReportActionsUtils.isPendingRemove(parentReportAction) && ReportActionsUtils.isThreadParentMessage(parentReportAction, report?.reportID ?? '')) { + return false; + } return true; } From 715d9f37752dcc3e5a37835f7737f5d3ed2ea15a Mon Sep 17 00:00:00 2001 From: tienifr Date: Thu, 30 May 2024 04:26:01 +0700 Subject: [PATCH 018/137] fix lint --- src/libs/ReportUtils.ts | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/libs/ReportUtils.ts b/src/libs/ReportUtils.ts index 6c9259ec6939..96a50d1ead89 100644 --- a/src/libs/ReportUtils.ts +++ b/src/libs/ReportUtils.ts @@ -5266,7 +5266,12 @@ function shouldReportBeInOptionList({ return includeSelfDM; } const parentReportAction = ReportActionsUtils.getParentReportAction(report); - if (parentReportAction && ReportActionsUtils.isPendingRemove(parentReportAction) && ReportActionsUtils.isThreadParentMessage(parentReportAction, report?.reportID ?? '')) { + if ( + parentReportAction && + !isEmptyObject(parentReportAction) && + ReportActionsUtils.isPendingRemove(parentReportAction) && + ReportActionsUtils.isThreadParentMessage(parentReportAction, report?.reportID ?? '') + ) { return false; } return true; From 81f47de231fcd02b1dd3dc02809db7440ca9d0d8 Mon Sep 17 00:00:00 2001 From: ShridharGoel <35566748+ShridharGoel@users.noreply.github.com> Date: Thu, 30 May 2024 20:32:12 +0530 Subject: [PATCH 019/137] Update --- src/styles/index.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/styles/index.ts b/src/styles/index.ts index 0d1bac489fa0..900954b744c4 100644 --- a/src/styles/index.ts +++ b/src/styles/index.ts @@ -4941,10 +4941,10 @@ const styles = (theme: ThemeColors) => }, emptyLHNDetailsContainer: { - flexDirection: 'row', - alignItems: 'center', - justifyContent: 'center', - flexWrap: 'wrap', + ...flex.flexRow, + ...flex.alignItemsCenter, + ...flex.justifyContentCenter, + ...flex.flexWrap, textAlign: 'center', }, } satisfies Styles); From b37cc7042c25ff2e9bbbee550875b5f7c763e5d9 Mon Sep 17 00:00:00 2001 From: ShridharGoel <35566748+ShridharGoel@users.noreply.github.com> Date: Fri, 31 May 2024 12:47:50 +0530 Subject: [PATCH 020/137] Update --- .../LHNOptionsList/LHNOptionsList.tsx | 20 +++++++------------ src/styles/index.ts | 8 -------- 2 files changed, 7 insertions(+), 21 deletions(-) diff --git a/src/components/LHNOptionsList/LHNOptionsList.tsx b/src/components/LHNOptionsList/LHNOptionsList.tsx index d04b40002302..5dd606897c40 100644 --- a/src/components/LHNOptionsList/LHNOptionsList.tsx +++ b/src/components/LHNOptionsList/LHNOptionsList.tsx @@ -69,12 +69,10 @@ function LHNOptionsList({ const emptyLHNSubtitle = useMemo( () => ( - + {translate('common.emptyLHN.subtitleText1')} @@ -88,10 +86,8 @@ function LHNOptionsList({ additionalStyles={styles.mh1} /> {translate('common.emptyLHN.subtitleText2')} @@ -105,10 +101,8 @@ function LHNOptionsList({ additionalStyles={styles.mh1} /> {translate('common.emptyLHN.subtitleText3')} diff --git a/src/styles/index.ts b/src/styles/index.ts index 900954b744c4..5627adb01834 100644 --- a/src/styles/index.ts +++ b/src/styles/index.ts @@ -4939,14 +4939,6 @@ const styles = (theme: ThemeColors) => reportListItemActionButtonMargin: { marginLeft: variables.searchTypeColumnWidth, }, - - emptyLHNDetailsContainer: { - ...flex.flexRow, - ...flex.alignItemsCenter, - ...flex.justifyContentCenter, - ...flex.flexWrap, - textAlign: 'center', - }, } satisfies Styles); type ThemeStyles = ReturnType; From 49006c9d06266db51d1586ae58a3cbff2c44650b Mon Sep 17 00:00:00 2001 From: ShridharGoel <35566748+ShridharGoel@users.noreply.github.com> Date: Fri, 31 May 2024 16:18:41 +0530 Subject: [PATCH 021/137] Update --- src/components/LHNOptionsList/LHNOptionsList.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/LHNOptionsList/LHNOptionsList.tsx b/src/components/LHNOptionsList/LHNOptionsList.tsx index 5dd606897c40..3f3c97fec09d 100644 --- a/src/components/LHNOptionsList/LHNOptionsList.tsx +++ b/src/components/LHNOptionsList/LHNOptionsList.tsx @@ -108,7 +108,7 @@ function LHNOptionsList({ ), - [styles.emptyLHNDetailsContainer, styles.mh1, styles.textAlignCenter, theme.icon, theme.placeholderText, translate], + [styles.alignItemsCenter, styles.flexRow, styles.justifyContentCenter, styles.flexWrap, styles.textAlignCenter, styles.mh1, theme.icon, theme.placeholderText, translate], ); /** From 1bd5fa13e18dbf57f77215bb4d40409fb7d21d1d Mon Sep 17 00:00:00 2001 From: ShridharGoel <35566748+ShridharGoel@users.noreply.github.com> Date: Sat, 1 Jun 2024 13:34:16 +0530 Subject: [PATCH 022/137] Update --- .../LHNOptionsList/LHNOptionsList.tsx | 31 ++++++-------- src/components/TextBlock.tsx | 40 +++++++++++++++++++ 2 files changed, 53 insertions(+), 18 deletions(-) create mode 100644 src/components/TextBlock.tsx diff --git a/src/components/LHNOptionsList/LHNOptionsList.tsx b/src/components/LHNOptionsList/LHNOptionsList.tsx index 3f3c97fec09d..edd037bd7d68 100644 --- a/src/components/LHNOptionsList/LHNOptionsList.tsx +++ b/src/components/LHNOptionsList/LHNOptionsList.tsx @@ -10,7 +10,6 @@ import Icon from '@components/Icon'; import * as Expensicons from '@components/Icon/Expensicons'; import LottieAnimations from '@components/LottieAnimations'; import {ScrollOffsetContext} from '@components/ScrollOffsetContextProvider'; -import Text from '@components/Text'; import useLocalize from '@hooks/useLocalize'; import usePermissions from '@hooks/usePermissions'; import usePrevious from '@hooks/usePrevious'; @@ -24,6 +23,7 @@ import CONST from '@src/CONST'; import ONYXKEYS from '@src/ONYXKEYS'; import OptionRowLHNData from './OptionRowLHNData'; import type {LHNOptionsListOnyxProps, LHNOptionsListProps, RenderItemProps} from './types'; +import TextBlock from "@components/TextBlock"; const keyExtractor = (item: string) => `report_${item}`; @@ -70,42 +70,37 @@ function LHNOptionsList({ const emptyLHNSubtitle = useMemo( () => ( - - {translate('common.emptyLHN.subtitleText1')} - + textStyles={[styles.textAlignCenter, styles.textNormal]} + text={translate('common.emptyLHN.subtitleText1')} + /> - - {translate('common.emptyLHN.subtitleText2')} - + textStyles={[styles.textAlignCenter, styles.textNormal]} + text={translate('common.emptyLHN.subtitleText2')} + /> - - {translate('common.emptyLHN.subtitleText3')} - + textStyles={[styles.textAlignCenter, styles.textNormal]} + text={translate('common.emptyLHN.subtitleText3')} + /> ), [styles.alignItemsCenter, styles.flexRow, styles.justifyContentCenter, styles.flexWrap, styles.textAlignCenter, styles.mh1, theme.icon, theme.placeholderText, translate], diff --git a/src/components/TextBlock.tsx b/src/components/TextBlock.tsx new file mode 100644 index 000000000000..d9cc99e8a738 --- /dev/null +++ b/src/components/TextBlock.tsx @@ -0,0 +1,40 @@ +import React from 'react'; +import type { StyleProp, TextStyle } from 'react-native'; +import { Text } from 'react-native'; +import useTheme from "@hooks/useTheme"; + +type TextWordProps = { + /** The color of the text */ + color?: string; + + /** Styles to apply to each text word */ + textStyles?: StyleProp; + + /** The full text to be split into words */ + text: string; +}; + +function TextWord({ color, textStyles, text }: TextWordProps) { + const theme = useTheme(); + const words = text.split(' '); + + return ( + <> + {words.map((word, index) => ( + + {word} + + ))} + + ); +} + +TextWord.displayName = 'TextWord'; + +export default TextWord; From 33b2b1fe3dfebcf4c53eabb07b71b61da51fc6d9 Mon Sep 17 00:00:00 2001 From: ShridharGoel <35566748+ShridharGoel@users.noreply.github.com> Date: Sat, 1 Jun 2024 13:46:11 +0530 Subject: [PATCH 023/137] Lint --- src/components/LHNOptionsList/LHNOptionsList.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/LHNOptionsList/LHNOptionsList.tsx b/src/components/LHNOptionsList/LHNOptionsList.tsx index edd037bd7d68..80cabb9fb761 100644 --- a/src/components/LHNOptionsList/LHNOptionsList.tsx +++ b/src/components/LHNOptionsList/LHNOptionsList.tsx @@ -21,9 +21,9 @@ import * as ReportActionsUtils from '@libs/ReportActionsUtils'; import variables from '@styles/variables'; import CONST from '@src/CONST'; import ONYXKEYS from '@src/ONYXKEYS'; +import TextBlock from "@components/TextBlock"; import OptionRowLHNData from './OptionRowLHNData'; import type {LHNOptionsListOnyxProps, LHNOptionsListProps, RenderItemProps} from './types'; -import TextBlock from "@components/TextBlock"; const keyExtractor = (item: string) => `report_${item}`; From 7f995841bd44c46289ef61131411931ba506d619 Mon Sep 17 00:00:00 2001 From: ShridharGoel <35566748+ShridharGoel@users.noreply.github.com> Date: Sat, 1 Jun 2024 18:21:45 +0530 Subject: [PATCH 024/137] Update --- .../LHNOptionsList/LHNOptionsList.tsx | 5 +--- src/components/TextBlock.tsx | 30 +++++++++---------- 2 files changed, 16 insertions(+), 19 deletions(-) diff --git a/src/components/LHNOptionsList/LHNOptionsList.tsx b/src/components/LHNOptionsList/LHNOptionsList.tsx index 80cabb9fb761..05b7e150fc53 100644 --- a/src/components/LHNOptionsList/LHNOptionsList.tsx +++ b/src/components/LHNOptionsList/LHNOptionsList.tsx @@ -10,6 +10,7 @@ import Icon from '@components/Icon'; import * as Expensicons from '@components/Icon/Expensicons'; import LottieAnimations from '@components/LottieAnimations'; import {ScrollOffsetContext} from '@components/ScrollOffsetContextProvider'; +import TextBlock from '@components/TextBlock'; import useLocalize from '@hooks/useLocalize'; import usePermissions from '@hooks/usePermissions'; import usePrevious from '@hooks/usePrevious'; @@ -21,7 +22,6 @@ import * as ReportActionsUtils from '@libs/ReportActionsUtils'; import variables from '@styles/variables'; import CONST from '@src/CONST'; import ONYXKEYS from '@src/ONYXKEYS'; -import TextBlock from "@components/TextBlock"; import OptionRowLHNData from './OptionRowLHNData'; import type {LHNOptionsListOnyxProps, LHNOptionsListProps, RenderItemProps} from './types'; @@ -72,7 +72,6 @@ function LHNOptionsList({ diff --git a/src/components/TextBlock.tsx b/src/components/TextBlock.tsx index d9cc99e8a738..0770bd0891cc 100644 --- a/src/components/TextBlock.tsx +++ b/src/components/TextBlock.tsx @@ -1,9 +1,10 @@ -import React from 'react'; -import type { StyleProp, TextStyle } from 'react-native'; -import { Text } from 'react-native'; -import useTheme from "@hooks/useTheme"; +import React, {memo, useMemo} from 'react'; +import type {StyleProp, TextStyle} from 'react-native'; +import useTheme from '@hooks/useTheme'; +import useThemeStyles from '@hooks/useThemeStyles'; +import Text from './Text'; -type TextWordProps = { +type TextBlockProps = { /** The color of the text */ color?: string; @@ -14,19 +15,18 @@ type TextWordProps = { text: string; }; -function TextWord({ color, textStyles, text }: TextWordProps) { +function TextBlock({color, textStyles, text}: TextBlockProps) { const theme = useTheme(); - const words = text.split(' '); + const styles = useThemeStyles(); + + const words = useMemo(() => text.match(/(\S+\s*)/g) ?? [], [text]); return ( <> - {words.map((word, index) => ( + {words.map((word) => ( {word} @@ -35,6 +35,6 @@ function TextWord({ color, textStyles, text }: TextWordProps) { ); } -TextWord.displayName = 'TextWord'; +TextBlock.displayName = 'TextBlock'; -export default TextWord; +export default memo(TextBlock); From 8f14bd5f10e0e2e2290f5f08147cd7dcb80b95b6 Mon Sep 17 00:00:00 2001 From: nkdengineer Date: Mon, 3 Jun 2024 10:18:14 +0700 Subject: [PATCH 025/137] fix: User is shown option to submit expense using group --- 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 bdf10f41cf89..f6a11cc03232 100644 --- a/src/libs/OptionsListUtils.ts +++ b/src/libs/OptionsListUtils.ts @@ -787,7 +787,7 @@ function createOption( result.isIOUReportOwner = ReportUtils.isIOUOwnedByCurrentUser(result); result.iouReportAmount = ReportUtils.getMoneyRequestSpendBreakdown(result).totalDisplaySpend; - if (!hasMultipleParticipants) { + if (!hasMultipleParticipants && !ReportUtils.isGroupChat(report)) { result.login = personalDetail?.login; result.accountID = Number(personalDetail?.accountID); result.phoneNumber = personalDetail?.phoneNumber; From 67f1e9a8eea2341044d1d985771858213dc1e8af Mon Sep 17 00:00:00 2001 From: nkdengineer Date: Mon, 3 Jun 2024 15:34:19 +0700 Subject: [PATCH 026/137] fix: add check chat room --- 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 f6a11cc03232..67aaced6f619 100644 --- a/src/libs/OptionsListUtils.ts +++ b/src/libs/OptionsListUtils.ts @@ -787,7 +787,7 @@ function createOption( result.isIOUReportOwner = ReportUtils.isIOUOwnedByCurrentUser(result); result.iouReportAmount = ReportUtils.getMoneyRequestSpendBreakdown(result).totalDisplaySpend; - if (!hasMultipleParticipants && !ReportUtils.isGroupChat(report)) { + if (!hasMultipleParticipants && !ReportUtils.isGroupChat(report) && !ReportUtils.isChatRoom(report)) { result.login = personalDetail?.login; result.accountID = Number(personalDetail?.accountID); result.phoneNumber = personalDetail?.phoneNumber; From 4beb40b7dba70e1d593c04b99535b89d40b82853 Mon Sep 17 00:00:00 2001 From: nkdengineer Date: Mon, 3 Jun 2024 16:15:50 +0700 Subject: [PATCH 027/137] fix lint --- 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 67aaced6f619..f896c2d817e5 100644 --- a/src/libs/OptionsListUtils.ts +++ b/src/libs/OptionsListUtils.ts @@ -787,7 +787,7 @@ function createOption( result.isIOUReportOwner = ReportUtils.isIOUOwnedByCurrentUser(result); result.iouReportAmount = ReportUtils.getMoneyRequestSpendBreakdown(result).totalDisplaySpend; - if (!hasMultipleParticipants && !ReportUtils.isGroupChat(report) && !ReportUtils.isChatRoom(report)) { + if (!hasMultipleParticipants && !ReportUtils.isGroupChat(report) && !ReportUtils.isChatRoom(report)) { result.login = personalDetail?.login; result.accountID = Number(personalDetail?.accountID); result.phoneNumber = personalDetail?.phoneNumber; From 22c18c3a6ccbbdf3cfd5f7463ed53c0ed3bc5375 Mon Sep 17 00:00:00 2001 From: Jakub Kosmydel <104823336+kosmydel@users.noreply.github.com> Date: Mon, 3 Jun 2024 12:25:15 +0200 Subject: [PATCH 028/137] feat: add loading state to the SettlementButton --- src/components/MoneyReportHeader.tsx | 5 ++++- src/components/ReportActionItem/ReportPreview.tsx | 5 ++++- src/libs/ReportUtils.ts | 3 ++- 3 files changed, 10 insertions(+), 3 deletions(-) diff --git a/src/components/MoneyReportHeader.tsx b/src/components/MoneyReportHeader.tsx index aad801a7c259..4f6e10337469 100644 --- a/src/components/MoneyReportHeader.tsx +++ b/src/components/MoneyReportHeader.tsx @@ -3,6 +3,7 @@ import {View} from 'react-native'; import type {OnyxEntry} from 'react-native-onyx'; import {useOnyx} from 'react-native-onyx'; import useLocalize from '@hooks/useLocalize'; +import useNetwork from '@hooks/useNetwork'; import useTheme from '@hooks/useTheme'; import useThemeStyles from '@hooks/useThemeStyles'; import useWindowDimensions from '@hooks/useWindowDimensions'; @@ -59,6 +60,7 @@ function MoneyReportHeader({policy, report: moneyRequestReport, transactionThrea const styles = useThemeStyles(); const theme = useTheme(); + const {isOffline} = useNetwork(); const [isDeleteRequestModalVisible, setIsDeleteRequestModalVisible] = useState(false); const {translate} = useLocalize(); const {windowWidth} = useWindowDimensions(); @@ -228,7 +230,8 @@ function MoneyReportHeader({policy, report: moneyRequestReport, transactionThrea shouldDisableApproveButton={shouldDisableApproveButton} style={[styles.pv2]} formattedAmount={!ReportUtils.hasOnlyHeldExpenses(moneyRequestReport.reportID) ? displayedAmount : ''} - isDisabled={!canAllowSettlement} + isDisabled={isOffline && !canAllowSettlement} + isLoading={!isOffline && !canAllowSettlement} /> )} diff --git a/src/components/ReportActionItem/ReportPreview.tsx b/src/components/ReportActionItem/ReportPreview.tsx index be3b104018db..52c987ca78ff 100644 --- a/src/components/ReportActionItem/ReportPreview.tsx +++ b/src/components/ReportActionItem/ReportPreview.tsx @@ -13,6 +13,7 @@ import SettlementButton from '@components/SettlementButton'; import {showContextMenuForReport} from '@components/ShowContextMenuContext'; import Text from '@components/Text'; import useLocalize from '@hooks/useLocalize'; +import useNetwork from '@hooks/useNetwork'; import usePermissions from '@hooks/usePermissions'; import useTheme from '@hooks/useTheme'; import useThemeStyles from '@hooks/useThemeStyles'; @@ -106,6 +107,7 @@ function ReportPreview({ const styles = useThemeStyles(); const {translate} = useLocalize(); const {canUseViolations} = usePermissions(); + const {isOffline} = useNetwork(); const {hasMissingSmartscanFields, areAllRequestsBeingSmartScanned, hasOnlyTransactionsWithPendingRoutes, hasNonReimbursableTransactions} = useMemo( () => ({ @@ -382,7 +384,8 @@ function ReportPreview({ horizontal: CONST.MODAL.ANCHOR_ORIGIN_HORIZONTAL.RIGHT, vertical: CONST.MODAL.ANCHOR_ORIGIN_VERTICAL.BOTTOM, }} - isDisabled={!canAllowSettlement} + isDisabled={isOffline && !canAllowSettlement} + isLoading={!isOffline && !canAllowSettlement} /> )} {shouldShowSubmitButton && ( diff --git a/src/libs/ReportUtils.ts b/src/libs/ReportUtils.ts index 690cfdafd92d..07a5ef9941f7 100644 --- a/src/libs/ReportUtils.ts +++ b/src/libs/ReportUtils.ts @@ -6343,8 +6343,9 @@ function hasUpdatedTotal(report: OnyxEntry, policy: OnyxEntry): const hasPendingTransaction = transactions.some((transaction) => !!transaction.pendingAction); const hasTransactionWithDifferentCurrency = transactions.some((transaction) => transaction.currency !== report.currency); const hasDifferentWorkspaceCurrency = report.pendingFields?.createChat && isExpenseReport(report) && report.currency !== policy?.outputCurrency; + const hasOptimisticHeldExpense = hasHeldExpenses(report.reportID) && report?.unheldTotal === undefined; - return !(hasPendingTransaction && (hasTransactionWithDifferentCurrency || hasDifferentWorkspaceCurrency)) && !(hasHeldExpenses(report.reportID) && report?.unheldTotal === undefined); + return !(hasPendingTransaction && (hasTransactionWithDifferentCurrency || hasDifferentWorkspaceCurrency)) && !hasOptimisticHeldExpense; } /** From 9a5608750bab8c0fded409e94637cd5d506d76eb Mon Sep 17 00:00:00 2001 From: ShridharGoel <35566748+ShridharGoel@users.noreply.github.com> Date: Tue, 4 Jun 2024 02:08:17 +0530 Subject: [PATCH 029/137] Update --- src/components/LHNOptionsList/LHNOptionsList.tsx | 9 ++++++--- src/components/TextBlock.tsx | 7 ++----- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/components/LHNOptionsList/LHNOptionsList.tsx b/src/components/LHNOptionsList/LHNOptionsList.tsx index 05b7e150fc53..4cac95ed9527 100644 --- a/src/components/LHNOptionsList/LHNOptionsList.tsx +++ b/src/components/LHNOptionsList/LHNOptionsList.tsx @@ -71,7 +71,8 @@ function LHNOptionsList({ () => ( diff --git a/src/components/TextBlock.tsx b/src/components/TextBlock.tsx index 0770bd0891cc..5d1414d95eba 100644 --- a/src/components/TextBlock.tsx +++ b/src/components/TextBlock.tsx @@ -16,17 +16,14 @@ type TextBlockProps = { }; function TextBlock({color, textStyles, text}: TextBlockProps) { - const theme = useTheme(); - const styles = useThemeStyles(); - const words = useMemo(() => text.match(/(\S+\s*)/g) ?? [], [text]); return ( <> {words.map((word) => ( {word} From b5ccc54e52ea634818c9ba08e4f419021f2d61a9 Mon Sep 17 00:00:00 2001 From: Shridhar Goel <35566748+ShridharGoel@users.noreply.github.com> Date: Tue, 4 Jun 2024 14:47:17 +0530 Subject: [PATCH 030/137] Update LHNOptionsList.tsx --- src/components/LHNOptionsList/LHNOptionsList.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/LHNOptionsList/LHNOptionsList.tsx b/src/components/LHNOptionsList/LHNOptionsList.tsx index 4cac95ed9527..f906b8efb35b 100644 --- a/src/components/LHNOptionsList/LHNOptionsList.tsx +++ b/src/components/LHNOptionsList/LHNOptionsList.tsx @@ -103,7 +103,7 @@ function LHNOptionsList({ /> ), - [styles.alignItemsCenter, styles.flexRow, styles.justifyContentCenter, styles.flexWrap, styles.textAlignCenter, styles.mh1, theme.icon, theme.placeholderText, translate], + [styles.alignItemsCenter, styles.flexRow, styles.justifyContentCenter, styles.flexWrap, styles.textAlignCenter, styles.mh1, theme.icon, theme.textSupporting, styles.textNormal, translate], ); /** From e307c86e8a18df915c599c0128c2efb05bb12909 Mon Sep 17 00:00:00 2001 From: Shridhar Goel <35566748+ShridharGoel@users.noreply.github.com> Date: Tue, 4 Jun 2024 14:47:33 +0530 Subject: [PATCH 031/137] Update TextBlock.tsx --- src/components/TextBlock.tsx | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/components/TextBlock.tsx b/src/components/TextBlock.tsx index 5d1414d95eba..ea7899b1c533 100644 --- a/src/components/TextBlock.tsx +++ b/src/components/TextBlock.tsx @@ -1,7 +1,5 @@ import React, {memo, useMemo} from 'react'; import type {StyleProp, TextStyle} from 'react-native'; -import useTheme from '@hooks/useTheme'; -import useThemeStyles from '@hooks/useThemeStyles'; import Text from './Text'; type TextBlockProps = { From a72b9310fb501802316f267a223d7a546fdf9332 Mon Sep 17 00:00:00 2001 From: ShridharGoel <35566748+ShridharGoel@users.noreply.github.com> Date: Tue, 4 Jun 2024 16:22:40 +0530 Subject: [PATCH 032/137] Update --- src/components/LHNOptionsList/LHNOptionsList.tsx | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/src/components/LHNOptionsList/LHNOptionsList.tsx b/src/components/LHNOptionsList/LHNOptionsList.tsx index f906b8efb35b..27325be54168 100644 --- a/src/components/LHNOptionsList/LHNOptionsList.tsx +++ b/src/components/LHNOptionsList/LHNOptionsList.tsx @@ -103,7 +103,18 @@ function LHNOptionsList({ /> ), - [styles.alignItemsCenter, styles.flexRow, styles.justifyContentCenter, styles.flexWrap, styles.textAlignCenter, styles.mh1, theme.icon, theme.textSupporting, styles.textNormal, translate], + [ + styles.alignItemsCenter, + styles.flexRow, + styles.justifyContentCenter, + styles.flexWrap, + styles.textAlignCenter, + styles.mh1, + theme.icon, + theme.textSupporting, + styles.textNormal, + translate, + ], ); /** From a8fbfa6ae5e5d11879015680fb9b9d3dc739df27 Mon Sep 17 00:00:00 2001 From: war-in Date: Tue, 4 Jun 2024 13:04:00 +0200 Subject: [PATCH 033/137] use `personalDetails.login` as account name --- src/libs/OnyxAwareParser.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/libs/OnyxAwareParser.ts b/src/libs/OnyxAwareParser.ts index 586b914216be..3366de44e76c 100644 --- a/src/libs/OnyxAwareParser.ts +++ b/src/libs/OnyxAwareParser.ts @@ -26,16 +26,18 @@ Onyx.connect({ return; } - accountIDToNameMap[personalDetails.accountID] = personalDetails.displayName ?? String(personalDetails.accountID); + accountIDToNameMap[personalDetails.accountID] = personalDetails.login ?? String(personalDetails.accountID); }); }, }); function parseHtmlToMarkdown(html: string): string { + // TODO: change `reportIdToName` to `reportIDToName` (changes in expensify-common) return parser.htmlToMarkdown(html, {reportIdToName: reportIDToNameMap, accountIDToName: accountIDToNameMap}); } function parseHtmlToText(html: string): string { + // TODO: change `reportIdToName` to `reportIDToName` (changes in expensify-common) return parser.htmlToText(html, {reportIdToName: reportIDToNameMap, accountIDToName: accountIDToNameMap}); } From aa695fe3aeb07dfb16024e04e496ab5c3b250e8e Mon Sep 17 00:00:00 2001 From: tienifr Date: Wed, 5 Jun 2024 05:25:32 +0700 Subject: [PATCH 034/137] fix comment --- src/libs/ReportUtils.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/libs/ReportUtils.ts b/src/libs/ReportUtils.ts index 329510baf38a..f342ee61f85c 100644 --- a/src/libs/ReportUtils.ts +++ b/src/libs/ReportUtils.ts @@ -5275,14 +5275,16 @@ function shouldReportBeInOptionList({ return includeSelfDM; } const parentReportAction = ReportActionsUtils.getParentReportAction(report); + + // Hide chat threads where the parent message is pending removal if ( - parentReportAction && !isEmptyObject(parentReportAction) && ReportActionsUtils.isPendingRemove(parentReportAction) && ReportActionsUtils.isThreadParentMessage(parentReportAction, report?.reportID ?? '') ) { return false; } + return true; } From d7f1ae6a7fcbbcc89074265fb8e7981f7b17864f Mon Sep 17 00:00:00 2001 From: tienifr Date: Thu, 6 Jun 2024 15:19:08 +0700 Subject: [PATCH 035/137] fix: empty category illustration is not center aligned --- src/components/WorkspaceEmptyStateSection.tsx | 20 +++++++++++++++++-- .../request/step/IOURequestStepCategory.tsx | 10 ++++------ 2 files changed, 22 insertions(+), 8 deletions(-) diff --git a/src/components/WorkspaceEmptyStateSection.tsx b/src/components/WorkspaceEmptyStateSection.tsx index e1ee7a1b66c3..6a00aa4bf5eb 100644 --- a/src/components/WorkspaceEmptyStateSection.tsx +++ b/src/components/WorkspaceEmptyStateSection.tsx @@ -1,5 +1,6 @@ import React from 'react'; import {View} from 'react-native'; +import type {StyleProp, ViewStyle} from 'react-native'; import useResponsiveLayout from '@hooks/useResponsiveLayout'; import useThemeStyles from '@hooks/useThemeStyles'; import type IconAsset from '@src/types/utils/IconAsset'; @@ -15,14 +16,29 @@ type WorkspaceEmptyStateSectionProps = { /** The icon to display along with the title */ icon: IconAsset; + + /** Additional style for container */ + containerStyle?: StyleProp; + + /** Whether to apply card style to container */ + shouldStyleAsCard?: boolean; }; -function WorkspaceEmptyStateSection({icon, subtitle, title}: WorkspaceEmptyStateSectionProps) { +function WorkspaceEmptyStateSection({icon, subtitle, title, containerStyle, shouldStyleAsCard = true}: WorkspaceEmptyStateSectionProps) { const styles = useThemeStyles(); const {shouldUseNarrowLayout} = useResponsiveLayout(); return ( - + -