Skip to content

Commit

Permalink
Merge pull request Expensify#57820 from daledah/fix/57525
Browse files Browse the repository at this point in the history
fix: show #admin room when invite user through actionable whisper
  • Loading branch information
nkuoch authored Mar 10, 2025
2 parents 1237390 + fb4b7ed commit d009edf
Show file tree
Hide file tree
Showing 2 changed files with 134 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/libs/ReportActionsUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,10 @@ function isCreatedAction(reportAction: OnyxInputOrEntry<ReportAction>): boolean
}

function isDeletedAction(reportAction: OnyxInputOrEntry<ReportAction | OptimisticIOUReportAction>): boolean {
if (isInviteOrRemovedAction(reportAction)) {
return false;
}

const message = reportAction?.message ?? [];

if (!Array.isArray(message)) {
Expand Down
130 changes: 130 additions & 0 deletions tests/unit/ReportActionsUtilsTest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -714,4 +714,134 @@ describe('ReportActionsUtils', () => {
expect(res).toEqual(false);
});
});

describe('isDeletedAction', () => {
it('should return true if reportAction is undefined', () => {
expect(ReportActionsUtils.isDeletedAction(undefined)).toBe(true);
});

it('should return false for POLICY_CHANGE_LOG.INVITE_TO_ROOM action', () => {
const reportAction = {
actionName: CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.INVITE_TO_ROOM,
originalMessage: {
html: '',
whisperedTo: [],
},
reportActionID: '1',
created: '1',
};
expect(ReportActionsUtils.isDeletedAction(reportAction)).toBe(false);
});

it('should return true if message is an empty array', () => {
const reportAction = {
created: '2022-11-09 22:27:01.825',
reportActionID: '8401445780099176',
actionName: CONST.REPORT.ACTIONS.TYPE.ADD_COMMENT,
originalMessage: {
html: 'Hello world',
whisperedTo: [],
},
};
expect(ReportActionsUtils.isDeletedAction(reportAction)).toBe(true);
});

it('should return true if message html is empty', () => {
const reportAction = {
created: '2022-11-09 22:27:01.825',
reportActionID: '8401445780099176',
actionName: CONST.REPORT.ACTIONS.TYPE.ADD_COMMENT,
originalMessage: {
html: 'Hello world',
whisperedTo: [],
},
message: {
html: '',
type: 'Action type',
text: 'Action text',
},
};
expect(ReportActionsUtils.isDeletedAction(reportAction)).toBe(true);
});

it('should return true if message is not an array and deleted is not empty', () => {
const reportAction = {
created: '2022-11-09 22:27:01.825',
reportActionID: '8401445780099176',
actionName: CONST.REPORT.ACTIONS.TYPE.ADD_COMMENT,
originalMessage: {
html: 'Hello world',
whisperedTo: [],
},
message: {
html: 'Hello world',
deleted: 'deleted',
type: 'Action type',
text: 'Action text',
},
};
expect(ReportActionsUtils.isDeletedAction(reportAction)).toBe(true);
});

it('should return true if message an array and first element deleted is not empty', () => {
const reportAction = {
created: '2022-11-09 22:27:01.825',
reportActionID: '8401445780099176',
actionName: CONST.REPORT.ACTIONS.TYPE.ADD_COMMENT,
originalMessage: {
html: 'Hello world',
whisperedTo: [],
},
message: [
{
html: 'Hello world',
deleted: 'deleted',
type: 'Action type',
text: 'Action text',
},
],
};
expect(ReportActionsUtils.isDeletedAction(reportAction)).toBe(true);
});

it('should return true if message is an object with html field with empty string as value is empty', () => {
const reportAction = {
created: '2022-11-09 22:27:01.825',
reportActionID: '8401445780099176',
actionName: CONST.REPORT.ACTIONS.TYPE.ADD_COMMENT,
originalMessage: {
html: 'Hello world',
whisperedTo: [],
},
message: [
{
html: '',
type: 'Action type',
text: 'Action text',
},
],
};
expect(ReportActionsUtils.isDeletedAction(reportAction)).toBe(true);
});

it('should return false otherwise', () => {
const reportAction = {
created: '2022-11-09 22:27:01.825',
reportActionID: '8401445780099176',
actionName: CONST.REPORT.ACTIONS.TYPE.ADD_COMMENT,
originalMessage: {
html: 'Hello world',
whisperedTo: [],
},
message: [
{
html: 'Hello world',
type: 'Action type',
text: 'Action text',
},
],
};
expect(ReportActionsUtils.isDeletedAction(reportAction)).toBe(false);
});
});
});

0 comments on commit d009edf

Please sign in to comment.