App: LHN does not update properly when calling ReconnectApp

Coming from https://github.com/Expensify/App/issues/33372

Problem

Left hand nav is outdated (in focus mode?) when calling ReconnectApp, which should never happen since after calling ReconnectApp everything should be up to date.

You can see logs from the App here and the call to ReconnectApp here and see that it failed to use the updates and instead called auth’s OpenApp

My very wild guess is that for focus mode, it is never clearing the existing data in onyx, so a chat that was showing (since it was unread) would not get explicitly removed when OpenApp does not send it back.

Upwork Automation - Do Not Edit
  • Upwork Job URL: https://www.upwork.com/jobs/~01ea2b6c10b081507e
  • Upwork Job ID: 1742324658321010688
  • Last Price Increase: 2024-01-02

About this issue

  • Original URL
  • State: closed
  • Created 6 months ago
  • Comments: 39 (29 by maintainers)

Most upvoted comments

@sonialiap possibly - but doesn’t seem related to me. That one seems to imply something went wrong with marking chats as read.

Bit of a stretch but I wonder if this is related to this: https://github.com/Expensify/App/issues/34273 (“Message didn’t show up as unread in LHN, but I got the email notification”)

@sakluger looks a bit different than this issue

Can’t say with certainty but it seems like maybe:

  • Message was sent fine via notification to your mobile
  • Message did not make it to web (maybe it’s slow for some reason or you lost connectivity for a moment)
  • Tapped another chat and reliable updates sent you the missing update

No I just did this:

diff --git a/lib/AppInit.php b/lib/AppInit.php
index 52612dbdca9..049c39521f6 100644
--- a/lib/AppInit.php
+++ b/lib/AppInit.php
@@ -375,6 +375,7 @@ class AppInit
             /** @psalm-suppress InvalidGlobal */
             global $trackMetric;
             try {
+                throw new ExpError('asdf', 'asdf', jsonCode: 423);
                 $response = Auth::getOnyxUpdates($authToken, $updateIDFrom, $updateIDTo);

                 // GetOnyxUpdates will return the format array{accountID => array{updates, previousUpdateID, lastUpdateID}}.

Ok, on a first pass - I cannot reproduce this problem and it does not seem like the current theory is the whole story.

If you look at the code for ReconnectApp we do not ever call it with the priority mode.

api.php

https://github.com/Expensify/Web-Expensify/blob/bff668e4e707766249cddb1117b0a4caf89e1621/api.php#L3280

AppInit.php (defaults to false)

https://github.com/Expensify/Web-Expensify/blob/7938771c948ff4a3c7e16a101cdbe0a9e00dbf70/lib/AppInit.php#L368

Which means we should be syncing with the full list when GetOnyxUpdates throws the 423 jsonCode.

And when I test locally I see everything sync up fine 🤔

As discussed, we think something like a Onyx.setCollection() could be the way forward. That way the fallback response of “OpenApp” can be used to overwrite existing values.

This makes sense to me. An alternative I can think of is to send the reportIDs from the client, like we did with policyIds, but I like that less and I guess it scales worse.