Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions src/libs/ReportActionsUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@
}

let allReportActions: OnyxCollection<ReportActions>;
Onyx.connect({

Check warning on line 93 in src/libs/ReportActionsUtils.ts

View workflow job for this annotation

GitHub Actions / Changed files ESLint check

Onyx.connect() is deprecated. Use useOnyx() hook instead and pass the data as parameters to a pure function
key: ONYXKEYS.COLLECTION.REPORT_ACTIONS,
waitForCollectionCallback: true,
callback: (actions) => {
Expand All @@ -102,7 +102,7 @@
});

let allReports: OnyxCollection<Report>;
Onyx.connect({

Check warning on line 105 in src/libs/ReportActionsUtils.ts

View workflow job for this annotation

GitHub Actions / Changed files ESLint check

Onyx.connect() is deprecated. Use useOnyx() hook instead and pass the data as parameters to a pure function
key: ONYXKEYS.COLLECTION.REPORT,
waitForCollectionCallback: true,
callback: (value) => {
Expand All @@ -111,13 +111,13 @@
});

let deprecatedIsNetworkOffline = false;
Onyx.connect({

Check warning on line 114 in src/libs/ReportActionsUtils.ts

View workflow job for this annotation

GitHub Actions / Changed files ESLint check

Onyx.connect() is deprecated. Use useOnyx() hook instead and pass the data as parameters to a pure function
key: ONYXKEYS.NETWORK,
callback: (val) => (deprecatedIsNetworkOffline = val?.isOffline ?? false),
});

let deprecatedCurrentUserAccountID: number | undefined;
Onyx.connect({

Check warning on line 120 in src/libs/ReportActionsUtils.ts

View workflow job for this annotation

GitHub Actions / Changed files ESLint check

Onyx.connect() is deprecated. Use useOnyx() hook instead and pass the data as parameters to a pure function
key: ONYXKEYS.SESSION,
callback: (value) => {
// When signed out, value is undefined
Expand Down Expand Up @@ -1180,8 +1180,11 @@
const reportID = reportAction.reportID;
const actions = allActionsForReport ?? (reportID ? allReportActions?.[`${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${reportID}`] : undefined);
if (actions) {
const parentOffset = isActionableReportMentionWhisper(reportAction) ? 2n : 1n;
const parentActionID = String(BigInt(reportAction.reportActionID) - parentOffset);
// Prefer the stored reportActionID from the whisper's originalMessage when available (set for
// whispers created during message edits, which don't follow the parentID+1 ID convention).
// Fall back to offset arithmetic for legacy whispers that predate this field.
const storedParentID = isActionableMentionWhisper(reportAction) ? (originalMessage as {parentReportActionID?: string}).parentReportActionID : undefined;
const parentActionID = storedParentID ?? String(BigInt(reportAction.reportActionID) - (isActionableReportMentionWhisper(reportAction) ? 2n : 1n));
const parentAction = actions[parentActionID];
if (parentAction && !isDeletedAction(parentAction)) {
return false;
Expand Down
16 changes: 16 additions & 0 deletions src/libs/actions/Report/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -381,7 +381,7 @@
// map of reportID to all reportActions for that report
const allReportActions: OnyxCollection<ReportActions> = {};

Onyx.connect({

Check warning on line 384 in src/libs/actions/Report/index.ts

View workflow job for this annotation

GitHub Actions / Changed files ESLint check

Onyx.connect() is deprecated. Use useOnyx() hook instead and pass the data as parameters to a pure function
key: ONYXKEYS.COLLECTION.REPORT_ACTIONS,
callback: (actions, key) => {
if (!key || !actions) {
Expand All @@ -393,7 +393,7 @@
});

let allReports: OnyxCollection<Report>;
Onyx.connect({

Check warning on line 396 in src/libs/actions/Report/index.ts

View workflow job for this annotation

GitHub Actions / Changed files ESLint check

Onyx.connect() is deprecated. Use useOnyx() hook instead and pass the data as parameters to a pure function
key: ONYXKEYS.COLLECTION.REPORT,
waitForCollectionCallback: true,
callback: (value) => {
Expand All @@ -402,7 +402,7 @@
});

let allPersonalDetails: OnyxEntry<PersonalDetailsList> = {};
Onyx.connect({

Check warning on line 405 in src/libs/actions/Report/index.ts

View workflow job for this annotation

GitHub Actions / Changed files ESLint check

Onyx.connect() is deprecated. Use useOnyx() hook instead and pass the data as parameters to a pure function
key: ONYXKEYS.PERSONAL_DETAILS_LIST,
callback: (value) => {
allPersonalDetails = value ?? {};
Expand All @@ -417,7 +417,7 @@
});

let onboarding: OnyxEntry<Onboarding>;
Onyx.connect({

Check warning on line 420 in src/libs/actions/Report/index.ts

View workflow job for this annotation

GitHub Actions / Changed files ESLint check

Onyx.connect() is deprecated. Use useOnyx() hook instead and pass the data as parameters to a pure function
key: ONYXKEYS.NVP_ONBOARDING,
callback: (val) => {
if (Array.isArray(val)) {
Expand Down Expand Up @@ -2566,6 +2566,22 @@
}
}

// Whispers created during a message edit receive a random ID (not parentID+1/+2), but the
// backend stores the parent's reportActionID in originalMessage.parentReportActionID. Scan
// all actions to catch any such whispers that the offset lookup above would miss.
for (const [actionID, action] of Object.entries(reportActionsForReport)) {
if (unresolvedMentionWhisperIDs.includes(actionID)) {
continue;
}
if (!ReportActionsUtils.isActionableMentionWhisper(action) && !ReportActionsUtils.isActionableReportMentionWhisper(action)) {
continue;
}
const originalMessage = ReportActionsUtils.getOriginalMessage(action);
if (originalMessage?.parentReportActionID === reportActionID && !originalMessage?.resolution && !originalMessage?.deleted) {
unresolvedMentionWhisperIDs.push(actionID);
}
}

const deletedTime = DateUtils.getDBTime();
for (const whisperID of unresolvedMentionWhisperIDs) {
optimisticReportActions[whisperID] = {
Expand Down
10 changes: 8 additions & 2 deletions src/types/onyx/OriginalMessage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,11 @@ type OriginalMessageActionableMentionWhisper = {

/** Timestamp of when the whisper was deleted (set by the backend when the parent comment is deleted) */
deleted?: string | null;

/** The reportActionID of the parent comment that triggered this whisper. Used to find the parent when this
* whisper was created during a message edit (and therefore doesn't follow the parentID+1 ID convention).
* Stored as a string by the backend to preserve full int64 precision. */
parentReportActionID?: string;
};

/** Model of `actionable card fraud alert` report action */
Expand Down Expand Up @@ -196,8 +201,9 @@ type OriginalMessageActionableReportMentionWhisper = {
/** Timestamp of when the whisper was deleted (set by the backend when the parent comment is deleted) */
deleted?: string | null;

/** The reportActionID of the parent comment that triggered this whisper */
reportActionID?: number;
/** The reportActionID of the parent comment that triggered this whisper.
* Stored as a string by the backend to preserve full int64 precision. */
parentReportActionID?: string;
};

/** Model of `welcome whisper` report action */
Expand Down
Loading