Skip to content

Commit 575d0ff

Browse files
authored
Merge pull request #38738 from software-mansion-labs/hold-requests/break-message
[Held requests] break held message into separate system message + comment
2 parents 7e4a438 + 2a8a0f7 commit 575d0ff

File tree

9 files changed

+49
-10
lines changed

9 files changed

+49
-10
lines changed

src/CONST.ts

+1
Original file line numberDiff line numberDiff line change
@@ -630,6 +630,7 @@ const CONST = {
630630
EXPORTEDTOQUICKBOOKS: 'EXPORTEDTOQUICKBOOKS', // OldDot Action
631631
FORWARDED: 'FORWARDED', // OldDot Action
632632
HOLD: 'HOLD',
633+
HOLDCOMMENT: 'HOLDCOMMENT',
633634
IOU: 'IOU',
634635
INTEGRATIONSMESSAGE: 'INTEGRATIONSMESSAGE', // OldDot Action
635636
MANAGERATTACHRECEIPT: 'MANAGERATTACHRECEIPT', // OldDot Action

src/languages/en.ts

+1-2
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@ import type {
2727
FormattedMaxLengthParams,
2828
GoBackMessageParams,
2929
GoToRoomParams,
30-
HeldRequestParams,
3130
InstantSummaryParams,
3231
LocalTimeParams,
3332
LoggedInAsParams,
@@ -692,7 +691,7 @@ export default {
692691
hold: 'Hold',
693692
holdRequest: 'Hold request',
694693
unholdRequest: 'Unhold request',
695-
heldRequest: ({comment}: HeldRequestParams) => `held this request with the comment: ${comment}`,
694+
heldRequest: 'held this request',
696695
unheldRequest: 'unheld this request',
697696
explainHold: "Explain why you're holding this request.",
698697
reason: 'Reason',

src/languages/es.ts

+1-2
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@ import type {
2626
FormattedMaxLengthParams,
2727
GoBackMessageParams,
2828
GoToRoomParams,
29-
HeldRequestParams,
3029
InstantSummaryParams,
3130
LocalTimeParams,
3231
LoggedInAsParams,
@@ -689,7 +688,7 @@ export default {
689688
enableWallet: 'Habilitar Billetera',
690689
holdRequest: 'Bloquear solicitud',
691690
unholdRequest: 'Desbloquear solicitud',
692-
heldRequest: ({comment}: HeldRequestParams) => `bloqueó esta solicitud con el comentario: ${comment}`,
691+
heldRequest: 'bloqueó esta solicitud',
693692
unheldRequest: 'desbloqueó esta solicitud',
694693
explainHold: 'Explica la razón para bloquear esta solicitud.',
695694
reason: 'Razón',

src/libs/API/parameters/HoldMoneyRequestParams.ts

+1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ type HoldMoneyRequestParams = {
22
transactionID: string;
33
comment: string;
44
reportActionID: string;
5+
commentReportActionID: string;
56
};
67

78
export default HoldMoneyRequestParams;

src/libs/ReportUtils.ts

+31-3
Original file line numberDiff line numberDiff line change
@@ -3787,7 +3787,7 @@ function buildOptimisticRenamedRoomReportAction(newName: string, oldName: string
37873787
* Returns the necessary reportAction onyx data to indicate that the transaction has been put on hold optimistically
37883788
* @param [created] - Action created time
37893789
*/
3790-
function buildOptimisticHoldReportAction(comment: string, created = DateUtils.getDBTime()): OptimisticHoldReportAction {
3790+
function buildOptimisticHoldReportAction(created = DateUtils.getDBTime()): OptimisticHoldReportAction {
37913791
return {
37923792
reportActionID: NumberUtils.rand64(),
37933793
actionName: CONST.REPORT.ACTIONS.TYPE.HOLD,
@@ -3797,10 +3797,37 @@ function buildOptimisticHoldReportAction(comment: string, created = DateUtils.ge
37973797
{
37983798
type: CONST.REPORT.MESSAGE.TYPE.TEXT,
37993799
style: 'normal',
3800-
text: Localize.translateLocal('iou.heldRequest', {comment}),
3800+
text: Localize.translateLocal('iou.heldRequest'),
38013801
},
3802+
],
3803+
person: [
38023804
{
3803-
type: CONST.REPORT.MESSAGE.TYPE.COMMENT,
3805+
type: CONST.REPORT.MESSAGE.TYPE.TEXT,
3806+
style: 'strong',
3807+
text: getCurrentUserDisplayNameOrEmail(),
3808+
},
3809+
],
3810+
automatic: false,
3811+
avatar: getCurrentUserAvatarOrDefault(),
3812+
created,
3813+
shouldShow: true,
3814+
};
3815+
}
3816+
3817+
/**
3818+
* Returns the necessary reportAction onyx data to indicate that the transaction has been put on hold optimistically
3819+
* @param [created] - Action created time
3820+
*/
3821+
function buildOptimisticHoldReportActionComment(comment: string, created = DateUtils.getDBTime()): OptimisticHoldReportAction {
3822+
return {
3823+
reportActionID: NumberUtils.rand64(),
3824+
actionName: CONST.REPORT.ACTIONS.TYPE.HOLDCOMMENT,
3825+
pendingAction: CONST.RED_BRICK_ROAD_PENDING_ACTION.ADD,
3826+
actorAccountID: currentUserAccountID,
3827+
message: [
3828+
{
3829+
type: CONST.REPORT.MESSAGE.TYPE.TEXT,
3830+
style: 'normal',
38043831
text: comment,
38053832
},
38063833
],
@@ -5649,6 +5676,7 @@ export {
56495676
hasSmartscanError,
56505677
shouldAutoFocusOnKeyPress,
56515678
buildOptimisticHoldReportAction,
5679+
buildOptimisticHoldReportActionComment,
56525680
buildOptimisticUnHoldReportAction,
56535681
shouldDisplayThreadReplies,
56545682
shouldDisableThread,

src/libs/actions/IOU.ts

+4-1
Original file line numberDiff line numberDiff line change
@@ -5031,14 +5031,16 @@ function getIOUReportID(iou?: OnyxTypes.IOU, route?: MoneyRequestRoute): string
50315031
* Put money request on HOLD
50325032
*/
50335033
function putOnHold(transactionID: string, comment: string, reportID: string) {
5034-
const createdReportAction = ReportUtils.buildOptimisticHoldReportAction(comment);
5034+
const createdReportAction = ReportUtils.buildOptimisticHoldReportAction();
5035+
const createdReportActionComment = ReportUtils.buildOptimisticHoldReportActionComment(comment);
50355036

50365037
const optimisticData: OnyxUpdate[] = [
50375038
{
50385039
onyxMethod: Onyx.METHOD.MERGE,
50395040
key: `${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${reportID}`,
50405041
value: {
50415042
[createdReportAction.reportActionID]: createdReportAction as ReportAction,
5043+
[createdReportActionComment.reportActionID]: createdReportActionComment as ReportAction,
50425044
},
50435045
},
50445046
{
@@ -5072,6 +5074,7 @@ function putOnHold(transactionID: string, comment: string, reportID: string) {
50725074
transactionID,
50735075
comment,
50745076
reportActionID: createdReportAction.reportActionID,
5077+
commentReportActionID: createdReportActionComment.reportActionID,
50755078
},
50765079
{optimisticData, successData, failureData},
50775080
);

src/pages/home/report/ContextMenu/ContextMenuActions.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -377,7 +377,7 @@ const ContextMenuActions: ContextMenuAction[] = [
377377
const mentionWhisperMessage = ReportActionsUtils.getActionableMentionWhisperMessage(reportAction);
378378
setClipboardMessage(mentionWhisperMessage);
379379
} else if (reportAction?.actionName === CONST.REPORT.ACTIONS.TYPE.HOLD) {
380-
Clipboard.setString(Localize.translateLocal('iou.heldRequest', {comment: reportAction.message?.[1]?.text ?? ''}));
380+
Clipboard.setString(Localize.translateLocal('iou.heldRequest'));
381381
} else if (reportAction?.actionName === CONST.REPORT.ACTIONS.TYPE.UNHOLD) {
382382
Clipboard.setString(Localize.translateLocal('iou.unheldRequest'));
383383
} else if (content) {

src/pages/home/report/ReportActionItem.tsx

+3-1
Original file line numberDiff line numberDiff line change
@@ -517,7 +517,9 @@ function ReportActionItem({
517517
// This handles all historical actions from OldDot that we just want to display the message text
518518
children = <ReportActionItemBasicMessage message={ReportActionsUtils.getMessageOfOldDotReportAction(action)} />;
519519
} else if (action.actionName === CONST.REPORT.ACTIONS.TYPE.HOLD) {
520-
children = <ReportActionItemBasicMessage message={translate('iou.heldRequest', {comment: action.message?.[1].text ?? ''})} />;
520+
children = <ReportActionItemBasicMessage message={translate('iou.heldRequest')} />;
521+
} else if (action.actionName === CONST.REPORT.ACTIONS.TYPE.HOLDCOMMENT) {
522+
children = <ReportActionItemBasicMessage message={action.message?.[0].text ?? ''} />;
521523
} else if (action.actionName === CONST.REPORT.ACTIONS.TYPE.UNHOLD) {
522524
children = <ReportActionItemBasicMessage message={translate('iou.unheldRequest')} />;
523525
} else {

src/types/onyx/OriginalMessage.ts

+6
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,11 @@ type OriginalMessageHold = {
3737
originalMessage: unknown;
3838
};
3939

40+
type OriginalMessageHoldComment = {
41+
actionName: typeof CONST.REPORT.ACTIONS.TYPE.HOLDCOMMENT;
42+
originalMessage: unknown;
43+
};
44+
4045
type OriginalMessageUnHold = {
4146
actionName: typeof CONST.REPORT.ACTIONS.TYPE.UNHOLD;
4247
originalMessage: unknown;
@@ -301,6 +306,7 @@ type OriginalMessage =
301306
| OriginalMessageClosed
302307
| OriginalMessageCreated
303308
| OriginalMessageHold
309+
| OriginalMessageHoldComment
304310
| OriginalMessageUnHold
305311
| OriginalMessageRenamed
306312
| OriginalMessageChronosOOOList

0 commit comments

Comments
 (0)