Skip to content

Commit

Permalink
Merge pull request #19163 from Expensify/mountiny-cherry-pick-staging…
Browse files Browse the repository at this point in the history
…-18772

🍒 Cherry pick PR #18772 to staging 🍒
  • Loading branch information
OSBotify authored May 17, 2023
2 parents a931c8e + 4370582 commit 5c6b531
Show file tree
Hide file tree
Showing 15 changed files with 68 additions and 61 deletions.
4 changes: 2 additions & 2 deletions android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -106,8 +106,8 @@ android {
minSdkVersion rootProject.ext.minSdkVersion
targetSdkVersion rootProject.ext.targetSdkVersion
multiDexEnabled rootProject.ext.multiDexEnabled
versionCode 1001031508
versionName "1.3.15-8"
versionCode 1001031510
versionName "1.3.15-10"
}

splits {
Expand Down
2 changes: 1 addition & 1 deletion ios/NewExpensify/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
</dict>
</array>
<key>CFBundleVersion</key>
<string>1.3.15.8</string>
<string>1.3.15.10</string>
<key>ITSAppUsesNonExemptEncryption</key>
<false/>
<key>LSApplicationQueriesSchemes</key>
Expand Down
2 changes: 1 addition & 1 deletion ios/NewExpensifyTests/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,6 @@
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
<string>1.3.15.8</string>
<string>1.3.15.10</string>
</dict>
</plist>
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "new.expensify",
"version": "1.3.15-8",
"version": "1.3.15-10",
"author": "Expensify, Inc.",
"homepage": "https://new.expensify.com",
"description": "New Expensify is the next generation of Expensify: a reimagination of payments based atop a foundation of chat.",
Expand Down
1 change: 1 addition & 0 deletions src/languages/en.js
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,7 @@ export default {
enterManually: 'Enter it manually',
message: 'Message ',
leaveRoom: 'Leave room',
leaveThread: 'Leave thread',
you: 'You',
youAfterPreposition: 'you',
your: 'your',
Expand Down
1 change: 1 addition & 0 deletions src/languages/es.js
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,7 @@ export default {
enterManually: 'Introducir manualmente',
message: 'Chatear con ',
leaveRoom: 'Salir de la sala de chat',
leaveThread: 'Salir del hilo',
you: 'Tú',
youAfterPreposition: 'ti',
your: 'tu',
Expand Down
7 changes: 4 additions & 3 deletions src/libs/ReportUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -473,15 +473,16 @@ function isThreadFirstChat(reportAction, reportID) {
/**
* Get either the policyName or domainName the chat is tied to
* @param {Object} report
* @param {Object} parentReport
* @returns {String}
*/
function getChatRoomSubtitle(report, parentReport = null) {
function getChatRoomSubtitle(report) {
if (isThread(report)) {
if (!getChatType(report)) {
return '';
}

const parentReport = lodashGet(allReports, [`${ONYXKEYS.COLLECTION.REPORT}${report.parentReportID}`]);

// If thread is not from a DM or group chat, the subtitle will follow the pattern 'Workspace Name • #roomName'
const workspaceName = getPolicyName(report);
let roomName = '';
Expand Down Expand Up @@ -1113,7 +1114,7 @@ function getReportName(report) {
function navigateToDetailsPage(report) {
const participants = lodashGet(report, 'participants', []);

if (isChatRoom(report) || isPolicyExpenseChat(report)) {
if (isChatRoom(report) || isPolicyExpenseChat(report) || isThread(report)) {
Navigation.navigate(ROUTES.getReportDetailsRoute(report.reportID));
return;
}
Expand Down
3 changes: 1 addition & 2 deletions src/libs/SidebarUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -260,10 +260,9 @@ function getOptionData(reportID) {
result.tooltipText = ReportUtils.getReportParticipantsTitle(report.participants || []);
result.hasOutstandingIOU = report.hasOutstandingIOU;
result.parentReportID = report.parentReportID || null;

const parentReport = result.parentReportID ? chatReports[`${ONYXKEYS.COLLECTION.REPORT}${result.parentReportID}`] : null;
const hasMultipleParticipants = participantPersonalDetailList.length > 1 || result.isChatRoom || result.isPolicyExpenseChat;
const subtitle = ReportUtils.getChatRoomSubtitle(report, parentReport);
const subtitle = ReportUtils.getChatRoomSubtitle(report);

const login = Str.removeSMSDomain(lodashGet(personalDetail, 'login', ''));
const formattedLogin = Str.isSMSLogin(login) ? LocalePhoneNumber.formatPhoneNumber(login) : login;
Expand Down
38 changes: 0 additions & 38 deletions src/libs/actions/Policy.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ import * as OptionsListUtils from '../OptionsListUtils';
import DateUtils from '../DateUtils';
import * as ReportUtils from '../ReportUtils';
import Log from '../Log';
import * as Report from './Report';
import Permissions from '../Permissions';

const allPolicies = {};
Expand Down Expand Up @@ -1148,42 +1147,6 @@ function setWorkspaceInviteMembersDraft(policyID, memberEmails) {
Onyx.set(`${ONYXKEYS.COLLECTION.WORKSPACE_INVITE_MEMBERS_DRAFT}${policyID}`, memberEmails);
}

/**
*
* @param {String} reportID
*/
function leaveRoom(reportID) {
API.write(
'LeaveRoom',
{
reportID,
},
{
optimisticData: [
{
onyxMethod: Onyx.METHOD.SET,
key: `${ONYXKEYS.COLLECTION.REPORT}${reportID}`,
value: {
stateNum: CONST.REPORT.STATE_NUM.SUBMITTED,
statusNum: CONST.REPORT.STATUS.CLOSED,
},
},
],
failureData: [
{
onyxMethod: Onyx.METHOD.SET,
key: `${ONYXKEYS.COLLECTION.REPORT}${reportID}`,
value: {
stateNum: CONST.REPORT.STATE_NUM.OPEN,
statusNum: CONST.REPORT.STATUS.OPEN,
},
},
],
},
);
Report.navigateToConciergeChat();
}

export {
removeMembers,
addMembersToWorkspace,
Expand Down Expand Up @@ -1213,5 +1176,4 @@ export {
removeWorkspace,
setWorkspaceInviteMembersDraft,
isPolicyOwner,
leaveRoom,
};
38 changes: 38 additions & 0 deletions src/libs/actions/Report.js
Original file line number Diff line number Diff line change
Expand Up @@ -1585,6 +1585,43 @@ function openReportFromDeepLink(url) {
});
}

/**
* Leave a report by setting the state to submitted and closed
*
* @param {String} reportID
*/
function leaveRoom(reportID) {
API.write(
'LeaveRoom',
{
reportID,
},
{
optimisticData: [
{
onyxMethod: Onyx.METHOD.SET,
key: `${ONYXKEYS.COLLECTION.REPORT}${reportID}`,
value: {
stateNum: CONST.REPORT.STATE_NUM.SUBMITTED,
statusNum: CONST.REPORT.STATUS.CLOSED,
},
},
],
failureData: [
{
onyxMethod: Onyx.METHOD.SET,
key: `${ONYXKEYS.COLLECTION.REPORT}${reportID}`,
value: {
stateNum: CONST.REPORT.STATE_NUM.OPEN,
statusNum: CONST.REPORT.STATUS.OPEN,
},
},
],
},
);
navigateToConciergeChat();
}

export {
addComment,
addAttachment,
Expand Down Expand Up @@ -1626,4 +1663,5 @@ export {
toggleEmojiReaction,
hasAccountIDReacted,
shouldShowReportActionNotification,
leaveRoom,
};
14 changes: 8 additions & 6 deletions src/pages/ReportDetailsPage.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import styles from '../styles/styles';
import DisplayNames from '../components/DisplayNames';
import * as OptionsListUtils from '../libs/OptionsListUtils';
import * as ReportUtils from '../libs/ReportUtils';
import * as Policy from '../libs/actions/Policy';
import * as Report from '../libs/actions/Report';
import participantPropTypes from '../components/participantPropTypes';
import * as Expensicons from '../components/Icon/Expensicons';
import ROUTES from '../ROUTES';
Expand Down Expand Up @@ -82,7 +82,7 @@ class ReportDetailsPage extends Component {
});
}

if (ReportUtils.isPolicyExpenseChat(this.props.report) || ReportUtils.isChatRoom(this.props.report)) {
if (ReportUtils.isPolicyExpenseChat(this.props.report) || ReportUtils.isChatRoom(this.props.report) || ReportUtils.isThread(this.props.report)) {
menuItems.push({
key: CONST.REPORT_DETAILS_MENU_ITEM.SETTINGS,
translationKey: 'common.settings',
Expand All @@ -94,12 +94,13 @@ class ReportDetailsPage extends Component {
}

const policy = this.props.policies[`${ONYXKEYS.COLLECTION.POLICY}${this.props.report.policyID}`];
if (ReportUtils.isUserCreatedPolicyRoom(this.props.report) || ReportUtils.canLeaveRoom(this.props.report, !_.isEmpty(policy))) {
const isThread = ReportUtils.isThread(this.props.report);
if (ReportUtils.isUserCreatedPolicyRoom(this.props.report) || ReportUtils.canLeaveRoom(this.props.report, !_.isEmpty(policy)) || isThread) {
menuItems.push({
key: CONST.REPORT_DETAILS_MENU_ITEM.LEAVE_ROOM,
translationKey: 'common.leaveRoom',
translationKey: isThread ? 'common.leaveThread' : 'common.leaveRoom',
icon: Expensicons.Exit,
action: () => Policy.leaveRoom(this.props.report.reportID),
action: () => Report.leaveRoom(this.props.report.reportID),
});
}

Expand All @@ -109,6 +110,7 @@ class ReportDetailsPage extends Component {
render() {
const isPolicyExpenseChat = ReportUtils.isPolicyExpenseChat(this.props.report);
const isChatRoom = ReportUtils.isChatRoom(this.props.report);
const isThread = ReportUtils.isThread(this.props.report);
const chatRoomSubtitle = ReportUtils.getChatRoomSubtitle(this.props.report);
const participants = lodashGet(this.props.report, 'participants', []);
const isMultipleParticipant = participants.length > 1;
Expand Down Expand Up @@ -139,7 +141,7 @@ class ReportDetailsPage extends Component {
tooltipEnabled
numberOfLines={1}
textStyles={[styles.textHeadline, styles.mb2, styles.textAlignCenter, styles.pre]}
shouldUseFullTitle={isChatRoom || isPolicyExpenseChat}
shouldUseFullTitle={isChatRoom || isPolicyExpenseChat || isThread}
/>
</View>
<Text
Expand Down
6 changes: 4 additions & 2 deletions src/pages/ReportParticipantsPage.js
Original file line number Diff line number Diff line change
Expand Up @@ -86,10 +86,12 @@ const ReportParticipantsPage = (props) => {
{({safeAreaPaddingBottomStyle}) => (
<FullPageNotFoundView shouldShow={_.isEmpty(props.report)}>
<HeaderWithCloseButton
title={props.translate(ReportUtils.isChatRoom(props.report) || ReportUtils.isPolicyExpenseChat(props.report) ? 'common.members' : 'common.details')}
title={props.translate(
ReportUtils.isChatRoom(props.report) || ReportUtils.isPolicyExpenseChat(props.report) || ReportUtils.isThread(props.report) ? 'common.members' : 'common.details',
)}
onCloseButtonPress={Navigation.dismissModal}
onBackButtonPress={Navigation.goBack}
shouldShowBackButton={ReportUtils.isChatRoom(props.report) || ReportUtils.isPolicyExpenseChat(props.report)}
shouldShowBackButton={ReportUtils.isChatRoom(props.report) || ReportUtils.isPolicyExpenseChat(props.report) || ReportUtils.isThread(props.report)}
/>
<View
pointerEvents="box-none"
Expand Down
4 changes: 2 additions & 2 deletions src/pages/ReportSettingsPage.js
Original file line number Diff line number Diff line change
Expand Up @@ -143,9 +143,9 @@ class ReportSettingsPage extends Component {
}

render() {
const shouldShowRoomName = !ReportUtils.isPolicyExpenseChat(this.props.report);
const shouldShowRoomName = !ReportUtils.isPolicyExpenseChat(this.props.report) && !ReportUtils.isThread(this.props.report);
const linkedWorkspace = _.find(this.props.policies, (policy) => policy && policy.id === this.props.report.policyID);
const shouldDisableRename = this.shouldDisableRename(linkedWorkspace);
const shouldDisableRename = this.shouldDisableRename(linkedWorkspace) || ReportUtils.isThread(this.props.report);

return (
<ScreenWrapper>
Expand Down
3 changes: 2 additions & 1 deletion src/pages/ShareCodePage.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ class ShareCodePage extends React.Component {

render() {
const isReport = this.props.report != null && this.props.report.reportID != null;
const subtitle = ReportUtils.getChatRoomSubtitle(this.props.report);

const url = isReport ? `${CONST.NEW_EXPENSIFY_URL}r/${this.props.report.reportID}` : `${CONST.NEW_EXPENSIFY_URL}details?login=${this.props.session.email}`;

Expand All @@ -58,7 +59,7 @@ class ShareCodePage extends React.Component {
ref={this.qrCodeRef}
url={url}
title={isReport ? this.props.report.reportName : this.props.currentUserPersonalDetails.displayName}
subtitle={isReport ? ReportUtils.getPolicyName(this.props.report) : this.props.session.email}
subtitle={isReport ? subtitle : this.props.session.email}
logo={isReport ? roomAvatar : this.props.currentUserPersonalDetails.avatar}
/>
</View>
Expand Down

0 comments on commit 5c6b531

Please sign in to comment.