diff --git a/src/libs/actions/Report.js b/src/libs/actions/Report.js
index 4cf90dbcb1ab..223d803dbc81 100644
--- a/src/libs/actions/Report.js
+++ b/src/libs/actions/Report.js
@@ -345,8 +345,9 @@ function addComment(reportID, text) {
* @param {Object} newReportObject The optimistic report object created when making a new chat, saved as optimistic data
* @param {String} parentReportActionID The parent report action that a thread was created from (only passed for new threads)
* @param {Boolean} isFromDeepLink Whether or not this report is being opened from a deep link
+ * @param {Array} participantAccountIDList The list of accountIDs that are included in a new chat, not including the user creating it
*/
-function openReport(reportID, participantLoginList = [], newReportObject = {}, parentReportActionID = '0', isFromDeepLink = false) {
+function openReport(reportID, participantLoginList = [], newReportObject = {}, parentReportActionID = '0', isFromDeepLink = false, participantAccountIDList = []) {
const optimisticReportData = {
onyxMethod: Onyx.METHOD.MERGE,
key: `${ONYXKEYS.COLLECTION.REPORT}${reportID}`,
@@ -387,6 +388,7 @@ function openReport(reportID, participantLoginList = [], newReportObject = {}, p
const params = {
reportID,
emailList: participantLoginList ? participantLoginList.join(',') : '',
+ accountIDList: participantAccountIDList ? participantAccountIDList.join(',') : '',
parentReportActionID,
};
@@ -492,6 +494,24 @@ function navigateToAndOpenReport(userLogins) {
Navigation.dismissModal(reportID);
}
+/**
+ * This will find an existing chat, or create a new one if none exists, for the given accountID or set of accountIDs. It will then navigate to this chat.
+ *
+ * @param {Array} participantAccountIDs of user logins to start a chat report with.
+ */
+function navigateToAndOpenReportWithAccountIDs(participantAccountIDs) {
+ let newChat = {};
+ const chat = ReportUtils.getChatByParticipants(participantAccountIDs);
+ if (!chat) {
+ newChat = ReportUtils.buildOptimisticChatReport(participantAccountIDs);
+ }
+ const reportID = chat ? chat.reportID : newChat.reportID;
+
+ // We want to pass newChat here because if anything is passed in that param (even an existing chat), we will try to create a chat on the server
+ openReport(reportID, [], newChat, '0', false, participantAccountIDs);
+ Navigation.dismissModal(reportID);
+}
+
/**
* This will navigate to an existing thread, or create a new one if necessary
*
@@ -1825,6 +1845,7 @@ export {
openReport,
openReportFromDeepLink,
navigateToAndOpenReport,
+ navigateToAndOpenReportWithAccountIDs,
navigateToAndOpenChildReport,
updatePolicyRoomNameAndNavigate,
clearPolicyRoomNameErrors,
diff --git a/src/pages/ProfilePage.js b/src/pages/ProfilePage.js
index 41a5d153f0cc..2b69c541c44d 100755
--- a/src/pages/ProfilePage.js
+++ b/src/pages/ProfilePage.js
@@ -6,6 +6,7 @@ import {withOnyx} from 'react-native-onyx';
import Str from 'expensify-common/lib/str';
import lodashGet from 'lodash/get';
import {parsePhoneNumber} from 'awesome-phonenumber';
+import * as Session from '../libs/actions/Session';
import styles from '../styles/styles';
import Text from '../components/Text';
import ONYXKEYS from '../ONYXKEYS';
@@ -90,7 +91,7 @@ const getPhoneNumber = (details) => {
};
function ProfilePage(props) {
- const accountID = lodashGet(props.route.params, 'accountID', 0);
+ const accountID = Number(lodashGet(props.route.params, 'accountID', 0));
// eslint-disable-next-line rulesdir/prefer-early-return
useEffect(() => {
@@ -200,11 +201,11 @@ function ProfilePage(props) {
) : null}
{shouldShowLocalTime && }
- {!isCurrentUser && Boolean(login) && (
+ {!isCurrentUser && !Session.isAnonymousUser() && (