App
App copied to clipboard
[HOLD for payment 2024-12-17] [LHN Mismatch] Move client-only keys from report_ to reportMetadata_
We are going to be changing the behavior of OpenApp/ReconnectApp when it does a full reconnect to replace the full reports list that the client has stored instead of merging with it. This means that any client-only data that we have about reports can potentially get wiped when the back-end reconnects.
We already have a reportMetadata_ object in Onyx that is meant to store such data. Let's move any keys that are currently client-only that are stored in the report_ object to the reportMetadata_ object. These are some likely keys that we will need to migrate:
- avatarFileName: The filename of the avatar.
- icons: List of icons for report participants.
- isPolicyExpenseChat: Indicates whether the report is a policy expense chat.
- lastMessageTimestamp: The timestamp of the last message on the report.
- lastReadCreated: The time of the last read of the report.
- openOnAdminRoom: If the admin room should be opened.
- cachedTotal: Report cached total.
- lastMessageTranslationKey: Translation key of the last message in the report.
- isOptimisticReport: Whether the current report is optimistic.
- displayName: Display name of the report, shown in options and mentions.
- ownerEmail: E-mail of the report owner.
- errors: Collection of errors to be shown to the user.
- isLastMessageDeletedParentAction: Whether the last message was a deleted parent action.
- iouReportAmount: Total amount of money owed for IOU report.
- preexistingReportID: The ID of the preexisting report.
- isHidden: Whether the report is hidden from the options list.
- isChatRoom: Whether the report is a chat room.
- participantsList: Collection of participants' personal details.
- text: Text to be displayed in the options list, which matches reportName by default.
- privateNotes: Collection of participant private notes, indexed by their accountID.
- isLoadingPrivateNotes: Whether participants' private notes are currently loading.
- selected: Whether the report is currently selected in the options list.
- pendingChatMembers: Pending members of the report.
- transactionThreadReportID: The ID of the single transaction thread report associated with this report, if one exists.
- participantAccountIDs: Participant account IDs.
- visibleChatMemberAccountIDs: Visible chat member account IDs.
To do this we will need to:
- Confirm whether this is the complete list of keys to migrate or whether there are others
- Confirm whether these keys all need to exist. Some of them seem like they might potentially be redundant and could be removed altogether. For example, isPolicyExpenseChat and isChatRoom seem like they may be redundant with chatType. The ownerEmail seems like it may be redundant with ownerAccountID. We should check each key and ensure that it's actually needed.
- For those that are needed, let's move them to reportMetadata_ by: a. Updating any code that sets the data to set it in reportMetadata_ instead b. Updating any code that gets the data to get it from reportMetadata_ instead c. Create migration to migrate any existing data in these keys from report_ to reportMetadata_
- Let's make it so that people can't accidentally add new client-only keys to the report object. We can do this by adding a unit test that checks that only these keys have been added to the report object. So that it must be explicitly updated if new keys are added after confirming that they are safe to add there