Skip to content

Email Notifications Display Messages in Reverse Order #89790

@m-natarajan

Description

@m-natarajan

If you haven’t already, check out our contributing guidelines for onboarding and email contributors@expensify.com to request to join our Slack channel!


Version Number: 9.3.67-11
Reproducible in staging?: Y
Reproducible in production?: Y
If this was caught during regression testing, add the test name, ID and link from BrowserStack:
Email or phone of affected tester (no customers):
Logs: https://stackoverflow.com/c/expensify/questions/4856
Expensify/Expensify Issue URL:
Issue reported by: @shawnborton
Slack conversation (hyperlinked to channel name): #Expensify Bugs

Action Performed:

  1. Trigger an email notification with multiple messages (e.g., chat thread or report activity)
  2. Open the email
  3. Observe the order of messages

Expected Result:

Messages should be displayed in chronological order with the latest message at the bottom

Actual Result:

Messages are displayed in reverse order

Workaround:

Unknown

Platforms:

Select the officially supported platforms where the issue was reproduced:

  • Android: App
  • Android: mWeb Chrome
  • iOS: App
  • iOS: mWeb Safari
  • iOS: mWeb Chrome
  • Windows: Chrome
  • MacOS: Chrome / Safari

MelvinBot investigation:

I investigated the email notification comment ordering code. Here's what I found:

The array_reverse() on email comments has been in the code since at least Oct 2024​ (and likely since Jan 2023 when getCommentBlock() was first created). This means email notifications have shown newest-on-top for a long time — this is not a recent regression.

The data flow is:

1.  Auth returns comments in ASC order (oldest first) via getHistory() with ACTION_ORDER_ASC
2.  Comment.php:686 calls array_reverse() → flips to newest-first
3.  The for loop renders them top-to-bottom → newest comment appears at top of email

Recent changes reviewed:

•   ​App PR #85114​ (FlashList migration) — purely frontend, zero impact on email notifications
•   ​Commit 47b5d98640​ (Apr 21, 2026) — added usort() + system message filtering in ReportUtils.php:3190. The usort sorts by created ASC which is the same order the data was already in, so this shouldn't have changed display order.

Bottom line:​ I could not find a recent commit that changed the ordering. The newest-on-top behavior appears to be long-standing. If the ordering truly needs to be oldest-on-top (newest-on-bottom), the fix would be to remove the array_reverse() call on line 686 of Comment.php. But I'd recommend first confirming with the reporter whether this is actually a recent change vs. something that was always this way and is only now being noticed.

Screenshots/Videos

Image Image

View all open jobs on GitHub

Metadata

Metadata

Labels

BugSomething is broken. Auto assigns a BugZero manager.DailyKSv2InternalRequires API changes or must be handled by Expensify staffReviewingHas a PR in review

Type

No type
No fields configured for issues without a type.

Projects

Status
Done

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions