Skip to content

[HOLD Web-Expensify#52112] Replace individual private detail edit pages with unified form + magic code#87928

Open
jasperhuangg wants to merge 19 commits intomainfrom
jasper-securePrivatePersonalDetails
Open

[HOLD Web-Expensify#52112] Replace individual private detail edit pages with unified form + magic code#87928
jasperhuangg wants to merge 19 commits intomainfrom
jasper-securePrivatePersonalDetails

Conversation

@jasperhuangg
Copy link
Copy Markdown
Contributor

@jasperhuangg jasperhuangg commented Apr 14, 2026

Explanation of Change

Replaces the four individual edit pages for private personal details (legal name, DOB, phone, address) with a single unified form that requires magic code verification when any field changes. This prevents session hijackers from silently modifying sensitive personal information.

New pages:

  • PrivatePersonalDetailsPage - Unified form showing all private detail fields, pre-populated from Onyx. Validates that previously-set fields aren't emptied. On submit, detects changes and navigates to magic code confirmation.
  • PrivatePersonalDetailsConfirmMagicCodePage - Uses ValidateCodeActionContent to collect a magic code, then calls updatePrivatePersonalDetails() to submit all changes in a single API call.

API changes:

  • New UPDATE_PRIVATE_PERSONAL_DETAILS write command with optimistic/success/failure data
  • New updatePrivatePersonalDetails() action in PersonalDetails.ts

Navigation changes:

  • ProfilePage updated so all four private detail rows navigate to the unified form
  • New routes, screens, linking config, and RHP relations registered

Depends on Auth PR and Web-Expensify PR.

Fixed Issues

part of https://github.com/Expensify/Expensify/issues/623849
PROPOSAL:

Tests

  1. Go to Settings > Profile
  2. Tap any of: Legal Name, Date of Birth, Phone Number, Address
  3. Verify you're taken to the new unified Private Personal Details form
  4. Verify all fields are pre-populated with your current data
  5. Without changing anything, tap Save — verify no magic code is required
  6. Change one or more fields, tap Save
  7. Verify you're navigated to the magic code page
  8. Enter a valid magic code
  9. Verify details are updated and you're navigated back
  • Verify that no errors appear in the JS console

Offline tests

  1. Go offline
  2. Navigate to the unified Private Personal Details form
  3. Verify the form loads with cached data from Onyx
  4. Make a change and submit
  5. Verify the optimistic update shows immediately
  6. Go back online and verify the update syncs

QA Steps

Same as Tests section above.

  • 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 tested this PR with a High Traffic account against the staging or production API
  • 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
  • I followed proper code patterns
    • I verified that any callback methods that were added or modified are named for what the method does
    • I verified that comments were added to code that is not self explanatory
    • I verified any new or modified comments were clear, correct English
    • I verified any copy / text shown in the product is localized
    • I verified all numbers, amounts, dates and phone numbers shown in the product are using the localization methods
    • I verified proper file naming conventions were followed
    • I verified the JSDocs style guidelines were followed
  • I verified all code is DRY
  • I verified any variables that can be defined as constants are defined as such
  • I verified that if a function's arguments changed that all usages have also been updated correctly
  • I verified that similar component doesn't exist in the codebase
  • I verified that all props are defined accurately and each prop has a /** comment above it */
  • I verified that each file is named correctly
  • I verified that each component has a clear name that is non-ambiguous and the purpose of the component can be inferred from the name alone
  • I verified that the only data being stored in component state is data necessary for rendering and nothing else
  • In component if we are not using the full Onyx data that we loaded, I've added the proper selector in order to ensure the component only re-renders when the data it is using changes
  • 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)
  • I verified that component 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)
  • I verified that all JSX used for rendering exists in the render method
  • I verified that each 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

Screenshots/Videos

Android: Native
Android: mWeb Chrome
iOS: Native
iOS: mWeb Safari
MacOS: Chrome / Safari

Made with Cursor

Adds the API plumbing for the new unified personal details update:
- UPDATE_PRIVATE_PERSONAL_DETAILS write command
- UpdatePrivatePersonalDetailsParams type (all personal detail fields +
  validateCode)
- updatePrivatePersonalDetails() action with optimistic/success/failure
  data that sets isLoading on PRIVATE_PERSONAL_DETAILS

Part of Expensify/Expensify#623849.

Made-with: Cursor
Registers two new screens in the Settings RHP:
- PRIVATE_PERSONAL_DETAILS: unified edit form for all private fields
- PRIVATE_PERSONAL_DETAILS_CONFIRM_MAGIC_CODE: magic code verification

