Skip to content
Open
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
10 changes: 0 additions & 10 deletions src/libs/actions/Policy/Policy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,7 @@
};

const deprecatedAllPolicies: OnyxCollection<Policy> = {};
Onyx.connect({

Check warning on line 241 in src/libs/actions/Policy/Policy.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.POLICY,
callback: (val, key) => {
if (!key) {
Expand All @@ -254,7 +254,7 @@
});

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

Check warning on line 257 in src/libs/actions/Policy/Policy.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 @@ -264,7 +264,7 @@

let deprecatedSessionEmail = '';
let deprecatedSessionAccountID = 0;
Onyx.connect({

Check warning on line 267 in src/libs/actions/Policy/Policy.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: (val) => {
deprecatedSessionEmail = val?.email ?? '';
Expand All @@ -273,7 +273,7 @@
});

let deprecatedAllPersonalDetails: OnyxEntry<PersonalDetailsList>;
Onyx.connect({

Check warning on line 276 in src/libs/actions/Policy/Policy.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: (val) => (deprecatedAllPersonalDetails = val),
});
Expand Down Expand Up @@ -2062,14 +2062,6 @@
});
}

function hideWorkspaceAlertMessage(policyID: string) {
if (!deprecatedAllPolicies?.[policyID]) {
return;
}

Onyx.merge(`${ONYXKEYS.COLLECTION.POLICY}${policyID}`, {alertMessage: ''});
}

function updateAddress(policyID: string, newAddress: CompanyAddress) {
const parameters: UpdatePolicyAddressParams = {
policyID,
Expand Down Expand Up @@ -3865,7 +3857,6 @@

function clearErrors(policyID: string) {
Onyx.merge(`${ONYXKEYS.COLLECTION.POLICY}${policyID}`, {errors: null});
hideWorkspaceAlertMessage(policyID);
}

/**
Expand Down Expand Up @@ -7084,7 +7075,6 @@
leaveWorkspace,
addBillingCardAndRequestPolicyOwnerChange,
hasActiveChatEnabledPolicies,
hideWorkspaceAlertMessage,
deleteWorkspace,
updateAddress,
updateLastAccessedWorkspace,
Expand Down
8 changes: 2 additions & 6 deletions src/pages/workspace/WorkspaceInvitePage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -178,10 +178,7 @@ function WorkspaceInvitePage({route, policy}: WorkspaceInvitePageProps) {
Navigation.navigate(ROUTES.WORKSPACE_INVITE_MESSAGE.getRoute(route.params.policyID, Navigation.getActiveRoute()));
}, [route.params.policyID, selectedOptions]);

const [policyName, shouldShowAlertPrompt] = useMemo(
() => [policy?.name ?? '', !isEmptyObject(policy?.errors) || !!policy?.alertMessage],
[policy?.name, policy?.errors, policy?.alertMessage],
);
const [policyName, shouldShowAlertPrompt] = useMemo(() => [policy?.name ?? '', !isEmptyObject(policy?.errors)], [policy?.name, policy?.errors]);

Choose a reason for hiding this comment

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

P2 Badge Keep invite-page alerts driven by policy.alertMessage

OpenWorkspaceInvitePage() can populate a standalone policy.alertMessage for invite-specific warnings; the old code even had a dedicated hideWorkspaceAlertMessage() cleanup path, which implies it is not always paired with policy.errors. After this change shouldShowAlertPrompt only checks policy.errors, so those server-provided warnings no longer render at all, and dropping the message prop means FormAlertWrapper falls back to its generic error copy whenever an alert is shown. In the workspace invite flow that hides the actual reason the user needs to adjust the invite list.

Useful? React with 👍 / 👎.


const headerMessage = useMemo(() => {
const searchValue = debouncedSearchTerm.trim().toLowerCase();
Expand Down Expand Up @@ -214,12 +211,11 @@ function WorkspaceInvitePage({route, policy}: WorkspaceInvitePageProps) {
isAlertVisible={shouldShowAlertPrompt}
buttonText={translate('common.next')}
onSubmit={inviteUser}
message={policy?.alertMessage ?? ''}
containerStyles={[styles.flexReset, styles.flexGrow0, styles.flexShrink0, styles.flexBasisAuto]}
enabledWhenOffline
/>
),
[inviteUser, policy?.alertMessage, selectedOptions.length, shouldShowAlertPrompt, styles.flexBasisAuto, styles.flexGrow0, styles.flexReset, styles.flexShrink0, translate],
[inviteUser, selectedOptions.length, shouldShowAlertPrompt, styles.flexBasisAuto, styles.flexGrow0, styles.flexReset, styles.flexShrink0, translate],
);

useEffect(() => {
Expand Down
3 changes: 0 additions & 3 deletions src/types/onyx/Policy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1898,9 +1898,6 @@ type Policy = OnyxCommon.OnyxValueWithOfflineFeedback<
/** Original file name which is used for the policy avatar */
originalFileName?: string;

/** Alert message for the policy */
alertMessage?: string;

/** Informative messages about which policy members were added with primary logins when invited with their secondary login */
primaryLoginsInvited?: Record<string, string>;

Expand Down
Loading