Expensify / App

Welcome to New Expensify: a complete re-imagination of financial collaboration, centered around chat. Help us build the next generation of Expensify by sharing feedback and contributing to the code.
https://new.expensify.com
MIT License
3.48k stars 2.84k forks source link

Make sure we have HTML content for CopyExistingPolicyConnection's POLICYCHANGELOG_ADD_INTEGRATION #45316

Closed yuwenmemon closed 2 months ago

yuwenmemon commented 3 months ago

Observed by @SzymczakJ here:

Tested the CopyExistingPolicyConnection endpoint and it connects integration correctly. One bug that I found is that when successfully connecting user gets buggy message telling him that he connected Sage Intacct to policy. In case when we connect to Sage intacct manually this is all the Onyx data that comes:

{
    "onyxData": [
        {
            "key": "report_4678534727087102",
            "onyxMethod": "merge",
            "value": {
                "chatType": "policyAdmins",
                "lastActorAccountID": 17824010,
                "lastMessageText": "connected to Sage Intacct",
                "lastVisibleActionCreated": "2024-07-11 15:44:20.838",
                "managerID": null,
                "parentReportActionID": null,
                "parentReportID": null,
                "participants": {
                    "17824010": {
                        "hidden": false
                    }
                },
                "policyID": "EDE79B7B980F6FA8",
                "reportID": "4678534727087102",
                "reportName": "#admins",
                "stateNum": 0,
                "statusNum": 0,
                "type": "chat",
                "visibility": null
            }
        },
        {
            "key": "reportActions_4678534727087102",
            "onyxMethod": "merge",
            "value": {
                "6934746527381465563": {
                    "actionName": "POLICYCHANGELOG_ADD_INTEGRATION",
                    "actorAccountID": 17824010,
                    "avatar": "https:\/\/d2k5nsl2zxldvw.cloudfront.net\/images\/avatars\/default-avatar_3.png",
                    "created": "2024-07-11 15:44:20.838",
                    "lastModified": "2024-07-11 15:44:20.838",
                    "message": [
                        {
                            "html": "",
                            "text": "",
                            "type": "COMMENT",
                            "whisperedTo": []
                        }
                    ],
                    "originalMessage": {
                        "connectionName": "intacct",
                        "lastModified": "2024-07-11 15:44:20.838"
                    },
                    "person": [
                        {
                            "style": "strong",
                            "text": "22",
                            "type": "TEXT"
                        }
                    ],
                    "previousReportActionID": "2368033606552521860",
                    "reportActionID": "6934746527381465563",
                    "shouldShow": true
                }
            }
        },
        {
            "key": "personalDetailsList",
            "onyxMethod": "merge",
            "value": {
                "17824010": {
                    "accountID": 17824010,
                    "avatar": "https:\/\/d2k5nsl2zxldvw.cloudfront.net\/images\/avatars\/default-avatar_3.png",
                    "displayName": "22",
                    "firstName": "22",
                    "lastName": "",
                    "login": "jakub.szymczak+connect_intacct_test3@swmansion.com",
                    "phoneNumber": "",
                    "pronouns": "",
                    "status": null,
                    "timezone": {
                        "automatic": true,
                        "selected": "Europe\/Warsaw"
                    },
                    "validated": true
                }
            }
        },
        {
            "key": "policy_EDE79B7B980F6FA8",
            "onyxMethod": "merge",
            "value": { ... } // this is not that important
        },
        {
            "key": "report_4678534727087102",
            "onyxMethod": "merge",
            "value": {
                "lastReadTime": "2024-07-11 15:44:20.838"
            }
        },
        {
            "key": "report_4678534727087102",
            "onyxMethod": "merge",
            "value": {
                "lastActorAccountID": 17824010,
                "lastMentionedTime": null,
                "lastMessageText": "connected to Sage Intacct",
                "lastReadTime": "2024-07-11 15:44:20.838",
                "lastVisibleActionCreated": "2024-07-11 15:44:20.838",
                "maxSequenceNumber": null,
                "reportID": "4678534727087102"
            }
        },
        {
            "key": "reportActions_4678534727087102",
            "onyxMethod": "merge",
            "shouldNotify": true,
            "value": {
                "6934746527381465563": {
                    "actionName": "POLICYCHANGELOG_ADD_INTEGRATION",
                    "actorAccountID": 17824010,
                    "automatic": false,
                    "avatar": "https:\/\/d2k5nsl2zxldvw.cloudfront.net\/images\/illustrations\/avatar_2.png",
                    "created": "2024-07-11 15:44:20.838",
                    "isAttachment": false,
                    "lastModified": "2024-07-11 15:44:20.838",
                    "message": [
                        {
                            "deleted": "",
                            "html": "connected to Sage Intacct", // THIS IS IMPORTANT
                            "isDeletedParentAction": false,
                            "isEdited": false,
                            "reactions": [],
                            "text": "connected to Sage Intacct",
                            "type": "COMMENT",
                            "whisperedTo": []
                        }
                    ],
                    "originalMessage": {
                        "connectionName": "intacct",
                        "lastModified": "2024-07-11 15:44:20.838"
                    },
                    "person": [
                        {
                            "style": "strong",
                            "text": "22",
                            "type": "TEXT"
                        }
                    ],
                    "previousReportActionID": "2368033606552521860",
                    "reportActionID": "6934746527381465563",
                    "reportActionTimestamp": 1720712660838,
                    "sequenceNumber": null,
                    "shouldShow": true,
                    "timestamp": 1720712660,
                    "whisperedToAccountIDs": []
                }
            }
        }
    ],
    "lastUpdateID": "573176855",
    "previousUpdateID": "573174602",
    "jsonCode": 200,
    "requestID": "8a19ea275cefbf7b-WAW"
}