Adds routes, screen constants, navigation param types, linking config,
and Settings-to-RHP relations.

Part of Expensify/Expensify#623849.

Made-with: Cursor
PrivatePersonalDetailsPage: single form with all private fields (legal
name, DOB, phone, address). Pre-populates from PRIVATE_PERSONAL_DETAILS,
validates that previously-set fields cannot be emptied, and navigates to
magic code confirmation when any field changes.

PrivatePersonalDetailsConfirmMagicCodePage: uses ValidateCodeActionContent
to collect a magic code, then calls updatePrivatePersonalDetails() to
submit all changes in a single validate-code-protected API call.

Part of Expensify/Expensify#623849.

Made-with: Cursor
All four private detail rows (legal name, DOB, phone, address) now
navigate to the unified PrivatePersonalDetailsPage instead of individual
edit pages. The individual pages are kept for backward compatibility with
deep links.

Part of Expensify/Expensify#623849.

Made-with: Cursor
@jasperhuangg jasperhuangg requested review from a team as code owners April 14, 2026 20:03
@melvin-bot melvin-bot Bot requested review from DylanDylann and removed request for a team April 14, 2026 20:03
@melvin-bot
Copy link
Copy Markdown

melvin-bot Bot commented Apr 14, 2026

@DylanDylann 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 requested review from trjExpensify and removed request for a team April 14, 2026 20:03
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: 5a14d480bd

ℹ️ About Codex in GitHub

