-
Notifications
You must be signed in to change notification settings - Fork 3.1k
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
Fix "New message" button shows when resolving an actionable mention whisper #50247
Changes from 1 commit
df8c9da
0058a06
71a09c9
caadda7
c4d90a0
9e03ff0
3d92ab7
24c72aa
386a87f
fbeb86a
f3538c0
64f3c3b
590505b
6875079
adb33aa
4f72027
3528073
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 |
---|---|---|
|
@@ -618,6 +618,39 @@ function isReportActionDeprecated(reportAction: OnyxEntry<ReportAction>, key: st | |
return false; | ||
} | ||
|
||
/** | ||
* Checks if a given report action corresponds to an actionable mention whisper. | ||
* @param reportAction | ||
*/ | ||
function isActionableMentionWhisper(reportAction: OnyxEntry<ReportAction>): reportAction is ReportAction<typeof CONST.REPORT.ACTIONS.TYPE.ACTIONABLE_MENTION_WHISPER> { | ||
return isActionOfType(reportAction, CONST.REPORT.ACTIONS.TYPE.ACTIONABLE_MENTION_WHISPER); | ||
} | ||
|
||
/** | ||
* Checks if a given report action corresponds to an actionable report mention whisper. | ||
* @param reportAction | ||
*/ | ||
function isActionableReportMentionWhisper(reportAction: OnyxEntry<ReportAction>): reportAction is ReportAction<typeof CONST.REPORT.ACTIONS.TYPE.ACTIONABLE_REPORT_MENTION_WHISPER> { | ||
return isActionOfType(reportAction, CONST.REPORT.ACTIONS.TYPE.ACTIONABLE_REPORT_MENTION_WHISPER); | ||
} | ||
|
||
/** | ||
* Checks whether an action is actionable track expense. | ||
dangrous marked this conversation as resolved.
Show resolved
Hide resolved
|
||
*/ | ||
function isActionableTrackExpense(reportAction: OnyxInputOrEntry<ReportAction>): reportAction is ReportAction<typeof CONST.REPORT.ACTIONS.TYPE.ACTIONABLE_TRACK_EXPENSE_WHISPER> { | ||
return isActionOfType(reportAction, CONST.REPORT.ACTIONS.TYPE.ACTIONABLE_TRACK_EXPENSE_WHISPER); | ||
} | ||
|
||
function isActionableWhisper( | ||
reportAction: OnyxEntry<ReportAction>, | ||
): reportAction is ReportAction< | ||
dangrous marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| typeof CONST.REPORT.ACTIONS.TYPE.ACTIONABLE_MENTION_WHISPER | ||
| typeof CONST.REPORT.ACTIONS.TYPE.ACTIONABLE_TRACK_EXPENSE_WHISPER | ||
| typeof CONST.REPORT.ACTIONS.TYPE.ACTIONABLE_REPORT_MENTION_WHISPER | ||
> { | ||
return isActionableMentionWhisper(reportAction) || isActionableTrackExpense(reportAction) || isActionableReportMentionWhisper(reportAction); | ||
} | ||
|
||
const {POLICY_CHANGE_LOG: policyChangelogTypes, ROOM_CHANGE_LOG: roomChangeLogTypes, ...otherActionTypes} = CONST.REPORT.ACTIONS.TYPE; | ||
const supportedActionTypes: ReportActionName[] = [...Object.values(otherActionTypes), ...Object.values(policyChangelogTypes), ...Object.values(roomChangeLogTypes)]; | ||
|
||
|
@@ -662,6 +695,11 @@ function shouldReportActionBeVisible(reportAction: OnyxEntry<ReportAction>, key: | |
return true; | ||
} | ||
|
||
// If action is actionable whisper and resolved by user, then we don't want to render anything | ||
if (isActionableWhisper(reportAction) && getOriginalMessage(reportAction)?.resolution) { | ||
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. This line caused a regression. See #55855 for details. |
||
return false; | ||
} | ||
|
||
// All other actions are displayed except thread parents, deleted, or non-pending actions | ||
const isDeleted = isDeletedAction(reportAction); | ||
const isPending = !!reportAction.pendingAction; | ||
|
@@ -679,24 +717,6 @@ function shouldHideNewMarker(reportAction: OnyxEntry<ReportAction>): boolean { | |
return !isNetworkOffline && reportAction.pendingAction === CONST.RED_BRICK_ROAD_PENDING_ACTION.DELETE; | ||
} | ||
|
||
/** | ||
* Checks whether an action is actionable track expense. | ||
* | ||
*/ | ||
function isActionableTrackExpense(reportAction: OnyxInputOrEntry<ReportAction>): reportAction is ReportAction<typeof CONST.REPORT.ACTIONS.TYPE.ACTIONABLE_TRACK_EXPENSE_WHISPER> { | ||
return isActionOfType(reportAction, CONST.REPORT.ACTIONS.TYPE.ACTIONABLE_TRACK_EXPENSE_WHISPER); | ||
} | ||
|
||
/** | ||
* Checks whether an action is actionable track expense and resolved. | ||
* | ||
*/ | ||
function isResolvedActionTrackExpense(reportAction: OnyxEntry<ReportAction>): boolean { | ||
const originalMessage = getOriginalMessage(reportAction); | ||
const resolution = originalMessage && typeof originalMessage === 'object' && 'resolution' in originalMessage ? originalMessage?.resolution : null; | ||
return isActionableTrackExpense(reportAction) && !!resolution; | ||
} | ||
|
||
/** | ||
* Checks if a reportAction is fit for display as report last action, meaning that | ||
* it satisfies shouldReportActionBeVisible, it's not whisper action and not deleted. | ||
|
@@ -715,8 +735,7 @@ function shouldReportActionBeVisibleAsLastAction(reportAction: OnyxInputOrEntry< | |
return ( | ||
shouldReportActionBeVisible(reportAction, reportAction.reportActionID) && | ||
!(isWhisperAction(reportAction) && !isReportPreviewAction(reportAction) && !isMoneyRequestAction(reportAction)) && | ||
!(isDeletedAction(reportAction) && !isDeletedParentAction(reportAction)) && | ||
!isResolvedActionTrackExpense(reportAction) | ||
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. I remove checking |
||
!(isDeletedAction(reportAction) && !isDeletedParentAction(reportAction)) | ||
); | ||
} | ||
|
||
|
@@ -1396,22 +1415,6 @@ function hasRequestFromCurrentAccount(reportID: string, currentAccountID: number | |
return reportActions.some((action) => action.actionName === CONST.REPORT.ACTIONS.TYPE.IOU && action.actorAccountID === currentAccountID); | ||
} | ||
|
||
/** | ||
* Checks if a given report action corresponds to an actionable mention whisper. | ||
* @param reportAction | ||
*/ | ||
function isActionableMentionWhisper(reportAction: OnyxEntry<ReportAction>): reportAction is ReportAction<typeof CONST.REPORT.ACTIONS.TYPE.ACTIONABLE_MENTION_WHISPER> { | ||
return isActionOfType(reportAction, CONST.REPORT.ACTIONS.TYPE.ACTIONABLE_MENTION_WHISPER); | ||
} | ||
|
||
/** | ||
* Checks if a given report action corresponds to an actionable report mention whisper. | ||
* @param reportAction | ||
*/ | ||
function isActionableReportMentionWhisper(reportAction: OnyxEntry<ReportAction>): reportAction is ReportAction<typeof CONST.REPORT.ACTIONS.TYPE.ACTIONABLE_REPORT_MENTION_WHISPER> { | ||
return isActionOfType(reportAction, CONST.REPORT.ACTIONS.TYPE.ACTIONABLE_REPORT_MENTION_WHISPER); | ||
} | ||
|
||
/** | ||
* Constructs a message for an actionable mention whisper report action. | ||
* @param reportAction | ||
|
@@ -1802,6 +1805,7 @@ export { | |
getWhisperedTo, | ||
hasRequestFromCurrentAccount, | ||
isActionOfType, | ||
isActionableWhisper, | ||
isActionableJoinRequest, | ||
isActionableJoinRequestPending, | ||
isActionableMentionWhisper, | ||
|
@@ -1834,7 +1838,6 @@ export { | |
isReportActionAttachment, | ||
isReportActionDeprecated, | ||
isReportPreviewAction, | ||
isResolvedActionTrackExpense, | ||
isReversedTransaction, | ||
isRoomChangeLogAction, | ||
isSentMoneyReportAction, | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -34,7 +34,7 @@ | |
import UnreadActionIndicator from '@components/UnreadActionIndicator'; | ||
import useLocalize from '@hooks/useLocalize'; | ||
import usePrevious from '@hooks/usePrevious'; | ||
import useReportScrollManager from '@hooks/useReportScrollManager'; | ||
import useResponsiveLayout from '@hooks/useResponsiveLayout'; | ||
import useStyleUtils from '@hooks/useStyleUtils'; | ||
import useTheme from '@hooks/useTheme'; | ||
|
@@ -200,20 +200,14 @@ | |
// eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing | ||
const [parentReport] = useOnyx(`${ONYXKEYS.COLLECTION.REPORT}${report?.parentReportID || -1}`); | ||
const isReportActionLinked = linkedReportActionID && action.reportActionID && linkedReportActionID === action.reportActionID; | ||
const reportScrollManager = useReportScrollManager(); | ||
const isActionableWhisper = | ||
ReportActionsUtils.isActionableMentionWhisper(action) || ReportActionsUtils.isActionableTrackExpense(action) || ReportActionsUtils.isActionableReportMentionWhisper(action); | ||
const originalMessage = ReportActionsUtils.getOriginalMessage(action); | ||
const isActionableWhisper = ReportActionsUtils.isActionableWhisper(action); | ||
|
||
const highlightedBackgroundColorIfNeeded = useMemo( | ||
() => (isReportActionLinked ? StyleUtils.getBackgroundColorStyle(theme.messageHighlightBG) : {}), | ||
[StyleUtils, isReportActionLinked, theme.messageHighlightBG], | ||
); | ||
|
||
const isDeletedParentAction = ReportActionsUtils.isDeletedParentAction(action); | ||
const isOriginalMessageAnObject = originalMessage && typeof originalMessage === 'object'; | ||
const hasResolutionInOriginalMessage = isOriginalMessageAnObject && 'resolution' in originalMessage; | ||
const prevActionResolution = usePrevious(isActionableWhisper && hasResolutionInOriginalMessage ? originalMessage?.resolution : null); | ||
|
||
// IOUDetails only exists when we are sending money | ||
const isSendingMoney = | ||
|
@@ -360,18 +354,6 @@ | |
[draftMessage, action, reportID, toggleContextMenuFromActiveReportAction, originalReportID, shouldDisplayContextMenu, disabledActions, isArchivedRoom, isChronosReport], | ||
); | ||
|
||
// Handles manual scrolling to the bottom of the chat when the last message is an actionable whisper and it's resolved. | ||
// This fixes an issue where InvertedFlatList fails to auto scroll down and results in an empty space at the bottom of the chat in IOS. | ||
useEffect(() => { | ||
if (index !== 0 || !isActionableWhisper) { | ||
return; | ||
} | ||
|
||
if (prevActionResolution !== (hasResolutionInOriginalMessage ? originalMessage.resolution : null)) { | ||
reportScrollManager.scrollToIndex(index); | ||
} | ||
}, [index, originalMessage, prevActionResolution, reportScrollManager, isActionableWhisper, hasResolutionInOriginalMessage]); | ||
|
||
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. Removed this workaround because the issue doesn't happen anymore after we exclude the resolved actionable whisper from the list. |
||
const toggleReaction = useCallback( | ||
(emoji: Emoji, ignoreSkinToneOnCompare?: boolean) => { | ||
Report.toggleEmojiReaction(reportID, action, emoji, emojiReactions, undefined, ignoreSkinToneOnCompare); | ||
|
@@ -879,11 +861,6 @@ | |
return null; | ||
} | ||
|
||
// If action is actionable whisper and resolved by user, then we don't want to render anything | ||
if (isActionableWhisper && (hasResolutionInOriginalMessage ? originalMessage.resolution : null)) { | ||
return null; | ||
} | ||
|
||
// We currently send whispers to all report participants and hide them in the UI for users that shouldn't see them. | ||
// This is a temporary solution needed for comment-linking. | ||
// The long term solution will leverage end-to-end encryption and only targeted users will be able to decrypt. | ||
|
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.
Same as https://github.com/Expensify/App/pull/50247/files#r1787860157