when reusing other connection:

{
    "jsonCode": 200,
    "requestID": "8a19ecccfff9b23f-WAW",
    "onyxData": [
        {
            "key": "policy_11295D0FB702844F",
            "onyxMethod": "merge",
            "value": {
                "connections": //  NOT THAT IMPORTANT
                }
            }
        },
        {
            "key": "report_5548358651717552",
            "onyxMethod": "merge",
            "value": {
                "chatType": "policyAdmins",
                "lastActorAccountID": 17824010,
                "lastMessageText": "connected to Sage Intacct",
                "lastVisibleActionCreated": "2024-07-11 15:46:12.803",
                "managerID": null,
                "parentReportActionID": null,
                "parentReportID": null,
                "participants": {
                    "17824010": {
                        "hidden": false
                    }
                },
                "policyID": "11295D0FB702844F",
                "reportID": "5548358651717552",
                "reportName": "#admins",
                "stateNum": 0,
                "statusNum": 0,
                "type": "chat",
                "visibility": null
            }
        },
        {
            "key": "reportActions_5548358651717552",
            "onyxMethod": "merge",
            "value": {
                "1074484534786610326": {
                    "actionName": "POLICYCHANGELOG_ADD_INTEGRATION",
                    "actorAccountID": 17824010,
                    "avatar": "https:\/\/d2k5nsl2zxldvw.cloudfront.net\/images\/avatars\/default-avatar_3.png",
                    "created": "2024-07-11 15:46:12.803",
                    "lastModified": "2024-07-11 15:46:12.803",
                    "message": [
                        {
                            "html": "", // THIS IS THE BUGGY PART! message is missing fields text, html, etc 
                            "text": "",
                            "type": "COMMENT",
                            "whisperedTo": []
                        }
                    ],
                    "originalMessage": {
                        "connectionName": "intacct",
                        "lastModified": "2024-07-11 15:46:12.803"
                    },
                    "person": [
                        {
                            "style": "strong",
                            "text": "22",
                            "type": "TEXT"
                        }
                    ],
                    "previousReportActionID": "5905515269550668013",
                    "reportActionID": "1074484534786610326",
                    "shouldShow": true
                }
            }
        },
        {
            "key": "personalDetailsList",
            "onyxMethod": "merge",
            "value": // THIS IS NOT IMPORTANT
            }
        }
    ],
    "lastUpdateID": 573184594
}

Please take a look how reportActions_... fields differ between these two


Should be a simple fix where we add in the proper HTML in Auth where this report action is being created.

melvin-bot[bot] commented 3 months ago

@yuwenmemon Whoops! This issue is 2 days overdue. Let's get this updated quick!

yuwenmemon commented 3 months ago

Looking at this today

yuwenmemon commented 2 months ago

This has been deployed to prod