Skip to content

[$250] Simplify optimistic report actions by removing text and html fields #98439

Open

Description

@tgolen

Coming from this Slack thread

Problem

These fields are causing issues when refactoring some Onyx.connect() references.

Solution

Remove those two fields from optimistic data since they are not used on the FE anywhere.

Issue OwnerCurrent Issue Owner: @shubham1206agra

Activity

  1. melvin-bot commented on Aug 12, 2026

    @melvin-bot

    Auto-assigning issues to engineers is no longer supported. If you think this issue should receive engineering attention, please raise it in #whatsnext.

  2. Sidsmartz commented on Aug 13, 2026

    @Sidsmartz

    Proposal

    What is the root cause of that problem?

    In buildOptimisticAddCommentReportAction (src/libs/ReportUtils.ts) and several similar
    optimistic-action builders (buildOptimisticTaskCommentReportAction, and the optimistic
    comment builders in src/libs/actions/Report/index.ts, IOU/DeleteMoneyRequest.ts,
    IOU/SplitTransactionUpdate.ts, IOU/TrackExpense.ts, and Transaction.ts), the same html
    string is written to two places on the optimistic reportAction: message[0].html AND
    originalMessage.html.

    Searching the full src/ tree, message[0].html/text are what the FE actually reads for rendering. via getReportActionMessage/getReportActionHtml/getReportActionText in ReportActionsUtils.ts, and directly in Chronos.ts. originalMessage.html on these optimistic objects is never read anywhere in the codebase. It's dead weight left over on the optimistic object, and it's the kind of extra, untyped-away field that trips up Onyx.connect() selectors when their expected return shape gets narrowed during a refactor.

    buildOptimisticTaskReportAction() in ReportUtils.ts has the same issue for TASK_COMPLETED/TASK_REOPENED/TASK_CANCELLED actions — it sets both text: message and html: message on originalMessage, and none of it is read anywhere either. Worth noting: OriginalMessageMap types these four task-status action names as never, meaning they aren't supposed to carry any originalMessage fields at all — the object is built as a loose structural literal with no compile-time contract catching the mismatch, which is exactly why it went unnoticed.

    What changes do you think we should make in order to solve the problem?

    Remove the redundant html key from the originalMessage object at each of the optimistic
    builder call sites listed above, so the optimistic reportAction only carries html/text
    inside message[0] (which is what rendering actually consumes) and drops the unused
    duplicate on originalMessage. message[0].html and message[0].text themselves are not
    touched, since they're actively read by the renderer. Update the snapshot/mock tests
    in the corresponding test files that currently assert on the shape of these optimistic
    objects, since they'll need to drop the now-removed originalMessage.html field.

    Also apply the same fix to buildOptimisticTaskReportAction(). And since OriginalMessageAddComment.html is currently typed as required (html: string) in src/types/onyx/OriginalMessage.ts, removing the runtime field on ADD_COMMENT builders needs a matching type change — making it optional — or the typecheck step fails. Nothing in src/ reads originalMessage.html for ADD_COMMENT either, so this is safe.

    What alternative solutions did you explore? (Optional)

    An alternative would be to leave originalMessage.html in place and instead adjust the
    Onyx.connect() selector to ignore/omit it. I think removing it from the optimistic
    builders is cleaner since it fixes the redundant data at its source rather than
    special-casing the selector around it, and it keeps the optimistic object's shape
    consistent with what's actually used.

  3. plantrungnampl commented on Aug 13, 2026

    @plantrungnampl

    Proposal

    What is the root cause of that problem?

    The two redundant fields are text and html on the originalMessage created by buildOptimisticTaskReportAction() in src/libs/ReportUtils.ts.

    That builder is used for optimistic TASK_COMPLETED, TASK_REOPENED, and TASK_CANCELLED actions and currently creates both:

    originalMessage: {
        taskReportID,
        type: actionName,
        text: message,
        html: message,
        whisperedTo: [],
    },
    message: [
        {
            text: message,
            taskReportID,
            type: CONST.REPORT.MESSAGE.TYPE.TEXT,
        },
    ],

    The visible action text is already carried by message[0].text, which is what the generic report-action helpers read. The FE does not need originalMessage.text or originalMessage.html. This also matches the report-action typing: OriginalMessageMap maps TASK_CANCELLED, TASK_COMPLETED, TASK_EDITED, and TASK_REOPENED to never, so adding display text/html to originalMessage gives optimistic data a shape that is not part of the typed FE contract and can surface when narrowing/refactoring Onyx.connect() data.

    This should not be solved by removing message[0].text / message[0].html from normal optimistic comment actions. Those message fields are actively consumed by getReportActionText() / getReportActionHtml() and are needed for optimistic rendering.

    What changes do you think we should make in order to solve the problem?

    In buildOptimisticTaskReportAction():

    1. Remove only text: message and html: message from the optimistic originalMessage object.
    2. Keep the action message in message[0].text so complete/reopen/cancel actions render exactly as they do today.
    3. Keep the existing task metadata (taskReportID, type, whisperedTo) unchanged to avoid expanding the scope beyond the two fields requested by this issue.
    4. Add/update targeted unit coverage for the optimistic task complete/reopen/cancel data to assert that originalMessage no longer contains text/html while the action message remains available from message[0].text.

    The implementation should therefore be a small source-of-truth cleanup rather than a broad change across ADD_COMMENT builders.

    What alternative solutions did you explore? (Optional)

    I checked removing the message fields instead, but that would be incorrect because the FE report-action helpers derive rendered text/html from message. I also considered stripping the fields downstream in an Onyx selector, but removing the redundant values at the optimistic-data builder is smaller and prevents the mismatched shape from being created in the first place.

  4. melvin-bot commented on Aug 13, 2026

    @melvin-bot

    📣 @plantrungnampl! 📣
    Hey, it seems we don’t have your contributor details yet! You'll only have to do this once, and this is how we'll hire you on Upwork.
    Please follow these steps:

    1. Make sure you've read and understood the contributing guidelines.
    2. Get the email address used to login to your Expensify account. If you don't already have an Expensify account, create one here. If you have multiple accounts (e.g. one for testing), please use your main account email.
    3. Get the link to your Upwork profile. It's necessary because we only pay via Upwork. You can access it by logging in, and then clicking on your name. It'll look like this. If you don't already have an account, sign up for one here.
    4. Copy the format below and paste it in a comment on this issue. Replace the placeholder text with your actual details.
      Screen Shot 2022-11-16 at 4 42 54 PM
      Format:
    Contributor details
    Your Expensify account email: <REPLACE EMAIL HERE>
    Upwork Profile Link: <REPLACE LINK HERE>
    
  5. 31 remaining items

  6. melvin-bot commented on Sep 11, 2026

    @melvin-bot

    @shubham1206agra Uh oh! This issue is overdue by 2 days. Don't forget to update your issues!

  7. melvin-bot commented on Sep 15, 2026

    @melvin-bot

    @shubham1206agra Still overdue 6 days?! Let's take care of this!

  8. eswar5678 commented on Sep 16, 2026

    @eswar5678
  9. eswar5678 commented on Sep 16, 2026

    @eswar5678
  10. melvin-bot commented on Sep 16, 2026

    @melvin-bot

    📣 @eswar5678! 📣
    Hey, it seems we don’t have your contributor details yet! You'll only have to do this once, and this is how we'll hire you on Upwork.
    Please follow these steps:

    1. Make sure you've read and understood the contributing guidelines.
    2. Get the email address used to login to your Expensify account. If you don't already have an Expensify account, create one here. If you have multiple accounts (e.g. one for testing), please use your main account email.
    3. Get the link to your Upwork profile. It's necessary because we only pay via Upwork. You can access it by logging in, and then clicking on your name. It'll look like this. If you don't already have an account, sign up for one here.
    4. Copy the format below and paste it in a comment on this issue. Replace the placeholder text with your actual details.
      Screen Shot 2022-11-16 at 4 42 54 PM
      Format:
    Contributor details
    Your Expensify account email: <REPLACE EMAIL HERE>
    Upwork Profile Link: <REPLACE LINK HERE>
    
  11. melvin-bot commented on Sep 17, 2026

    @melvin-bot

    @shubham1206agra Now this issue is 8 days overdue. Are you sure this should be a Daily? Feel free to change it!

  12. shubham1206agra commented on Sep 21, 2026

    @shubham1206agra
    Contributor

    @tgolen Can you change this to Weekly for now?

  13. tgolen commented on Sep 21, 2026

    @tgolen
    ContributorAuthor

    Sure can!

  14. added and removed on Sep 21, 2026
  15. melvin-bot commented on Oct 14, 2026

    @melvin-bot

    This issue has not been updated in over 15 days. @tgolen, @shubham1206agra eroding to Monthly issue.

    P.S. Is everyone reading this sure this is really a near-term priority? Be brave: if you disagree, go ahead and close it out. If someone disagrees, they'll reopen it, and if they don't: one less thing to do!

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

Metadata

Metadata

Type

No type

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions