You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Home-"Recently added" not sorted by when they were added #94339
Version Number: v9.4.17-0 Reproducible in staging?: Yes Reproducible in production?: N/A - new feature, doesn't exist in prod If this was caught during regression testing, add the test name, ID and link from BrowserStack:#93451 Email or phone of affected tester (no customers):lekima20+615706@gmail.com Issue reported by: Applause Internal Team Bug source: Pull Request QA execution Device used: Win 11/Chrome App Component: Other
Action Performed:
Precondition: Login with new account and create a workspace
Scroll down to Recently added section and observe the list
Expected Result:
Verify the "Recently added" slot lists up to five expenses sorted by when they were added (an expense added today but dated months ago appears at the top)
Actual Result:
The list isn't sorted by when they were added. The expense with date in April and May aren't displayed at the top.
👋 Friendly reminder that deploy blockers are time-sensitive ⏱ issues! Check out the open `StagingDeployCash` deploy checklist to see the list of PRs included in this release, then work quickly to do one of the following:
Identify the pull request that introduced this issue and revert it.
Root Cause: The "Recently added" sort relies on each transaction's inserted timestamp, but the data it renders from — the Search snapshot — doesn't carry inserted, and its only fallback source (the local transactions_ collection) doesn't reliably contain these expenses either. So the recency key falls all the way through to the expense date (getCreated), which is why the list is ordered by date instead of by when each expense was added.
insertedByTransactionID.get(id) // local transactions_ collection — sparse/on-demand
?? transaction.inserted // snapshot — omits `inserted` by design (see lines 70-71)
?? getCreated(transaction) // expense DATE ('YYYY-MM-DD') — the wrong key, but what we land on
The hook itself documents at :70-71 that the snapshot omits inserted, so ordering "must come from the local transactions_ collection" — but that collection is also flagged as holding "only on-demand data and may be missing most expenses." When both miss, getCreated (date-only) decides the order → exactly the reported symptom.
Why the PR's tests didn't catch it: the unit tests inject inserted directly onto the snapshot transactions and never populate the local transactions_ collection (useRecentlyAddedDataTest.ts:90-99), so they pass via the ?? transaction.inserted branch — a path that never exists in production. The UI test fully mocks the hook, so it validates no sorting at all.
⚠️The real fix is outside the App repo. Making the sort correct requires the backend Search command (Web-Expensify) to include inserted on the transaction objects it returns in the snapshot (and/or return results pre-sorted by date-added). I don't have access to that repo, so this should be escalated to an internal engineer. There is no reliable App-only source of inserted for arbitrary expenses surfaced via Search.
Deploy-blocker recommendation: Since this is a brand-new feature (#93451) and the proper fix is a backend change, the fastest path to unblock the deploy is to revert / CP-revert #93451 (or hide the Recently-added section) until the snapshot carries inserted.
Investigation details & evidence
buildOptimisticTransactiondoes set inserted: DateUtils.getDBTime() (src/libs/TransactionUtils/index.ts:447), so an expense created on-device gets inserted in transactions_ momentarily. But the Home list renders from the Search snapshot (snapshot_<hash>), not from transactions_, and transactions_ is sparse/on-demand — so the snapshot transactions frequently have no matching local entry to borrow inserted from.
The App never injects inserted into snapshot data: search() only writes loading/offset metadata optimistically; the transaction payload comes entirely from the backend SEARCH response (src/libs/actions/Search.ts). Whether the snapshot has inserted is a backend decision.
getCreated returns modifiedCreated ?? created, a date-only 'YYYY-MM-DD' string — when used as the sort key, all same-day expenses tie and months-ago-dated expenses sink to the bottom regardless of when they were added.
Alternative explanations considered & ruled out: (a) sort-direction bug — the comparator at :158-165 correctly orders newest-first; (b) inserted format/precision mismatch — inserted is 'YYYY-MM-DD HH:mm:ss.SSS' and sorts lexicographically fine; the problem is its absence, not its format. The single common cause that explains every symptom is the fallback to getCreated.
Test fix needed too: the unit test should seed ONYXKEYS.COLLECTION.TRANSACTION (the local collection) and leave insertedoff the snapshot transactions, to actually exercise the production path.
Next Steps for Contributor+ team: To accept the backend escalation: Assign an internal engineer to add inserted to the Search command's transaction payload in Web-Expensify. To unblock the deploy now: Revert #93451. To refine:@MelvinBot <your feedback>
Activity
applause-bot commentedon Jun 23, 2026
While Applause doesn't embed attachments for this bug, here are the links for quick view:
https://platform.applause.com/services/links/v1/external/a1e3e3ff3d6e6e597b0bc8fd422b10a1a494d836d82a6b690debb6b72bbee814
melvin-bot commentedon Jun 23, 2026
@grgia recently merged #93451, but they are OOO right now, so I'll auto-assign someone else.
melvin-bot commentedon Jun 23, 2026
Triggered auto assignment to @Julesssss (
DeployBlockerCash), see https://stackoverflowteams.com/c/expensify/questions/9980/ for more details.melvin-bot commentedon Jun 23, 2026
💬 A slack conversation has been started in #expensify-open-source
github-actions commentedon Jun 23, 2026
👋 Friendly reminder that deploy blockers are time-sensitive ⏱ issues! Check out the open `StagingDeployCash` deploy checklist to see the list of PRs included in this release, then work quickly to do one of the following:
MelvinBot commentedon Jun 23, 2026
Issue Analysis
Root Cause: The "Recently added" sort relies on each transaction's
insertedtimestamp, but the data it renders from — the Search snapshot — doesn't carryinserted, and its only fallback source (the localtransactions_collection) doesn't reliably contain these expenses either. So the recency key falls all the way through to the expense date (getCreated), which is why the list is ordered by date instead of by when each expense was added.The recency key in
useRecentlyAddedData.ts:154-155is:The hook itself documents at
:70-71that the snapshot omitsinserted, so ordering "must come from the localtransactions_collection" — but that collection is also flagged as holding "only on-demand data and may be missing most expenses." When both miss,getCreated(date-only) decides the order → exactly the reported symptom.Why the PR's tests didn't catch it: the unit tests inject
inserteddirectly onto the snapshot transactions and never populate the localtransactions_collection (useRecentlyAddedDataTest.ts:90-99), so they pass via the?? transaction.insertedbranch — a path that never exists in production. The UI test fully mocks the hook, so it validates no sorting at all.Deploy-blocker recommendation: Since this is a brand-new feature (#93451) and the proper fix is a backend change, the fastest path to unblock the deploy is to revert / CP-revert #93451 (or hide the Recently-added section) until the snapshot carries
inserted.Investigation details & evidence
buildOptimisticTransactiondoes setinserted: DateUtils.getDBTime()(src/libs/TransactionUtils/index.ts:447), so an expense created on-device getsinsertedintransactions_momentarily. But the Home list renders from the Search snapshot (snapshot_<hash>), not fromtransactions_, andtransactions_is sparse/on-demand — so the snapshot transactions frequently have no matching local entry to borrowinsertedfrom.insertedinto snapshot data:search()only writes loading/offset metadata optimistically; the transaction payload comes entirely from the backendSEARCHresponse (src/libs/actions/Search.ts). Whether the snapshot hasinsertedis a backend decision.getCreatedreturnsmodifiedCreated ?? created, a date-only'YYYY-MM-DD'string — when used as the sort key, all same-day expenses tie and months-ago-dated expenses sink to the bottom regardless of when they were added.:158-165correctly orders newest-first; (b)insertedformat/precision mismatch —insertedis'YYYY-MM-DD HH:mm:ss.SSS'and sorts lexicographically fine; the problem is its absence, not its format. The single common cause that explains every symptom is the fallback togetCreated.ONYXKEYS.COLLECTION.TRANSACTION(the local collection) and leaveinsertedoff the snapshot transactions, to actually exercise the production path.Next Steps for Contributor+ team:
To accept the backend escalation: Assign an internal engineer to add
insertedto theSearchcommand's transaction payload in Web-Expensify.To unblock the deploy now: Revert #93451.
To refine:
@MelvinBot <your feedback>blimpich commentedon Jun 23, 2026
Demoting: https://expensify.slack.com/archives/C01GTK53T8Q/p1782234021458379?thread_ts=1782233318.342609&cid=C01GTK53T8Q
grgia commentedon Jun 29, 2026
Closing as dupe
m-natarajan commentedon Jul 1, 2026
@blimpich @grgia Able to reproduce this in the latest staging v9.4.25-0, Should I reopen this issue or is this a dupe of #94162 as per this comment
Recording.2284.mp4