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
4 changes: 4 additions & 0 deletions src/libs/OptionsListUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,7 @@
shouldSeparateSelfDMChat?: boolean;
excludeNonAdminWorkspaces?: boolean;
isPerDiemRequest?: boolean;
showRBR?: boolean;
} & GetValidOptionsSharedConfig;

type GetValidReportsReturnTypeCombined = {
Expand Down Expand Up @@ -321,7 +322,7 @@
* methods should be named for the views they build options for and then exported for use in a component.
*/
let currentUserLogin: string | undefined;
let currentUserAccountID: number | undefined;

Check warning on line 325 in src/libs/OptionsListUtils.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
Onyx.connect({
key: ONYXKEYS.SESSION,
callback: (value) => {
Expand All @@ -330,19 +331,19 @@
},
});

let loginList: OnyxEntry<Login>;

Check warning on line 334 in src/libs/OptionsListUtils.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
Onyx.connect({
key: ONYXKEYS.LOGIN_LIST,
callback: (value) => (loginList = isEmptyObject(value) ? {} : value),
});

let allPersonalDetails: OnyxEntry<PersonalDetailsList>;

Check warning on line 340 in src/libs/OptionsListUtils.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
Onyx.connect({
key: ONYXKEYS.PERSONAL_DETAILS_LIST,
callback: (value) => (allPersonalDetails = isEmptyObject(value) ? {} : value),
});

const policies: OnyxCollection<Policy> = {};

Check warning on line 346 in src/libs/OptionsListUtils.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
Onyx.connect({
key: ONYXKEYS.COLLECTION.POLICY,
callback: (policy, key) => {
Expand All @@ -354,14 +355,14 @@
},
});

let allPolicies: OnyxCollection<Policy> = {};

Check warning on line 358 in src/libs/OptionsListUtils.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
Onyx.connect({
key: ONYXKEYS.COLLECTION.POLICY,
waitForCollectionCallback: true,
callback: (val) => (allPolicies = val),
});

let allReports: OnyxCollection<Report>;

Check warning on line 365 in src/libs/OptionsListUtils.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
Onyx.connect({
key: ONYXKEYS.COLLECTION.REPORT,
waitForCollectionCallback: true,
Expand All @@ -370,7 +371,7 @@
},
});

let allReportNameValuePairs: OnyxCollection<ReportNameValuePairs>;

Check warning on line 374 in src/libs/OptionsListUtils.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
Onyx.connect({
key: ONYXKEYS.COLLECTION.REPORT_NAME_VALUE_PAIRS,
waitForCollectionCallback: true,
Expand All @@ -382,7 +383,7 @@
const lastReportActions: ReportActions = {};
const allSortedReportActions: Record<string, ReportAction[]> = {};
let allReportActions: OnyxCollection<ReportActions>;
const lastVisibleReportActions: ReportActions = {};

Check warning on line 386 in src/libs/OptionsListUtils.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
Onyx.connect({
key: ONYXKEYS.COLLECTION.REPORT_ACTIONS,
waitForCollectionCallback: true,
Expand Down Expand Up @@ -441,13 +442,13 @@
});
},
});

Check warning on line 445 in src/libs/OptionsListUtils.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
let activePolicyID: OnyxEntry<string>;
Onyx.connect({
key: ONYXKEYS.NVP_ACTIVE_POLICY_ID,
callback: (value) => (activePolicyID = value),
});

Check warning on line 451 in src/libs/OptionsListUtils.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
let nvpDismissedProductTraining: OnyxEntry<DismissedProductTraining>;
Onyx.connect({
key: ONYXKEYS.NVP_DISMISSED_PRODUCT_TRAINING,
Expand Down Expand Up @@ -1049,6 +1050,7 @@
option.isDisabled = isDraftReport(participant.reportID);
option.selected = participant.selected;
option.isSelected = participant.selected;
option.brickRoadIndicator = null;
return option;
}

Expand Down Expand Up @@ -1584,6 +1586,7 @@
shouldSeparateWorkspaceChat,
excludeNonAdminWorkspaces,
isPerDiemRequest = false,
showRBR = true,
} = config;
const topmostReportId = Navigation.getTopmostReportId();

Expand Down Expand Up @@ -1730,6 +1733,7 @@
isSelected,
isBold,
lastIOUCreationDate,
brickRoadIndicator: showRBR ? option.brickRoadIndicator : null,
};

if (shouldSeparateWorkspaceChat && newReportOption.isOwnPolicyExpenseChat && !newReportOption.private_isArchived) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,7 @@ function MoneyRequestParticipantsSelector({
includeSelfDM: !isMovingTransactionFromTrackExpense(action) && iouType !== CONST.IOU.TYPE.INVOICE,
canShowManagerMcTest: !hasBeenAddedToNudgeMigration && action !== CONST.IOU.ACTION.SUBMIT,
isPerDiemRequest,
showRBR: false,
},
);

Expand Down
92 changes: 92 additions & 0 deletions tests/unit/OptionsListUtilsTest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -801,6 +801,98 @@ describe('OptionsListUtils', () => {
// Then the result should include the admin room
expect(adminRoomOption).toBeDefined();
});

it('should include brickRoadIndicator if showRBR is true', () => {
const reportID = '1455140530846319';
const workspaceChat: SearchOption<Report> = {
item: {
chatType: CONST.REPORT.CHAT_TYPE.POLICY_EXPENSE_CHAT,
currency: 'USD',
errorFields: {},
lastActionType: 'CREATED',
lastReadTime: '2025-03-21 07:25:46.279',
lastVisibleActionCreated: '2024-12-15 21:13:24.317',
lastVisibleActionLastModified: '2024-12-15 21:13:24.317',
ownerAccountID: 0,
permissions: ['read', 'write'],
participants: {1: {notificationPreference: 'always'}},
policyID: '52A5ABD88FBBD18F',
policyName: "A's Workspace",
reportID,
reportName: "A's Workspace chat",
type: 'chat',
writeCapability: 'all',
},
text: "A's Workspace chat",
alternateText: "A's Workspace",
allReportErrors: {},
subtitle: "A's Workspace",
participantsList: [],
reportID,
keyForList: '1455140530846319',
isDefaultRoom: true,
isChatRoom: true,
policyID: '52A5ABD88FBBD18F',
lastMessageText: '',
lastVisibleActionCreated: '2024-12-15 21:13:24.317',
notificationPreference: 'hidden',
brickRoadIndicator: CONST.BRICK_ROAD_INDICATOR_STATUS.ERROR,
};
const results = getValidOptions(
{reports: [workspaceChat], personalDetails: []},
{
includeMultipleParticipantReports: true,
showRBR: true,
},
);
expect(results.recentReports.at(0)?.brickRoadIndicator).toBe(CONST.BRICK_ROAD_INDICATOR_STATUS.ERROR);
});

it('should not include brickRoadIndicator if showRBR is false', () => {
const reportID = '1455140530846319';
const workspaceChat: SearchOption<Report> = {
item: {
chatType: CONST.REPORT.CHAT_TYPE.POLICY_EXPENSE_CHAT,
currency: 'USD',
errorFields: {},
lastActionType: 'CREATED',
lastReadTime: '2025-03-21 07:25:46.279',
lastVisibleActionCreated: '2024-12-15 21:13:24.317',
lastVisibleActionLastModified: '2024-12-15 21:13:24.317',
ownerAccountID: 0,
permissions: ['read', 'write'],
participants: {1: {notificationPreference: 'always'}},
policyID: '52A5ABD88FBBD18F',
policyName: "A's Workspace",
reportID,
reportName: "A's Workspace chat",
type: 'chat',
writeCapability: 'all',
},
text: "A's Workspace chat",
alternateText: "A's Workspace",
allReportErrors: {},
subtitle: "A's Workspace",
participantsList: [],
reportID,
keyForList: '1455140530846319',
isDefaultRoom: true,
isChatRoom: true,
policyID: '52A5ABD88FBBD18F',
lastMessageText: '',
lastVisibleActionCreated: '2024-12-15 21:13:24.317',
notificationPreference: 'hidden',
brickRoadIndicator: CONST.BRICK_ROAD_INDICATOR_STATUS.ERROR,
};
const results = getValidOptions(
{reports: [workspaceChat], personalDetails: []},
{
includeMultipleParticipantReports: true,
showRBR: false,
},
);
expect(results.recentReports.at(0)?.brickRoadIndicator).toBe(null);
});
});

describe('getValidOptions() for chat room', () => {
Expand Down
Loading