Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Unable to send a reply in thread after leaving the thread in offline mode #35869

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 5 additions & 23 deletions src/libs/actions/Report.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2179,7 +2179,7 @@ function getCurrentUserAccountID(): number {
}

/** Leave a report by setting the state to submitted and closed */
function leaveRoom(reportID: string, isWorkspaceMemberLeavingWorkspaceRoom = false) {
function leaveRoom(reportID: string) {
const report = currentReportData?.[reportID];

if (!report) {
Expand All @@ -2197,31 +2197,13 @@ function leaveRoom(reportID: string, isWorkspaceMemberLeavingWorkspaceRoom = fal
{
onyxMethod: Onyx.METHOD.MERGE,
key: `${ONYXKEYS.COLLECTION.REPORT}${reportID}`,
value: isWorkspaceMemberLeavingWorkspaceRoom
? {
notificationPreference: CONST.REPORT.NOTIFICATION_PREFERENCE.HIDDEN,
}
: {
reportID: null,
stateNum: CONST.REPORT.STATE_NUM.APPROVED,
statusNum: CONST.REPORT.STATUS_NUM.CLOSED,
notificationPreference: CONST.REPORT.NOTIFICATION_PREFERENCE.HIDDEN,
},
value: {
notificationPreference: CONST.REPORT.NOTIFICATION_PREFERENCE.HIDDEN,
},
},
];

const successData: OnyxUpdate[] = [
{
onyxMethod: Onyx.METHOD.MERGE,
key: `${ONYXKEYS.COLLECTION.REPORT}${reportID}`,
value: isWorkspaceMemberLeavingWorkspaceRoom
? {notificationPreference: CONST.REPORT.NOTIFICATION_PREFERENCE.HIDDEN}
: Object.keys(report).reduce<Record<string, null>>((acc, key) => {
acc[key] = null;
return acc;
}, {}),
},
];
const successData: OnyxUpdate[] = [];

const failureData: OnyxUpdate[] = [
{
Expand Down
3 changes: 1 addition & 2 deletions src/pages/home/HeaderView.js
Original file line number Diff line number Diff line change
Expand Up @@ -163,11 +163,10 @@ function HeaderView(props) {
onSelected: join,
});
} else if (canLeave) {
const isWorkspaceMemberLeavingWorkspaceRoom = !isChatThread && lodashGet(props.report, 'visibility', '') === CONST.REPORT.VISIBILITY.RESTRICTED && isPolicyMember;
threeDotMenuItems.push({
icon: Expensicons.ChatBubbles,
text: translate('common.leave'),
onSelected: Session.checkIfActionIsAllowed(() => Report.leaveRoom(props.reportID, isWorkspaceMemberLeavingWorkspaceRoom)),
onSelected: Session.checkIfActionIsAllowed(() => Report.leaveRoom(props.reportID)),
});
}

Expand Down
Loading