Your team has set up Codex to 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 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +57 to +60
const handleSubmitForm = useCallback(
(validateCode: string) => {
updatePrivatePersonalDetails(values, validateCode, countryCode);
},
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 Add success navigation after private-details code submit

After handleSubmitForm calls updatePrivatePersonalDetails, this page never observes a successful update to close itself or return to the form/profile. That leaves users on the magic-code screen after a valid code (and offline submits can appear stuck while isLoading remains true), unlike other validate-code flows that navigate away when the action succeeds.

Useful? React with 👍 / 👎.

Comment on lines +109 to +113
// Country: required if previously set
const countryValue = values[INPUT_IDS.COUNTRY] ?? '';
if (country && !countryValue) {
errors[INPUT_IDS.COUNTRY] = translate('common.error.fieldRequired');
}
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Validate state and ZIP before allowing address update

The new validator only enforces required checks for street, city, and country, but not state or zipPostCode. For users who already have a populated address, clearing state or ZIP still passes client validation and gets submitted in the consolidated update call, which can silently erase address data or force a server-side failure after code verification.

Useful? React with 👍 / 👎.

@codecov
Copy link
Copy Markdown

codecov Bot commented Apr 14, 2026

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 Δ
src/SCREENS.ts 100.00% <ø> (ø)
src/libs/API/types.ts 100.00% <ø> (ø)
...igation/linkingConfig/RELATIONS/SETTINGS_TO_RHP.ts 100.00% <ø> (ø)
src/libs/Navigation/linkingConfig/config.ts 76.92% <ø> (ø)
src/ROUTES.ts 16.68% <0.00%> (+0.08%) ⬆️
src/pages/settings/Profile/ProfilePage.tsx 94.73% <83.33%> (+3.71%) ⬆️
...gation/AppNavigator/ModalStackNavigators/index.tsx 6.95% <0.00%> (-0.03%) ⬇️
src/libs/PersonalDetailsUtils.ts 77.52% <0.00%> (-6.62%) ⬇️
src/libs/actions/PersonalDetails.ts 43.63% <0.00%> (-6.37%) ⬇️
...ils/PrivatePersonalDetailsConfirmMagicCodePage.tsx 0.00% <0.00%> (ø)
... and 1 more
... and 209 files with indirect coverage changes

Convert SETTINGS_PRIVATE_PERSONAL_DETAILS from a plain string to
an object with getRoute(fieldToFocus?) so callers can specify
which field to auto-focus when the form opens. Update the
linking config and navigation types accordingly.

Made-with: Cursor
Each private detail row in ProfilePage now passes its
corresponding INPUT_ID so the form auto-focuses the tapped
field: legal name, DOB, phone number, or address.

Made-with: Cursor
Read the fieldToFocus query param and set autoFocus on the
matching InputWrapper. For the DatePicker (DOB), autoFocus
triggers the calendar modal to open immediately.

Made-with: Cursor
After the private personal details update succeeds (isLoading
transitions from true to false with no errors), navigate back
to the Profile settings page instead of the intermediate form.

Made-with: Cursor
When the user edits fields but navigates away without submitting,
the draft values were persisted via shouldSaveDraft. Now we call
clearDraftValues on unmount so the form always resets to the
current saved values when reopened.

Made-with: Cursor
@jasperhuangg jasperhuangg marked this pull request as draft April 14, 2026 23:42
Check both privatePersonalDetails.errors and
validateCodeAction.errorFields before navigating back to
Profile. Invalid magic code errors are stored on the
validateCodeAction key, not privatePersonalDetails.

Made-with: Cursor
The server sets validate code errors on
PRIVATE_PERSONAL_DETAILS.errorFields.personalDetails via
Onyx::handleException, but the component was reading from
.errors which is never populated. Use getLatestErrorField to
read from the correct path so errors are displayed and the
success navigation doesn't fire on failure.

Made-with: Cursor
@jasperhuangg jasperhuangg changed the title Replace individual private detail edit pages with unified form + magic code [HOLD Web-Expensify#52112] Replace individual private detail edit pages with unified form + magic code Apr 15, 2026
@jasperhuangg
Copy link
Copy Markdown
Contributor Author

@MelvinBot pull main on this PR

…ersonalDetails

Co-authored-by: Jasper Huang <jasperhuangg@users.noreply.github.com>
@MelvinBot
Copy link
Copy Markdown
Contributor

Merged main into this branch. ✅

- Add 'Basic details' and 'Address' section headers with sectionTitle style
- Replace Country text input with CountrySelector picker component
- Add basicDetails translation key to all language files

Made-with: Cursor
@OSBotify
Copy link
Copy Markdown
Contributor

🦜 Polyglot Parrot! 🦜

Squawk! Looks like you added some shiny new English strings. Allow me to parrot them back to you in other tongues:

View the translation diff
diff --git a/src/languages/fr.ts b/src/languages/fr.ts
index f115885e..50bf5895 100644
--- a/src/languages/fr.ts
+++ b/src/languages/fr.ts
@@ -3261,7 +3261,7 @@ ${amount} pour ${merchant} - ${date}`,
         enterPhoneNumber: 'Quel est votre numéro de téléphone ?',
         personalDetails: 'Informations personnelles',
         privateDataMessage: 'Ces informations sont utilisées pour les déplacements et les paiements. Elles ne s’affichent jamais sur votre profil public.',
-        basicDetails: 'Informations de base',
+        basicDetails: 'Détails de base',
         legalName: 'Nom légal',
         legalFirstName: 'Prénom légal',
         legalLastName: 'Nom de famille légal',

Note

You can apply these changes to your branch by copying the patch to your clipboard, then running pbpaste | git apply 😉

View workflow run

@jasperhuangg jasperhuangg marked this pull request as ready for review April 16, 2026 18:45
},
[],
);

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.

❌ CLEAN-REACT-PATTERNS-0 (docs)

React Compiler is enabled in this codebase and automatically memoizes closures based on their captured variables. The useCallback wrapper around validate is redundant and adds maintenance overhead with the manual dependency array. Similar existing pages in this directory (e.g., PersonalAddressPage.tsx) compile successfully with React Compiler.

Remove useCallback and define validate as a plain function:

const validate = (values: FormOnyxValues<typeof ONYXKEYS.FORMS.PERSONAL_DETAILS_FORM>): FormInputErrors<typeof ONYXKEYS.FORMS.PERSONAL_DETAILS_FORM> => {
    // ... validation logic unchanged
};

Apply the same change to hasChanges (line 135) and onSubmit (line 172) in this file.


Reviewed at: f486a7b | Please rate this suggestion with 👍 or 👎 to help us improve! Reactions are used to monitor reviewer efficiency.

const legalFirstName = privatePersonalDetails?.legalFirstName ?? '';
const legalLastName = privatePersonalDetails?.legalLastName ?? '';
const phoneNumber = privatePersonalDetails?.phoneNumber ?? '';
const dob = privatePersonalDetails?.dob ?? '';
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.

❌ CLEAN-REACT-PATTERNS-0 (docs)

React Compiler is enabled and automatically caches derived values. The useMemo wrapper around the address computation is redundant.

Remove useMemo and compute address directly:

const address = normalizeCountryCode(getCurrentAddress(privatePersonalDetails)) as Address | undefined;

Reviewed at: f486a7b | Please rate this suggestion with 👍 or 👎 to help us improve! Reactions are used to monitor reviewer efficiency.

if (wasLoading.current && !hasErrors) {
wasLoading.current = false;
resetValidateActionCodeSent();
Navigation.goBack(ROUTES.SETTINGS_PROFILE.route);
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.

❌ CLEAN-REACT-PATTERNS-0 (docs)

React Compiler is enabled and automatically caches derived values and closures. The useMemo on line 64 and useCallback on line 66 are redundant.

Remove both manual memoization wrappers:

const values = normalizeCountryCode(getFormValues(privatePersonalDetails, draftValues)) as PersonalDetailsForm;

const handleSubmitForm = (validateCode: string) => {
    updatePrivatePersonalDetails(values, validateCode, countryCode);
};

Reviewed at: f486a7b | Please rate this suggestion with 👍 or 👎 to help us improve! Reactions are used to monitor reviewer efficiency.

);

const reasonAttributes: SkeletonSpanReasonAttributes = {context: 'PrivatePersonalDetailsPage', isLoadingApp};

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.

❌ UI-1 (docs)

FullScreenLoadingIndicator is used as an early return when isLoadingApp is true. In this code path, no navigation component (e.g., HeaderWithBackButton) is rendered, so the user has no way to escape if loading hangs.

Add shouldUseGoBackButton to provide an emergency escape route:

return <FullScreenLoadingIndicator reasonAttributes={reasonAttributes} shouldUseGoBackButton />;

Reviewed at: f486a7b | Please rate this suggestion with 👍 or 👎 to help us improve! Reactions are used to monitor reviewer efficiency.

import type {PersonalDetailsForm} from '@src/types/form';
import INPUT_IDS from '@src/types/form/PersonalDetailsForm';
import {isEmptyObject} from '@src/types/utils/EmptyObject';

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.

❌ CONSISTENCY-3 (docs)

The getFormValues helper (lines 18-30) duplicates address extraction logic that also appears in PrivatePersonalDetailsPage.tsx (lines 42-53). Both call getCurrentAddress(privatePersonalDetails), split street by \n, and extract the same set of fields (legalFirstName, legalLastName, dob, phoneNumber, address fields) with the same fallback patterns.

Extract a shared utility function (e.g., in PersonalDetailsUtils.ts) that converts privatePersonalDetails into a PersonalDetailsForm shape, and use it from both pages. The confirm page can then merge draft overrides on top of the shared result.


Reviewed at: f486a7b | Please rate this suggestion with 👍 or 👎 to help us improve! Reactions are used to monitor reviewer efficiency.

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: f486a7b649

ℹ️ About Codex in GitHub

Your team has set up Codex to 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 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

<InputWrapper
InputComponent={CountrySelector}
inputID={INPUT_IDS.COUNTRY}
value={country}
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 Bind country selector to editable form state

This field is wired as a controlled input with value={country} from the initial Onyx snapshot, but there is no onValueChange updating that source. In FormProvider, any defined value is reapplied to form state on each render, so user selections get overwritten and the country cannot actually be changed from this unified form. Use a form-managed default/uncontrolled value or update a local state value in onValueChange before passing it back.

Useful? React with 👍 / 👎.

const primaryLogin = usePrimaryContactMethod();

const [validateCodeAction] = useOnyx(ONYXKEYS.VALIDATE_ACTION_CODE);
const personalDetailsError = getLatestErrorField(privatePersonalDetails, 'personalDetails');
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 Read submit errors from errors before treating update as success

This page reads personalDetailsError from errorFields.personalDetails, but this flow’s helpers and related magic-code flow use PRIVATE_PERSONAL_DETAILS.errors for submission failures. If the backend writes a failure into errors, hasErrors remains false and the success effect can navigate back after loading, hiding the failed update from the user. Check errors (or both sources) when computing submit failure state.

Useful? React with 👍 / 👎.

@jasperhuangg jasperhuangg requested a review from rafecolton April 16, 2026 20:58
- Bind CountrySelector to local state with onValueChange so picker
  selections persist across renders (P1)
- Validate state and zip as required when previously set (P2)
- Add shouldUseGoBackButton to FullScreenLoadingIndicator so users
  can escape a hung loading state (UI-1)
- Remove redundant useCallback/useMemo wrappers now that React
  Compiler handles memoization (CLEAN-REACT-PATTERNS-0)
- Extract shared getPrivatePersonalDetailsFormValues helper into
  PersonalDetailsUtils (CONSISTENCY-3)

Made-with: Cursor
- Check both errors and errorFields sources to avoid navigating
  away on failure (P1)
- Use shared getPrivatePersonalDetailsFormValues helper instead of
  duplicated local function (CONSISTENCY-3)
- Remove redundant useMemo/useCallback wrappers
  (CLEAN-REACT-PATTERNS-0)

Made-with: Cursor
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.

3 participants