Skip to content

Refactor ConfirmModal usage to useConfirmModal in workspace accounting and general pages (Part 1)#77919

Open
thelullabyy wants to merge 37 commits intoExpensify:mainfrom
thelullabyy:fix/76692-part-1
Open

Refactor ConfirmModal usage to useConfirmModal in workspace accounting and general pages (Part 1)#77919
thelullabyy wants to merge 37 commits intoExpensify:mainfrom
thelullabyy:fix/76692-part-1

Conversation

@thelullabyy
Copy link
Copy Markdown
Contributor

@thelullabyy thelullabyy commented Dec 17, 2025

Explanation of Change

For the first batch, I refactored these pages:

  • WorkspaceDuplicateSelectFeaturesForm
  • WorkspaceMoreFeaturesPage
  • WorkspaceDowngradePage
  • WorkspacesListPage
  • WorkspaceOverviewPage

Fixed Issues

$ #76692
PROPOSAL: #76692 (comment)

Tests

Test 1: WorkspaceDuplicateSelectFeaturesForm

  1. Login to ND (account has 1 workspace with at least 2 members)
  2. Go to Workspace list
  3. Click "Three dot" --> Duplicate
  4. Enter name --> Next
  5. Press continue
  6. Verify that modal is shown and works proper

Test 2: WorkspaceMoreFeaturesPage

  1. Login to ND (account has 1 workspace with company cards enabled with at least 1 card feed)
  2. Go to Workspace settings --> More features
  3. Turn off company card
  4. Verify that modal is shown and works proper

Test 3: WorkspaceDowngradePage

  1. Login to ND (account has 1 workspace - control plan with at least 2 card feeds)
  2. Go to Workspace settings --> Overview
  3. Downgrade to collect plan
  4. Verify that modal is shown and works proper

Test 4: WorkspacesListPage

  1. Login to ND (account has at least 1 workspace)
  2. Go to Workspace
  3. Delete a workspace
  4. Verify that modal is shown and works proper

Test 5: WorkspaceOverviewPage

  1. Login to ND (account has at least 1 workspace with card feeds)
  2. Go to Workspace
  3. Go to Overview --> Delete workspace
  4. Verify that modal is shown and works proper
  • Verify that no errors appear in the JS console

Offline tests

QA Steps

Please refer to Test part

  • Verify that no errors appear in the JS console

