Skip to content

fix: Onboarding - Onboarding tasks in #admins room are grayed out in offline mode. #60973

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

Merged
merged 8 commits into from
May 7, 2025
Merged
Show file tree
Hide file tree
Changes from 6 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
8 changes: 4 additions & 4 deletions src/libs/ReportUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9844,7 +9844,7 @@ function prepareOnboardingOnyxData(
onyxMethod: Onyx.METHOD.MERGE,
key: `${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${targetChatReportID}`,
value: {
[taskReportAction.reportAction.reportActionID]: {pendingAction: null},
[taskReportAction.reportAction.reportActionID]: {pendingAction: null, isOptimisticAction: null},
},
},
{
Expand Down Expand Up @@ -9880,7 +9880,7 @@ function prepareOnboardingOnyxData(
onyxMethod: Onyx.METHOD.MERGE,
key: `${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${currentTask.reportID}`,
value: {
[completedTaskReportAction.reportActionID]: {pendingAction: null},
[completedTaskReportAction.reportActionID]: {pendingAction: null, isOptimisticAction: null},
},
});
}
Expand Down Expand Up @@ -9938,7 +9938,7 @@ function prepareOnboardingOnyxData(
onyxMethod: Onyx.METHOD.MERGE,
key: `${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${targetChatReportID}`,
value: {
[textCommentAction.reportActionID]: {pendingAction: null},
[textCommentAction.reportActionID]: {pendingAction: null, isOptimisticAction: null},
},
});
}
Expand Down Expand Up @@ -10126,7 +10126,7 @@ function prepareOnboardingOnyxData(
onyxMethod: Onyx.METHOD.MERGE,
key: `${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${targetChatReportID}`,
value: {
[welcomeSignOffCommentAction.reportActionID]: {pendingAction: null},
[welcomeSignOffCommentAction.reportActionID]: {pendingAction: null, isOptimisticAction: null},
},
});

Expand Down
42 changes: 42 additions & 0 deletions tests/actions/ReportTest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ describe('actions/Report', () => {
beforeEach(() => {
HttpUtils.xhr = originalXHR;
const promise = Onyx.clear().then(jest.useRealTimers);

if (getIsUsingFakeTimers()) {
// flushing pending timers
// Onyx.clear() promise is resolved in batch which happens after the current microtasks cycle
Expand Down Expand Up @@ -1606,4 +1607,45 @@ describe('actions/Report', () => {
expect(derivedConciergeChatReportID).toBe(conciergeChatReport2.reportID);
});
});

describe('completeOnboarding', () => {
const TEST_USER_LOGIN = '[email protected]';
const TEST_USER_ACCOUNT_ID = 1;
global.fetch = TestHelper.getGlobalFetchMock();

it('should set "isOptimisticAction" to false/null for all actions in admins report after completing onboarding setup', async () => {
await Onyx.set(ONYXKEYS.SESSION, {email: TEST_USER_LOGIN, accountID: TEST_USER_ACCOUNT_ID});
await waitForBatchedUpdates();

const adminsChatReportID = '7957055873634067';
const onboardingPolicyID = 'A70D00C752416807';
const engagementChoice = CONST.INTRO_CHOICES.MANAGE_TEAM;

Report.completeOnboarding({
engagementChoice,
onboardingMessage: CONST.ONBOARDING_MESSAGES.newDotManageTeam,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
onboardingMessage: CONST.ONBOARDING_MESSAGES.newDotManageTeam,
onboardingMessage: CONST.ONBOARDING_MESSAGES[engagementChoice],

adminsChatReportID,
onboardingPolicyID,
companySize: '1-10',
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
companySize: '1-10',
companySize: CONST.ONBOARDING_COMPANY_SIZE.MICRO,

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sorry for overlooking. Updated.

userReportedIntegration: null,
});

await waitForBatchedUpdates();

const reportActions: OnyxEntry<OnyxTypes.ReportActions> = await new Promise((resolve) => {
const connection = Onyx.connect({
key: `${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${adminsChatReportID}`,
callback: (id) => {
Onyx.disconnect(connection);
resolve(id);
},
});
});
expect(reportActions).not.toBeNull();
expect(reportActions).not.toBeUndefined();
Object.values(reportActions ?? {}).forEach((action) => {
expect(action.isOptimisticAction).toBeFalsy();
});
});
});
});
Loading