Skip to content

Commit

Permalink
Merge pull request #57551 from Expensify/dsilva_changesToAcceptJoinRe…
Browse files Browse the repository at this point in the history
…quest
  • Loading branch information
blimpich authored Feb 27, 2025
2 parents d8790a4 + 07ab714 commit 7bda731
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 7 deletions.
12 changes: 8 additions & 4 deletions src/libs/actions/Policy/Member.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1010,11 +1010,13 @@ function acceptJoinRequest(reportID: string | undefined, reportAction: OnyxEntry
},
},
];

const accountIDToApprove = ReportActionsUtils.isActionableJoinRequest(reportAction)
? ReportActionsUtils.getOriginalMessage(reportAction)?.accountID ?? reportAction?.actorAccountID
: CONST.DEFAULT_NUMBER_ID;
const parameters = {
requests: JSON.stringify({
[ReportActionsUtils.isActionableJoinRequest(reportAction) ? ReportActionsUtils.getOriginalMessage(reportAction)?.policyID ?? CONST.DEFAULT_NUMBER_ID : CONST.DEFAULT_NUMBER_ID]: {
requests: [{accountID: reportAction?.actorAccountID, adminsRoomMessageReportActionID: reportAction.reportActionID}],
requests: [{accountID: accountIDToApprove, adminsRoomMessageReportActionID: reportAction.reportActionID}],
},
}),
};
Expand Down Expand Up @@ -1069,11 +1071,13 @@ function declineJoinRequest(reportID: string | undefined, reportAction: OnyxEntr
},
},
];

const accountIDToApprove = ReportActionsUtils.isActionableJoinRequest(reportAction)
? ReportActionsUtils.getOriginalMessage(reportAction)?.accountID ?? reportAction?.actorAccountID
: CONST.DEFAULT_NUMBER_ID;
const parameters = {
requests: JSON.stringify({
[ReportActionsUtils.isActionableJoinRequest(reportAction) ? ReportActionsUtils.getOriginalMessage(reportAction)?.policyID ?? CONST.DEFAULT_NUMBER_ID : CONST.DEFAULT_NUMBER_ID]: {
requests: [{accountID: reportAction?.actorAccountID, adminsRoomMessageReportActionID: reportAction.reportActionID}],
requests: [{accountID: accountIDToApprove, adminsRoomMessageReportActionID: reportAction.reportActionID}],
},
}),
};
Expand Down
9 changes: 6 additions & 3 deletions src/types/onyx/OriginalMessage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -406,13 +406,16 @@ type OriginalMessagePolicyChangeLog = {
oldValue?: boolean | string;
};

/** Model of `join policy changelog` report action */
type OriginalMessageJoinPolicyChangeLog = {
/** Model of `join policy` report action */
type OriginalMessageJoinPolicy = {
/** What was the invited user decision */
choice: JoinWorkspaceResolution;

/** ID of the affected policy */
policyID: string;

/** AccountID for the user requesting to join the policy */
accountID?: number;
};

/** Model of `modified expense` report action */
Expand Down Expand Up @@ -719,7 +722,7 @@ type IssueNewCardOriginalMessage = OriginalMessage<
/* eslint-disable jsdoc/require-jsdoc */
type OriginalMessageMap = {
[CONST.REPORT.ACTIONS.TYPE.ACTIONABLE_ADD_PAYMENT_CARD]: OriginalMessageAddPaymentCard;
[CONST.REPORT.ACTIONS.TYPE.ACTIONABLE_JOIN_REQUEST]: OriginalMessageJoinPolicyChangeLog;
[CONST.REPORT.ACTIONS.TYPE.ACTIONABLE_JOIN_REQUEST]: OriginalMessageJoinPolicy;
[CONST.REPORT.ACTIONS.TYPE.ACTIONABLE_MENTION_WHISPER]: OriginalMessageActionableMentionWhisper;
[CONST.REPORT.ACTIONS.TYPE.ACTIONABLE_REPORT_MENTION_WHISPER]: OriginalMessageActionableReportMentionWhisper;
[CONST.REPORT.ACTIONS.TYPE.ACTIONABLE_TRACK_EXPENSE_WHISPER]: OriginalMessageActionableTrackedExpenseWhisper;
Expand Down

0 comments on commit 7bda731

Please sign in to comment.