PR Author Checklist

  • I linked the correct issue in the ### Fixed Issues section above
  • I wrote clear testing steps that cover the changes made in this PR
    • I added steps for local testing in the Tests section
    • I added steps for the expected offline behavior in the Offline steps section
    • I added steps for Staging and/or Production testing in the QA steps section
    • I added steps to cover failure scenarios (i.e. verify an input displays the correct error message if the entered data is not correct)
    • I turned off my network connection and tested it while offline to ensure it matches the expected behavior (i.e. verify the default avatar icon is displayed if app is offline)
    • I tested this PR with a High Traffic account against the staging or production API to ensure there are no regressions (e.g. long loading states that impact usability).
  • I included screenshots or videos for tests on all platforms
  • I ran the tests on all platforms & verified they passed on:
    • Android: Native
    • Android: mWeb Chrome
    • iOS: Native
    • iOS: mWeb Safari
    • MacOS: Chrome / Safari
  • I verified there are no console errors (if there's a console error not related to the PR, report it or open an issue for it to be fixed)
  • I verified there are no new alerts related to the canBeMissing param for useOnyx
  • I followed proper code patterns (see Reviewing the code)
    • I verified that any callback methods that were added or modified are named for what the method does and never what callback they handle (i.e. toggleReport and not onIconClick)
    • I verified that comments were added to code that is not self explanatory
    • I verified that any new or modified comments were clear, correct English, and explained "why" the code was doing something instead of only explaining "what" the code was doing.
    • I verified any copy / text shown in the product is localized by adding it to src/languages/* files and using the translation method
      • If any non-english text was added/modified, I used JaimeGPT to get English > Spanish translation. I then posted it in #expensify-open-source and it was approved by an internal Expensify engineer. Link to Slack message:
    • I verified all numbers, amounts, dates and phone numbers shown in the product are using the localization methods
    • I verified any copy / text that was added to the app is grammatically correct in English. It adheres to proper capitalization guidelines (note: only the first word of header/labels should be capitalized), and is either coming verbatim from figma or has been approved by marketing (in order to get marketing approval, ask the Bug Zero team member to add the Waiting for copy label to the issue)
    • I verified proper file naming conventions were followed for any new files or renamed files. All non-platform specific files are named after what they export and are not named "index.js". All platform-specific files are named for the platform the code supports as outlined in the README.
    • I verified the JSDocs style guidelines (in STYLE.md) were followed
  • If a new code pattern is added I verified it was agreed to be used by multiple Expensify engineers
  • I followed the guidelines as stated in the Review Guidelines
  • I tested other components that can be impacted by my changes (i.e. if the PR modifies a shared library or component like Avatar, I verified the components using Avatar are working as expected)
  • I verified all code is DRY (the PR doesn't include any logic written more than once, with the exception of tests)
  • I verified any variables that can be defined as constants (ie. in CONST.ts or at the top of the file that uses the constant) are defined as such
  • I verified that if a function's arguments changed that all usages have also been updated correctly
  • If any new file was added I verified that:
    • The file has a description of what it does and/or why is needed at the top of the file if the code is not self explanatory
  • If a new CSS style is added I verified that:
    • A similar style doesn't already exist
    • The style can't be created with an existing StyleUtils function (i.e. StyleUtils.getBackgroundAndBorderStyle(theme.componentBG))
  • If new assets were added or existing ones were modified, I verified that:
    • The assets are optimized and compressed (for SVG files, run npm run compress-svg)
    • The assets load correctly across all supported platforms.
  • If the PR modifies code that runs when editing or sending messages, I tested and verified there is no unexpected behavior for all supported markdown - URLs, single line code, code blocks, quotes, headings, bold, strikethrough, and italic.
  • If the PR modifies a generic component, I tested and verified that those changes do not break usages of that component in the rest of the App (i.e. if a shared library or component like Avatar is modified, I verified that Avatar is working as expected in all cases)
  • If the PR modifies a component related to any of the existing Storybook stories, I tested and verified all stories for that component are still working as expected.
  • If the PR modifies a component or page that can be accessed by a direct deeplink, I verified that the code functions as expected when the deeplink is used - from a logged in and logged out account.
  • If the PR modifies the UI (e.g. new buttons, new UI components, changing the padding/spacing/sizing, moving components, etc) or modifies the form input styles:
    • I verified that all the inputs inside a form are aligned with each other.
    • I added Design label and/or tagged @Expensify/design so the design team can review the changes.
  • If a new page is added, I verified it's using the ScrollView component to make it scrollable when more elements are added to the page.
  • I added unit tests for any new feature or bug fix in this PR to help automatically prevent regressions in this user flow.
  • If the main branch was merged into this PR after a review, I tested again and verified the outcome was still expected according to the Test steps.

Screenshots/Videos

Android: Native
Screen.Recording.2025-12-23.at.11.51.38.mov
Android: mWeb Chrome
web-android.mov
iOS: Native
ios.mov
iOS: mWeb Safari
web-ios.mov
MacOS: Chrome / Safari
WorkspaceDuplicateSelectFeaturesForm.mov
WorkspaceMoreFeaturesPage.mov
WorkspaceDowngradePage.mov
WorkspacesListPage.mov
WorkspaceOverviewPage.mov

@thelullabyy thelullabyy marked this pull request as ready for review December 17, 2025 18:04
@thelullabyy thelullabyy requested review from a team as code owners December 17, 2025 18:04
@melvin-bot melvin-bot bot requested review from ZhenjaHorbach and joekaufmanexpensify and removed request for a team December 17, 2025 18:04
@melvin-bot
Copy link
Copy Markdown

melvin-bot bot commented Dec 17, 2025

@ZhenjaHorbach Please copy/paste the Reviewer Checklist from here into a new comment on this PR and complete it. If you have the K2 extension, you can simply click: [this button]

@melvin-bot melvin-bot bot removed the request for review from a team December 17, 2025 18:04
@thelullabyy
Copy link
Copy Markdown
Contributor Author

Make it as ready to get reviews from AI reviewer

@codecov
Copy link
Copy Markdown

codecov bot commented Dec 17, 2025

Codecov Report

❌ Looks like you've decreased code coverage for some files. Please write tests to increase, or at least maintain, the existing level of code coverage. See our documentation here for how to interpret this table.

Files with missing lines Coverage Δ
...rc/components/Modal/Global/ConfirmModalWrapper.tsx 100.00% <100.00%> (ø)
src/pages/workspace/downgrade/DowngradeIntro.tsx 0.00% <ø> (ø)
src/hooks/usePayAndDowngrade.ts 64.70% <75.00%> (-18.63%) ⬇️
src/components/Modal/Global/ModalContext.tsx 85.71% <50.00%> (-8.74%) ⬇️
...ges/workspace/downgrade/WorkspaceDowngradePage.tsx 0.00% <0.00%> (ø)
...duplicate/WorkspaceDuplicateSelectFeaturesForm.tsx 0.00% <0.00%> (ø)
src/pages/workspace/WorkspaceOverviewPage.tsx 0.00% <0.00%> (ø)
src/pages/workspace/WorkspaceMoreFeaturesPage.tsx 0.00% <0.00%> (ø)
src/pages/workspace/WorkspacesListPage.tsx 51.41% <15.21%> (-20.29%) ⬇️
... and 9 files with indirect coverage changes

@joekaufmanexpensify
Copy link
Copy Markdown
Contributor

Refactor, removing my review

@joekaufmanexpensify joekaufmanexpensify removed their request for review December 17, 2025 20:57
@thelullabyy
Copy link
Copy Markdown
Contributor Author

Kindly help on review this PR @ZhenjaHorbach

@ZhenjaHorbach
Copy link
Copy Markdown
Contributor

Sorry for delay
@thelullabyy
Could you please fix conflicts?

@ZhenjaHorbach
Copy link
Copy Markdown
Contributor

And don't forget to check this comment

Comment on lines +47 to +48
const canPerformDowngrade = () => canModifyPlan(ownerPolicies, policy);
const isDowngraded = isCollectPolicy(policy);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Why did we remove useMemo?

Copy link
Copy Markdown
Contributor Author

@thelullabyy thelullabyy Jan 12, 2026

Choose a reason for hiding this comment

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

I think we are going to remove useMemo, useCallback soon

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Comment on lines +381 to +387
showConfirmModal({
title: translate('common.leaveWorkspace'),
prompt: confirmModalPrompt(),
confirmText: translate('common.buttonConfirm'),
shouldShowCancelButton: false,
success: true,
});
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Is it okay that this modal doesn't have any event after pressing submit?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Copy link
Copy Markdown
Contributor

@ZhenjaHorbach ZhenjaHorbach Jan 12, 2026

Choose a reason for hiding this comment

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

Looks weird 😅
But okay if it was like this before us

),
confirmText: translate('common.proceed'),
cancelText: translate('common.cancel'),
}).then((result) => {
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I think it is fine to keep using .then here as it requires to update core component SelectionList

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Fair enough

@ZhenjaHorbach
Copy link
Copy Markdown
Contributor

ZhenjaHorbach commented Jan 12, 2026

Reviewer Checklist

  • I have verified the author checklist is complete (all boxes are checked off).
  • I verified the correct issue is linked in the ### Fixed Issues section above
  • I verified testing steps are clear and they cover the changes made in this PR
    • I verified the steps for local testing are in the Tests section
    • I verified the steps for Staging and/or Production testing are in the QA steps section
    • I verified the steps cover any possible failure scenarios (i.e. verify an input displays the correct error message if the entered data is not correct)
    • I turned off my network connection and tested it while offline to ensure it matches the expected behavior (i.e. verify the default avatar icon is displayed if app is offline)
  • I checked that screenshots or videos are included for tests on all platforms
  • I included screenshots or videos for tests on all platforms
  • I verified that the composer does not automatically focus or open the keyboard on mobile unless explicitly intended. This includes checking that returning the app from the background does not unexpectedly open the keyboard.
  • I verified tests pass on all platforms & I tested again on:
    • Android: HybridApp
    • Android: mWeb Chrome
    • iOS: HybridApp
    • iOS: mWeb Safari
    • MacOS: Chrome / Safari
  • If there are any errors in the console that are unrelated to this PR, I either fixed them (preferred) or linked to where I reported them in Slack
  • I verified there are no new alerts related to the canBeMissing param for useOnyx
  • I verified proper code patterns were followed (see Reviewing the code)
    • I verified that any callback methods that were added or modified are named for what the method does and never what callback they handle (i.e. toggleReport and not onIconClick).
    • I verified that comments were added to code that is not self explanatory
    • I verified that any new or modified comments were clear, correct English, and explained "why" the code was doing something instead of only explaining "what" the code was doing.
    • I verified any copy / text shown in the product is localized by adding it to src/languages/* files and using the translation method
    • I verified all numbers, amounts, dates and phone numbers shown in the product are using the localization methods
    • I verified any copy / text that was added to the app is grammatically correct in English. It adheres to proper capitalization guidelines (note: only the first word of header/labels should be capitalized), and is either coming verbatim from figma or has been approved by marketing (in order to get marketing approval, ask the Bug Zero team member to add the Waiting for copy label to the issue)
    • I verified proper file naming conventions were followed for any new files or renamed files. All non-platform specific files are named after what they export and are not named "index.js". All platform-specific files are named for the platform the code supports as outlined in the README.
    • I verified the JSDocs style guidelines (in STYLE.md) were followed
  • If a new code pattern is added I verified it was agreed to be used by multiple Expensify engineers
  • I verified that this PR follows the guidelines as stated in the Review Guidelines
  • I verified other components that can be impacted by these changes have been tested, and I retested again (i.e. if the PR modifies a shared library or component like Avatar, I verified the components using Avatar have been tested & I retested again)
  • I verified all code is DRY (the PR doesn't include any logic written more than once, with the exception of tests)
  • I verified any variables that can be defined as constants (ie. in CONST.ts or at the top of the file that uses the constant) are defined as such
  • If a new component is created I verified that:
    • A similar component doesn't exist in the codebase
    • All props are defined accurately and each prop has a /** comment above it */
    • The file is named correctly
    • The component has a clear name that is non-ambiguous and the purpose of the component can be inferred from the name alone
    • The only data being stored in the state is data necessary for rendering and nothing else
    • For Class Components, any internal methods passed to components event handlers are bound to this properly so there are no scoping issues (i.e. for onClick={this.submit} the method this.submit should be bound to this in the constructor)
    • Any internal methods bound to this are necessary to be bound (i.e. avoid this.submit = this.submit.bind(this); if this.submit is never passed to a component event handler like onClick)
    • All JSX used for rendering exists in the render method
    • The component has the minimum amount of code necessary for its purpose, and it is broken down into smaller components in order to separate concerns and functions
  • If any new file was added I verified that:
    • The file has a description of what it does and/or why is needed at the top of the file if the code is not self explanatory
  • If a new CSS style is added I verified that:
    • A similar style doesn't already exist
    • The style can't be created with an existing StyleUtils function (i.e. StyleUtils.getBackgroundAndBorderStyle(theme.componentBG)
  • If the PR modifies code that runs when editing or sending messages, I tested and verified there is no unexpected behavior for all supported markdown - URLs, single line code, code blocks, quotes, headings, bold, strikethrough, and italic.
  • If the PR modifies a generic component, I tested and verified that those changes do not break usages of that component in the rest of the App (i.e. if a shared library or component like Avatar is modified, I verified that Avatar is working as expected in all cases)
  • If the PR modifies a component related to any of the existing Storybook stories, I tested and verified all stories for that component are still working as expected.
  • If the PR modifies a component or page that can be accessed by a direct deeplink, I verified that the code functions as expected when the deeplink is used - from a logged in and logged out account.
  • If the PR modifies the UI (e.g. new buttons, new UI components, changing the padding/spacing/sizing, moving components, etc) or modifies the form input styles:
    • I verified that all the inputs inside a form are aligned with each other.
    • I added Design label and/or tagged @Expensify/design so the design team can review the changes.
  • If a new page is added, I verified it's using the ScrollView component to make it scrollable when more elements are added to the page.
  • For any bug fix or new feature in this PR, I verified that sufficient unit tests are included to prevent regressions in this flow.
  • If the main branch was merged into this PR after a review, I tested again and verified the outcome was still expected according to the Test steps.
  • I have checked off every checkbox in the PR reviewer checklist, including those that don't apply to this PR.

Screenshots/Videos

Android: HybridApp
2026-01-12.15.57.26.mov
2026-01-12.15.57.59.mov
2026-01-12.15.58.28.mov
2026-01-12.15.59.00.mov
Android: mWeb Chrome
2026-01-12.16.05.09.mov
2026-01-12.16.05.30.mov
2026-01-12.16.05.54.mov
2026-01-12.16.06.28.mov
2026-01-12.16.07.26.mov
iOS: HybridApp
2026-01-12.15.37.40.mov
2026-01-12.15.39.44.mov
2026-01-12.15.40.59.mov
2026-01-12.15.41.21.mov
2026-01-12.15.42.11.mov
iOS: mWeb Safari
MacOS: Chrome / Safari
2026-01-12.14.39.07.mov
2026-01-12.14.41.08.mov
2026-01-12.14.42.26.mov
2026-01-12.14.43.46.mov
2026-01-12.14.48.40.mov
2026-01-12.14.53.16.mov
2026-01-12.14.56.39.mov

@thelullabyy
Copy link
Copy Markdown
Contributor Author

@ZhenjaHorbach Kindly check again. Issues were fixed

@thelullabyy
Copy link
Copy Markdown
Contributor Author

@ZhenjaHorbach Kindly review again

@ZhenjaHorbach
Copy link
Copy Markdown
Contributor

When we delete workspaces we don't show the loader and immediately close the modal

2026-01-12.15.04.29.mov

I still have this issue

@thelullabyy
Copy link
Copy Markdown
Contributor Author

The issue is fixed @ZhenjaHorbach

Screen.Recording.2026-03-23.at.20.55.29.mov

@ZhenjaHorbach
Copy link
Copy Markdown
Contributor

Looks like the current behaviour is not the same as on staging

2026-03-23.19.21.29.mov

But agree that it's impossible to fix without modifying the core component

I think it's better to revert changes for this modal and fix it in a separate PR

@waterim
Maybe you want to take a look and add a loading state for the confirm modal? 😅

@thelullabyy
Copy link
Copy Markdown
Contributor Author

@ZhenjaHorbach conflicts are resolved. Besides, I fixed the mismatch behavior in the modal

Screen.Recording.2026-03-25.at.00.36.08.mov

cancelText: translate('common.cancel'),
success: false,
shouldShowCancelButton: false,
// eslint-disable-next-line react-hooks/refs
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Do we need this?

cancelText: translate('common.cancel'),
success: false,
shouldShowCancelButton: false,
// eslint-disable-next-line react-hooks/refs
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Do we need this?

const {setIsDeletingPaidWorkspace, isLoadingBill}: {setIsDeletingPaidWorkspace: (value: boolean) => void; isLoadingBill: boolean | undefined} =
usePayAndDowngrade(continueDeleteWorkspace);

const hideDeleteWorkspaceErrorModal = useCallback(() => {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I suppose we don't need memoization here

@ZhenjaHorbach
Copy link
Copy Markdown
Contributor

@MelvinBot
Review this PR


// Resolves the modal promise without closing the modal
// Used for async confirmation flows where the modal stays open with loading state
const resolveModal: ModalContextType['resolveModal'] = (data = {action: 'CONFIRM'}) => {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

We can use ModalActions.CONFIRM here instead 'CONFIRM'

}
};

const closeModal: ModalContextType['closeModal'] = (data = {action: 'CLOSE'}) => {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

But let's update here also

@MelvinBot
Copy link
Copy Markdown
Contributor

PR Review

Summary: This PR refactors 5 workspace pages from inline <ConfirmModal> components to the useConfirmModal hook, and adds a new resolveModal mechanism to ModalContext for async confirmation flows (loading state while keeping modal open).

Issues Found

1. canPerformDowngrade changed from useMemo to a plain function call (WorkspaceDowngradePage.tsx)

-const canPerformDowngrade = useMemo(() => canModifyPlan(ownerPolicies, policy), [ownerPolicies, policy]);
+const canPerformDowngrade = () => canModifyPlan(ownerPolicies, policy);

This is now a function reference (always truthy), but later used as:

if (!canPerformDowngrade) {
    return <NotFoundPage />;
}

This guard will never trigger — !canPerformDowngrade is always false because it's a function, not a boolean. The original code evaluated the function and memoized the result. The fix should be const canPerformDowngrade = canModifyPlan(ownerPolicies, policy) (no arrow, no useMemo needed for a simple boolean, but must be a value not a function).

2. confirmModalPrompt is not wrapped in useCallback but listed as a dependency (WorkspaceOverviewPage.tsx)

confirmModalPrompt is a plain function defined inside the component body and used in the useCallback dependency array of handleLeave. This causes handleLeave to be recreated on every render, defeating the purpose of useCallback.

3. handleLeaveWorkspace used in useCallback deps but not wrapped in useCallback (WorkspaceOverviewPage.tsx)

handleLeaveWorkspace is a plain function and is listed as a dependency of handleLeave's useCallback. Same issue — causes re-creation every render.

4. Duplicate error modal logic in WorkspacesListPage.tsx

The same "show error modal" block appears in three places — the useEffect, the prevIsPendingDelete state change block, and both have identical showConfirmModal calls with // eslint-disable-next-line react-hooks/refs comments. Consider extracting to a helper.

5. showConfirmModal called inside render phase (WorkspacesListPage.tsx)

The if (prevIsPendingDelete !== isPendingDelete) block runs during render (it's the "derived state" pattern). Calling showConfirmModal — which calls context.showModal and triggers state updates — during render may cause React warnings or unexpected behavior. The original code only called setIsDeleteWorkspaceErrorModalOpen(true) (a simple state setter, which is safe during render). The new code triggers showModal which does setModalStack(...) on a different component's state during this component's render, which is not safe.

6. Missing accountIDToLogin in continueDeleteWorkspace deps (WorkspacesListPage.tsx)

accountIDToLogin is used inside continueDeleteWorkspace but not listed in the useCallback dependency array.

7. isConfirmLoading prop behavior may not work as expected

In ConfirmModalWrapper, when props.isConfirmLoading !== undefined, handleConfirm calls resolveModal immediately and sets local isConfirmLoading to true. But the passed isConfirmLoading value (isPendingDelete) won't update inside the already-mounted modal because the prop is captured at mount time. The final loading state is isConfirmLoading={isConfirmLoading || props.isConfirmLoading} — the local state isConfirmLoading will be true after confirm, but props.isConfirmLoading won't reactively update since the modal was mounted with the initial value. This needs verification that the modal actually re-renders with updated props when isPendingDelete changes.

8. Test failure: WorkspaceListPageTest.tsx OOM

The failing CI test is tests/ui/WorkspaceListPageTest.tsx which crashes with OOM (out of memory). Since this test exercises WorkspacesListPage which was heavily modified in this PR, this is likely related. The showConfirmModal calls inside the render-phase derived state block (issue #5) could be causing infinite re-renders or modal stacking.

Minor Notes

  • The eslint-disable-next-line react-hooks/refs comments in WorkspacesListPage.tsx appear misplaced (they're on lines that don't access refs)
  • The onDowngradeToTeam function in WorkspaceDowngradePage is now async but the return type annotation on the onDowngrade prop was updated to () => void | Promise<void> — this is fine

Next Steps: Reply with @MelvinBot <your feedback> to discuss any of these findings.


const continueActionRef = useRef(continueAction);
// eslint-disable-next-line react-hooks/refs
continueActionRef.current = continueAction;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Can we add a comment here on why we added this?

@ZhenjaHorbach
Copy link
Copy Markdown
Contributor

@codex review

Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 3603178512

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment on lines 97 to 98
if (!canPerformDowngrade) {
return <NotFoundPage />;
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Call canPerformDowngrade() in permission gates

canPerformDowngrade was changed to a function, but this guard now checks the function object instead of its boolean result. Because function references are always truthy, the NotFound guard is bypassed and non-authorized users can still access downgrade UI/flows (the same pattern is also used in onDowngradeToTeam). This regresses the permission check that previously blocked users who cannot modify the plan.

Useful? React with 👍 / 👎.

Comment on lines +459 to +463
}).then((result) => {
if (result.action !== ModalActions.CONFIRM) {
return;
}
confirmLeaveAndHideModal();
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Use selected policy directly in leave confirm callback

This confirm handler closes over confirmLeaveAndHideModal from the same render where setPolicyIDToLeave(item.policyID) was just dispatched, so it can run with stale policyToLeave data (often undefined, or a previously selected workspace). In that case pressing confirm does nothing or targets the wrong workspace. The previous modal-state flow re-rendered before confirm, so this is a regression in the leave action path.

Useful? React with 👍 / 👎.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants