Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
6c59e81
Pass transactionThreadIDs from InSelector to getAlternateText for res…
truph01 Oct 19, 2026
ce120e4
Pass transactionThreadIDs through getMoneyRequestParticipantOptions
truph01 Oct 19, 2026
81fdc7b
fix: add test
truph01 Oct 19, 2026
1253247
fix: update comment
truph01 Oct 19, 2026
3fb22cd
Revert transactionThreadIDs plumbing in getReportOption flows; pass u…
truph01 Oct 19, 2026
9328801
Pass explicit undefined transactionThreadIDs in getReportDisplayOption
truph01 Oct 19, 2026
cd02803
Pass explicit undefined transactionThreadIDs in getPolicyExpenseRepor…
truph01 Oct 19, 2026
b378b78
Pass explicit undefined transactionThreadIDs in buildFullOption and g…
truph01 Oct 19, 2026
5407e61
Pass transactionThreadIDs in SearchAutocompleteList's Auth-matched ge…
truph01 Oct 19, 2026
a2351f8
Make oneTransactionThreadReportID a required string in resolveLastAct…
truph01 Oct 19, 2026
ff2333b
Add getAlternateText test for missing one-transaction thread ID
truph01 Oct 19, 2026
cdbb556
Revert oneTransactionThreadReportID to string | undefined to satisfy …
truph01 Oct 19, 2026
5bf4ebf
fix: conflicts
truph01 Nov 3, 2026
d757102
fix: oxlint
truph01 Nov 3, 2026
1e1abd1
Merge branch 'Expensify:main' into fix/66381-part-7
truph01 Nov 9, 2026
ed7b015
Merge branch 'Expensify:main' into fix/66381-part-7
truph01 Nov 10, 2026
c95a194
fix: test
truph01 Nov 10, 2026
9349d43
Address review: real IOU fixture in resolveLastActionContext test, dr…
truph01 Nov 12, 2026
5290133
Merge branch 'Expensify:main' into fix/66381-part-7
truph01 Nov 12, 2026
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
1 change: 1 addition & 0 deletions src/components/Search/FilterComponents/InSelector.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,7 @@ function InSelector({value = [], selectionListTextInputStyle, selectionListStyle
reportAttributesDerived,
policyTags: reportPolicyTags,
conciergeReportID,
transactionThreadIDs,
isTrackIntentUser,
translate,
currentUserAccountID,
Expand Down
1 change: 1 addition & 0 deletions src/components/Search/SearchAutocompleteList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -366,6 +366,7 @@ function SearchAutocompleteList({
policyCollection: policies,
personalDetails,
sortedActions,
transactionThreadIDs,
conciergeReportID,
isTrackIntentUser,
translate,
Expand Down
12 changes: 12 additions & 0 deletions src/libs/OptionsListUtils/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -664,6 +664,9 @@ function getReportOption({
// `sortedActions` is only read to build the report preview last message. These options are static (`showChatPreviewLine: false`) and their
// consumers don't render `lastMessageText`, so we verified nothing in this flow depends on it and pass undefined instead of threading it from every caller.
sortedActions: undefined,
// `transactionThreadIDs` is only read to resolve the chat preview's last action. With `showChatPreviewLine: false` the preview is never built
// (and `alternateText` is overwritten below), so we pass undefined instead of threading it from every caller.
transactionThreadIDs: undefined,
currentUserAccountID,
formatPhoneNumber,
pendingDeleteMemberAccountIDs,
Expand Down Expand Up @@ -758,6 +761,9 @@ function getReportDisplayOption({
// `sortedActions` is only read to build the report preview last message. These options are static (`showChatPreviewLine: false`) and their
// consumers don't render `lastMessageText`, so we verified nothing in this flow depends on it and pass undefined instead of threading it from every caller.
sortedActions: undefined,
// `transactionThreadIDs` is only read to resolve the chat preview's last action. With `showChatPreviewLine: false` the preview is never built,
// so we pass undefined instead of threading it from every caller.
transactionThreadIDs: undefined,
currentUserAccountID,
formatPhoneNumber,
pendingDeleteMemberAccountIDs,
Expand Down Expand Up @@ -828,6 +834,8 @@ function getPolicyExpenseReportOption(
showChatPreviewLine: false,
forcePolicyNamePreview: false,
},
// Passing transactionThreadIDs as undefined is intentional, it is only read to build the chat preview line, which `showChatPreviewLine: false` disables.
transactionThreadIDs: undefined,
reportAttributesDerived,
policyTags,
visibleReportActionsData,
Expand Down Expand Up @@ -1144,6 +1152,8 @@ function buildFullOption(
translate,
// Passing pendingDeleteMemberAccountIDs as undefined is intentional, `report` here is always a 1:1 DM, never a group chat.
pendingDeleteMemberAccountIDs: undefined,
// Passing transactionThreadIDs as undefined is intentional, contact options show personal details and never build the chat preview line that reads it.
transactionThreadIDs: undefined,
formatPhoneNumber,
}),
isHydrated: true,
Expand Down Expand Up @@ -1899,6 +1909,8 @@ function getUserToInviteOption({
conciergeReportID: undefined,
// Passing pendingDeleteMemberAccountIDs as undefined is intentional, there is no report to build a group chat name from.
pendingDeleteMemberAccountIDs: undefined,
// Passing transactionThreadIDs as undefined is intentional, the invite option has no report, so there is no chat preview to resolve.
transactionThreadIDs: undefined,
config: {showChatPreviewLine},
visibleReportActionsData,
currentUserAccountID,
Expand Down
6 changes: 2 additions & 4 deletions src/libs/ReportAlternateTextUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -429,12 +429,10 @@ function resolveLastActionContext(
report: Report,
isReportArchived: boolean | undefined,
visibleReportActionsData: VisibleReportActionsDerivedValue | undefined,
oneTransactionThreadReportID?: string,
oneTransactionThreadReportID: string | undefined,
): LastActionContext {
const canUserPerformWrite = canUserPerformWriteAction(report, isReportArchived);
// eslint-disable-next-line @typescript-eslint/no-deprecated
const resolvedOneTransactionThreadReportID = oneTransactionThreadReportID ?? deprecatedCachedOneTransactionThreadReportIDs[report.reportID];
const lastAction = getLastVisibleActionIncludingTransactionThread(report.reportID, canUserPerformWrite, undefined, visibleReportActionsData, resolvedOneTransactionThreadReportID);
const lastAction = getLastVisibleActionIncludingTransactionThread(report.reportID, canUserPerformWrite, undefined, visibleReportActionsData, oneTransactionThreadReportID);
let lastActionReport: OnyxEntry<Report>;
if (isInviteOrRemovedAction(lastAction)) {
const lastActionOriginalMessage = getOriginalMessage(lastAction);
Expand Down
4 changes: 2 additions & 2 deletions tests/unit/OptionsListUtilsTest.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7115,7 +7115,6 @@ describe('OptionsListUtils', () => {
],
};

// Reports must exist before the report actions merge so the one-transaction thread caches resolve the thread ID
await setReport(expenseReport);
await setReport(transactionThreadReport);
await Onyx.mergeCollection(ONYXKEYS.COLLECTION.REPORT_ACTIONS, {
Expand All @@ -7133,7 +7132,8 @@ describe('OptionsListUtils', () => {
isMoneyRequestReport: true,
};

const result = getAlternateText(option, {showChatPreviewLine: true}, buildConfig());
// When the alternate text is built with the one-transaction thread IDs from the sorted report actions derived value
const result = getAlternateText(option, {showChatPreviewLine: true}, buildConfig({transactionThreadIDs: {[EXPENSE_REPORT_ID]: TRANSACTION_THREAD_REPORT_ID}}));

// Then the actor prefix comes from the transaction thread comment, not from the parent report's IOU action
expect(result).toBe('Spider-Man: thread comment');
Expand Down
68 changes: 68 additions & 0 deletions tests/unit/ReportAlternateTextUtilsTest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ import {
getLastMessageTextForReport,
getReportAlternateText,
getWelcomeMessage,
resolveLastActionContext,
shouldShowLastActorDisplayName,
} from '@libs/ReportAlternateTextUtils';
import {formatReportLastMessageText, getMovedActionMessage, getMovedTransactionMessage, getReportPreviewMessage, parseMovedTransactionReportIDs} from '@libs/ReportUtils';
Expand Down Expand Up @@ -442,6 +443,73 @@ describe('ReportAlternateTextUtils', () => {
});
});

describe('resolveLastActionContext', () => {
const parentReportID = '9001';
const transactionThreadReportID = '9002';
const chatReportID = '9003';
const makeCommentAction = (reportActionID: string, created: string): ReportAction => ({
reportActionID,
actionName: CONST.REPORT.ACTIONS.TYPE.ADD_COMMENT,
actorAccountID: 1,
created,
message: [{type: 'COMMENT', html: reportActionID, text: reportActionID}],
person: [{type: 'TEXT', style: 'strong', text: 'User'}],
shouldShow: true,
});
const parentComment = makeCommentAction('9100', '2024-01-01 10:00:00.000');
const iouAction: ReportAction = {
reportActionID: '9101',
actionName: CONST.REPORT.ACTIONS.TYPE.IOU,
actorAccountID: 1,
childReportID: transactionThreadReportID,
created: '2024-01-01 09:00:00.000',
message: [{type: 'COMMENT', html: '$1.00', text: '$1.00'}],
// eslint-disable-next-line @typescript-eslint/no-deprecated -- the fixture must carry an IOU originalMessage so the module cache maps the report to its transaction thread
originalMessage: {
IOUTransactionID: 'txn9101',
IOUReportID: parentReportID,
amount: 100,
currency: CONST.CURRENCY.USD,
type: CONST.IOU.REPORT_ACTION_TYPE.CREATE,
},
shouldShow: true,
};
const threadComment = makeCommentAction('9200', '2024-01-02 10:00:00.000');
const expenseReport: Report = {
...createRandomReport(Number(parentReportID), undefined),
reportID: parentReportID,
type: CONST.REPORT.TYPE.EXPENSE,
chatReportID,
};

beforeEach(async () => {
// Seed a one-transaction expense report whose transaction thread has the newest comment
await Onyx.set(`${ONYXKEYS.COLLECTION.REPORT}${parentReportID}`, expenseReport);
await Onyx.set(`${ONYXKEYS.COLLECTION.REPORT}${chatReportID}`, {...createRandomReport(Number(chatReportID), undefined), reportID: chatReportID, type: CONST.REPORT.TYPE.CHAT});
await Onyx.set(`${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${parentReportID}`, {[parentComment.reportActionID]: parentComment, [iouAction.reportActionID]: iouAction});
await Onyx.set(`${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${transactionThreadReportID}`, {[threadComment.reportActionID]: threadComment});
await waitForBatchedUpdates();
});

it('returns the transaction thread action when the one-transaction thread ID is passed', () => {
// Given the caller resolved the one-transaction thread ID from the sorted report actions derived value
// When the last action context is resolved
const {lastAction} = resolveLastActionContext(expenseReport, false, undefined, transactionThreadReportID);

// Then the newer action from the transaction thread wins
expect(lastAction?.reportActionID).toBe(threadComment.reportActionID);
});

it('only uses the parent report actions when the report has no one-transaction thread', () => {
// Given the caller has no one-transaction thread for the report (e.g. the derived value has no entry for it)
// When the last action context is resolved without a thread ID
const {lastAction} = resolveLastActionContext(expenseReport, false, undefined, undefined);

// Then only the parent's own actions are considered, because the thread ID is no longer read from a module-level cache
expect(lastAction?.reportActionID).toBe(parentComment.reportActionID);
});
});

describe('getReportAlternateText', () => {
it('should prefix a room comment with the actor display name', () => {
expect(getAlternateText({lastAction: makeAction(CONST.REPORT.ACTIONS.TYPE.ADD_COMMENT)})).toBe('Alice: Fixture last message');
Expand Down
Loading