-
Notifications
You must be signed in to change notification settings - Fork 2.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Refactor task preview for hidden case #35027
Changes from all commits
8c802ed
bba68ba
357ef0c
caaf8c1
852c38d
069e83e
03743f7
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,7 +6,6 @@ import type {OnyxEntry} from 'react-native-onyx'; | |
import Checkbox from '@components/Checkbox'; | ||
import Icon from '@components/Icon'; | ||
import * as Expensicons from '@components/Icon/Expensicons'; | ||
import {usePersonalDetails} from '@components/OnyxProvider'; | ||
import PressableWithoutFeedback from '@components/Pressable/PressableWithoutFeedback'; | ||
import RenderHTML from '@components/RenderHTML'; | ||
import {showContextMenuForReport} from '@components/ShowContextMenuContext'; | ||
|
@@ -18,7 +17,6 @@ import useThemeStyles from '@hooks/useThemeStyles'; | |
import ControlSelection from '@libs/ControlSelection'; | ||
import * as DeviceCapabilities from '@libs/DeviceCapabilities'; | ||
import getButtonState from '@libs/getButtonState'; | ||
import * as LocalePhoneNumber from '@libs/LocalePhoneNumber'; | ||
import Navigation from '@libs/Navigation/Navigation'; | ||
import * as ReportUtils from '@libs/ReportUtils'; | ||
import * as TaskUtils from '@libs/TaskUtils'; | ||
|
@@ -65,7 +63,6 @@ type TaskPreviewProps = WithCurrentUserPersonalDetailsProps & | |
function TaskPreview({taskReport, taskReportID, action, contextMenuAnchor, chatReportID, checkIfContextMenuActive, currentUserPersonalDetails, isHovered = false}: TaskPreviewProps) { | ||
const styles = useThemeStyles(); | ||
const StyleUtils = useStyleUtils(); | ||
const personalDetails = usePersonalDetails() || CONST.EMPTY_OBJECT; | ||
const {translate} = useLocalize(); | ||
|
||
// The reportAction might not contain details regarding the taskReport | ||
|
@@ -76,13 +73,8 @@ function TaskPreview({taskReport, taskReportID, action, contextMenuAnchor, chatR | |
: action?.childStateNum === CONST.REPORT.STATE_NUM.APPROVED && action?.childStatusNum === CONST.REPORT.STATUS_NUM.APPROVED; | ||
const taskTitle = Str.htmlEncode(TaskUtils.getTaskTitle(taskReportID, action?.childReportName ?? '')); | ||
const taskAssigneeAccountID = Task.getTaskAssigneeAccountID(taskReport) ?? action?.childManagerAccountID ?? ''; | ||
const assigneeLogin = personalDetails[taskAssigneeAccountID]?.login ?? ''; | ||
const assigneeDisplayName = personalDetails[taskAssigneeAccountID]?.displayName ?? ''; | ||
const taskAssignee = assigneeDisplayName || LocalePhoneNumber.formatPhoneNumber(assigneeLogin); | ||
const htmlForTaskPreview = | ||
taskAssignee && taskAssigneeAccountID !== 0 | ||
? `<comment><mention-user accountid="${taskAssigneeAccountID}">@${taskAssignee}</mention-user> ${taskTitle}</comment>` | ||
: `<comment>${taskTitle}</comment>`; | ||
taskAssigneeAccountID !== 0 ? `<comment><mention-user accountid="${taskAssigneeAccountID}"></mention-user> ${taskTitle}</comment>` : `<comment>${taskTitle}</comment>`; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is there any linter warning if we keep 3 lines as before instead of 1 line of code, it's hard to read code for me atm? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It's displayed after I run prettier. |
||
const isDeletedParentAction = ReportUtils.isCanceledTaskReport(taskReport, action); | ||
|
||
if (isDeletedParentAction) { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you think we can replace this line by
ReportUtils.getDisplayNameForParticipant
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looked at
getDisplayNameForParticipant
function and yeah we can use this as well.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
TLDR; we tried to use
getDisplayNameForParticipant
but we found a bug here, so we decided to keep it as it is for now.#35027 (comment)