Skip to content

Commit d009edf

Browse files
authored
Merge pull request Expensify#57820 from daledah/fix/57525
fix: show #admin room when invite user through actionable whisper
2 parents 1237390 + fb4b7ed commit d009edf

File tree

2 files changed

+134
-0
lines changed

2 files changed

+134
-0
lines changed

src/libs/ReportActionsUtils.ts

+4
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,10 @@ function isCreatedAction(reportAction: OnyxInputOrEntry<ReportAction>): boolean
146146
}
147147

148148
function isDeletedAction(reportAction: OnyxInputOrEntry<ReportAction | OptimisticIOUReportAction>): boolean {
149+
if (isInviteOrRemovedAction(reportAction)) {
150+
return false;
151+
}
152+
149153
const message = reportAction?.message ?? [];
150154

151155
if (!Array.isArray(message)) {

tests/unit/ReportActionsUtilsTest.ts

+130
Original file line numberDiff line numberDiff line change
@@ -714,4 +714,134 @@ describe('ReportActionsUtils', () => {
714714
expect(res).toEqual(false);
715715
});
716716
});
717+
718+
describe('isDeletedAction', () => {
719+
it('should return true if reportAction is undefined', () => {
720+
expect(ReportActionsUtils.isDeletedAction(undefined)).toBe(true);
721+
});
722+
723+
it('should return false for POLICY_CHANGE_LOG.INVITE_TO_ROOM action', () => {
724+
const reportAction = {
725+
actionName: CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.INVITE_TO_ROOM,
726+
originalMessage: {
727+
html: '',
728+
whisperedTo: [],
729+
},
730+
reportActionID: '1',
731+
created: '1',
732+
};
733+
expect(ReportActionsUtils.isDeletedAction(reportAction)).toBe(false);
734+
});
735+
736+
it('should return true if message is an empty array', () => {
737+
const reportAction = {
738+
created: '2022-11-09 22:27:01.825',
739+
reportActionID: '8401445780099176',
740+
actionName: CONST.REPORT.ACTIONS.TYPE.ADD_COMMENT,
741+
originalMessage: {
742+
html: 'Hello world',
743+
whisperedTo: [],
744+
},
745+
};
746+
expect(ReportActionsUtils.isDeletedAction(reportAction)).toBe(true);
747+
});
748+
749+
it('should return true if message html is empty', () => {
750+
const reportAction = {
751+
created: '2022-11-09 22:27:01.825',
752+
reportActionID: '8401445780099176',
753+
actionName: CONST.REPORT.ACTIONS.TYPE.ADD_COMMENT,
754+
originalMessage: {
755+
html: 'Hello world',
756+
whisperedTo: [],
757+
},
758+
message: {
759+
html: '',
760+
type: 'Action type',
761+
text: 'Action text',
762+
},
763+
};
764+
expect(ReportActionsUtils.isDeletedAction(reportAction)).toBe(true);
765+
});
766+
767+
it('should return true if message is not an array and deleted is not empty', () => {
768+
const reportAction = {
769+
created: '2022-11-09 22:27:01.825',
770+
reportActionID: '8401445780099176',
771+
actionName: CONST.REPORT.ACTIONS.TYPE.ADD_COMMENT,
772+
originalMessage: {
773+
html: 'Hello world',
774+
whisperedTo: [],
775+
},
776+
message: {
777+
html: 'Hello world',
778+
deleted: 'deleted',
779+
type: 'Action type',
780+
text: 'Action text',
781+
},
782+
};
783+
expect(ReportActionsUtils.isDeletedAction(reportAction)).toBe(true);
784+
});
785+
786+
it('should return true if message an array and first element deleted is not empty', () => {
787+
const reportAction = {
788+
created: '2022-11-09 22:27:01.825',
789+
reportActionID: '8401445780099176',
790+
actionName: CONST.REPORT.ACTIONS.TYPE.ADD_COMMENT,
791+
originalMessage: {
792+
html: 'Hello world',
793+
whisperedTo: [],
794+
},
795+
message: [
796+
{
797+
html: 'Hello world',
798+
deleted: 'deleted',
799+
type: 'Action type',
800+
text: 'Action text',
801+
},
802+
],
803+
};
804+
expect(ReportActionsUtils.isDeletedAction(reportAction)).toBe(true);
805+
});
806+
807+
it('should return true if message is an object with html field with empty string as value is empty', () => {
808+
const reportAction = {
809+
created: '2022-11-09 22:27:01.825',
810+
reportActionID: '8401445780099176',
811+
actionName: CONST.REPORT.ACTIONS.TYPE.ADD_COMMENT,
812+
originalMessage: {
813+
html: 'Hello world',
814+
whisperedTo: [],
815+
},
816+
message: [
817+
{
818+
html: '',
819+
type: 'Action type',
820+
text: 'Action text',
821+
},
822+
],
823+
};
824+
expect(ReportActionsUtils.isDeletedAction(reportAction)).toBe(true);
825+
});
826+
827+
it('should return false otherwise', () => {
828+
const reportAction = {
829+
created: '2022-11-09 22:27:01.825',
830+
reportActionID: '8401445780099176',
831+
actionName: CONST.REPORT.ACTIONS.TYPE.ADD_COMMENT,
832+
originalMessage: {
833+
html: 'Hello world',
834+
whisperedTo: [],
835+
},
836+
message: [
837+
{
838+
html: 'Hello world',
839+
type: 'Action type',
840+
text: 'Action text',
841+
},
842+
],
843+
};
844+
expect(ReportActionsUtils.isDeletedAction(reportAction)).toBe(false);
845+
});
846+
});
717847
});

0 commit comments

Comments
 (0)