Skip to content

feat: Add inline editing for tables on desktop (V2)#89166

Open
mohammadjafarinejad wants to merge 42 commits intoExpensify:mainfrom
mohammadjafarinejad:fix/82534-v2
Open

feat: Add inline editing for tables on desktop (V2)#89166
mohammadjafarinejad wants to merge 42 commits intoExpensify:mainfrom
mohammadjafarinejad:fix/82534-v2

Conversation

@mohammadjafarinejad
Copy link
Copy Markdown
Contributor

@mohammadjafarinejad mohammadjafarinejad commented Apr 29, 2026

This reverts commit 78be79e.

Explanation of Change

This PR reapplies #83127 (inline editing for tables on desktop), which was reverted in #88751, with the original issues fixed and additional improvements.

Fixed Issues

$ #82534
$ #88711
PROPOSAL: #82534 (comment)

Tests

  1. Open the app and navigate to the Search/Expenses table on desktop (wide layout)
  2. Click a date cell on any transaction row — verify a date picker popover appears anchored to the cell
  3. Select a new date — verify the cell updates and the popover closes
  4. Click a merchant cell — verify it becomes an inline text input with the current value pre-filled
  5. Edit the text and click away (blur) — verify the new value is saved and the cell returns to display mode
  6. Repeat steps 4–5 for description and amount cells
  7. Click a category cell — verify the category picker popover appears
  8. Select a category — verify the cell updates and the popover closes
  9. Click a cell on a row where editing is not permitted (e.g. no policy) — verify no edit mode is triggered
  • Verify that no errors appear in the JS console

Offline tests

  1. Disable network connection
  2. Edit a cell value — verify the optimistic update is reflected immediately in the UI
  3. Re-enable network — verify the value syncs correctly with the backend

QA Steps

Same as tests.

  • 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 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.

This reverts commit 78be79e.

Co-authored-by: Copilot <copilot@github.com>
@melvin-bot
Copy link
Copy Markdown

melvin-bot Bot commented Apr 29, 2026

Hey! I see that you made changes to our Form component. Make sure to update the docs in FORMS.md accordingly. Cheers!

mohammadjafarinejad and others added 5 commits April 29, 2026 15:20
Co-authored-by: Copilot <copilot@github.com>
Co-authored-by: Copilot <copilot@github.com>
Co-authored-by: Copilot <copilot@github.com>
Co-authored-by: Copilot <copilot@github.com>
@codecov
Copy link
Copy Markdown

codecov Bot commented Apr 29, 2026

Codecov Report

✅ Changes either increased or maintained existing code coverage, great job!

Files with missing lines Coverage Δ
src/App.tsx 100.00% <ø> (ø)
src/CONST/index.ts 92.30% <ø> (ø)
src/components/CategoryPicker/index.tsx 3.44% <ø> (ø)
src/components/DatePicker/CalendarPicker/index.tsx 97.14% <100.00%> (+0.02%) ⬆️
src/components/Modal/BaseModal.tsx 87.68% <100.00%> (+0.18%) ⬆️
src/components/MoneyRequestAmountInput.tsx 74.07% <100.00%> (+0.48%) ⬆️
src/components/Search/SearchContext.tsx 50.00% <100.00%> (+0.42%) ⬆️
...components/Search/SearchList/ListItem/DateCell.tsx 100.00% <100.00%> (ø)
src/components/Search/SearchTableHeader.tsx 50.57% <ø> (ø)
...omponents/Table/EditableCell/useInlineEditState.ts 100.00% <100.00%> (ø)
... and 31 more
... and 9 files with indirect coverage changes

@trjExpensify
Copy link
Copy Markdown
Contributor

@mohammadjafarinejad when can you have this ready for review?

@dubielzyk-expensify
Copy link
Copy Markdown
Contributor

And let us know when we can adhoc test build 😄

@trjExpensify
Copy link
Copy Markdown
Contributor

Bump @mohammadjafarinejad. Can we get daily updates please to get this back out?

@trjExpensify
Copy link
Copy Markdown
Contributor

Bump again @mohammadjafarinejad. Please provide an update.

@mohammadjafarinejad
Copy link
Copy Markdown
Contributor Author

@trjExpensify I'll have it ready for review by tomorrow, after I test it to make sure all bugs are fixed.

@trjExpensify
Copy link
Copy Markdown
Contributor

Okay, thank you.

Comment thread src/components/TransactionItemRow/DataCells/TotalCell.tsx
Comment thread src/components/Table/EditableCell/types.ts
Comment thread src/hooks/useTransactionInlineEdit.ts Outdated
Comment thread src/components/TagPicker/TagPickerModal.tsx Outdated
@ahmedGaber93
Copy link
Copy Markdown
Contributor

@mohammadjafarinejad Thanks for the updates. I’ll review them today.

This PR touches many important and frequently edited files. We should try to get it merged faster; otherwise, you’ll likely need to resolve git conflicts daily and continuously refactor/fix issues caused by new changes.

I think we can handle those in follow-up PRs. Let’s focus on the remaining critical items so we can merge this faster.

#88750 → Likely due to missing Onyx data, needs deeper investigation
#88681 → UX edge case, not blocking
#88659 → Same behavior on production, newly added expense highlights every time any other report is opened

@ahmedGaber93
Copy link
Copy Markdown
Contributor

Table header (Category) misalignment in MoneyRequestReportTransactionItem.

@mohammadjafarinejad This not related to our PR, it should fix here #89529

@ahmedGaber93
Copy link
Copy Markdown
Contributor

The amount field is not editable in Spend > Reports (MoneyRequestReportTransactionItem) (likely need to replace AmountCell with TotalCell).

@mohammadjafarinejad, I’m unable to display the Amount column in the table. Are you experiencing the same issue?

Screen.Recording.2026-05-04.at.11.52.18.PM.mov

Could you also please resolve the conflict and merge the main branch? In the last hours, a few false PRs that touched this table have been reverted.

Comment thread src/libs/MoneyRequestUtils.ts Outdated
Comment on lines +172 to +177
// Unreported transactions can have empty merchants (allows clearing)
const isUnreported = transaction ? isExpenseUnreported(transaction) : false;
if (isEmpty && isUnreported) {
return 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.

I think we also need to allow empty value for IOU because it is not mandatory on IOU.

WDYT if we follow the same validation logic on stepMerchant

const isMerchantRequired = isPolicyExpenseChat(report) || isExpenseRequest(report) || transaction?.participants?.some((participant) => !!participant.isPolicyExpenseChat);

if (isMerchantRequired && !trimmedMerchant) {

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’m not sure why the suggestion above doesn’t work for me when I test it now. If it doesn’t work for you either, we can use this alternative instead.

const isIOU = isIOUReport(transaction?.reportID);
if (isEmpty && (isUnreported || isIOU)) {

Comment on lines +134 to +135
allowFlippingAmount
isNegative={isNegative}
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.

Let’s follow this to avoid allowing fields that don’t support negative amounts.

allowFlippingAmount={!isSplitBill && allowNegative}

Comment on lines +363 to +364
if (!policy?.areCategoriesEnabled) {
return false;
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 think we should also check if the category is missing, so we can remove the selected category even if the category feature is disabled.

if (!policy?.areCategoriesEnabled && isCategoryMissing(transaction?.category)) {
Screen.Recording.2026-05-05.at.2.43.53.AM.mov

Comment thread src/components/Modal/BaseModal.tsx Outdated
forwardedFSClass = CONST.FULLSTORY.CLASS.UNMASK,
ref,
shouldDisplayBelowModals = false,
shouldEnableBackdropInNarrowPane = false,
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.

shouldEnableBackdropInNarrowPane seems a bit generic. Since this behavior is specific to right-docked modals rendered in narrow layouts, I suggest renaming it to shouldKeepRightDockedBackdropInNarrowPane for better clarity and self-documentation at call sites.

I believe this change is only needed for the BaseModal.tsx component, since it’s a global component, and isn’t needed for the YearPickerModal.tsx and MonthPickerModal.tsx components.

return (
<PressableWithFeedback
accessibilityRole={CONST.ROLE.BUTTON}
accessibilityLabel="Edit cell"
Copy link
Copy Markdown
Contributor

@ahmedGaber93 ahmedGaber93 May 5, 2026

Choose a reason for hiding this comment

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

I believe we should discuss/address accessibility in the follow-up because the search table has many expense rows, and each row has multiple input types.

If we need to support it on the table (this accessibility action should be used to focus the cell and start editing), we should have options like “Edit amount” and “Edit Tag.” Additionally, we might need to create a separate “Edit amount” option for transaction X.

CC @trjExpensify

Comment thread src/components/Table/EditableCell/types.ts
return;
}
hasEndedRef.current = true;
onSave?.(localValue);
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.

Should we return early here if the value hasn’t changed to avoid redundant API calls?

if (localValue === value) {
    setIsEditing(false);
    return;
}

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.

@mohammadjafarinejad We have an edge case with the above suggestion when flipping between negative and positive amounts. The - symbol lives outside the input, so switching to a negative value is not considered a change.

Passing a new allowSavingUnchangedValue param to useInlineEditState for the amount cell fixes this issue.


if (!allowSavingUnchangedValue && localValue === value) {
    setIsEditing(false);
    return;
}

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.

@ahmedGaber93 We normalize values in MerchantCell and TotalCell before saving, so a plain equality check is not enough. I added an optional equality function to useInlineEditState so each field can compare normalized values.

const getNormalizedValue = (value: string) => (isDescription ? value : value.trim());

const {isEditing, localValue, setLocalValue, startEditing, save, cancelEditing} = useInlineEditState(
    canEdit,
    text,
    (value) => onSave?.(getNormalizedValue(value)),
    (value, originalValue) => getNormalizedValue(value) === getNormalizedValue(originalValue),
);

WDYT about this approach?

Comment thread src/libs/MoneyRequestUtils.ts Outdated
Comment on lines +172 to +177
// Unreported transactions can have empty merchants (allows clearing)
const isUnreported = transaction ? isExpenseUnreported(transaction) : false;
if (isEmpty && isUnreported) {
return 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.

I’m not sure why the suggestion above doesn’t work for me when I test it now. If it doesn’t work for you either, we can use this alternative instead.

const isIOU = isIOUReport(transaction?.reportID);
if (isEmpty && (isUnreported || isIOU)) {

const [isInverted, setIsInverted] = useState(false);
const [adjustedPopoverHeight, setAdjustedPopoverHeight] = useState(popoverHeight);

const openPopover = () => {
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 think the previous version looks more stable. We now have dynamic height, and the issue is still reproducible.

I think it would be better if we keep the previous version and handle this in a follow-up to keep this PR focused.

Current

Screen.Recording.2026-05-05.at.11.37.57.AM.mov

previous version

Screen.Recording.2026-05-05.at.11.28.44.AM.mov

Comment thread src/components/TagPicker/TagPickerModal.tsx Outdated
editContent={
<TextInput
ref={handleRef}
accessibilityLabel={isDescription ? 'Description input' : 'Merchant input'}
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.

Could we localize this accessibility label instead of hardcoding English text?

Comment thread src/components/ConfirmCancelButtonRow.tsx Outdated
Comment thread src/hooks/useTransactionInlineEdit.ts Outdated
@ahmedGaber93
Copy link
Copy Markdown
Contributor

@mohammadjafarinejad, I’ve completed my review. Please let me know when it’s ready for review again. Thanks!

@ahmedGaber93
Copy link
Copy Markdown
Contributor

ahmedGaber93 commented May 5, 2026

And let us know when we can adhoc test build 😄

@dubielzyk-expensify @Expensify/design It is ready for review.

We manage to fix those on follow-up if they not blockers

#88750 → Likely due to missing Onyx data, needs deeper investigation
#88681 → UX edge case, not blocking
#88659 → Same behavior on production, newly added expense highlights every time any other report is opened

Inline edit for description on multiline
Handling accessibility if it's required as mentioned here #89166 (comment)

@shawnborton
Copy link
Copy Markdown
Contributor

@puneetlath did you want to review this one too?

@puneetlath
Copy link
Copy Markdown
Contributor

Yes! I'll take a look once @ahmedGaber93's feedback has been addressed.

@ahmedGaber93
Copy link
Copy Markdown
Contributor

The amount field is not editable in Spend > Reports (MoneyRequestReportTransactionItem) (likely need to replace AmountCell with TotalCell).

@mohammadjafarinejad This looks not related to our PR, Amount field is hidden even when it is selected in the column configuration.

Commenting on the offending PR https://github.com/Expensify/App/pull/86824/changes#r3191023822 that causes the issue since it still on regression period

If you want to force display it for testing, set this value to false and confirm Amount is selected in the columns configuration.

[CONST.SEARCH.TABLE_COLUMNS.TOTAL_AMOUNT]: false,

Screen.Recording.2026-05-05.at.10.50.23.PM.mov

@ahmedGaber93
Copy link
Copy Markdown
Contributor

We have a new update here: #86824 (comment)

Now, we need to have at least one expense with a foreign currency to display the Amount column on the expense report page.

This may cause a UX conflict for inline edit:

  • The Total column is always visible, but users cannot edit it because it displays the converted amount.
  • The Amount column is editable, but it only appears when there is at least one expense with a foreign currency.

@trjExpensify WDYT?

Should we exchange them instead?

  • Display the Amount column by default since it is the editable value.
  • Display the Total column only when there is at least one expense with a foreign currency.

@trjExpensify
Copy link
Copy Markdown
Contributor

Should we exchange them instead?

  • Display the Amount column by default since it is the editable value.
  • Display the Total column only when there is at least one expense with a foreign currency.

This would be contrary to Classic though? Total (convertedAmount) is always visible, Amount is shown when there's foreign expenses.

@ahmedGaber93
Copy link
Copy Markdown
Contributor

@trjExpensify Ah, I think we have some options for that.

  1. Display both the amount and the total, as was the case two weeks ago.
  2. Make the total editable if there are no foreign expenses since it already has the value of the amount. When expenses with foreign currency are added and the amount column is displayed, make the editable field the amount (this may confuse the user)
    Do nothing. The amount will remain hidden (no inline edit for the amount) until there are foreign expenses.

@mohammadjafarinejad
Copy link
Copy Markdown
Contributor Author

@ahmedGaber93 Ready for re-review.

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.

6 participants