From ce8e379365fdafb576cf59d4dcca05657308c36d Mon Sep 17 00:00:00 2001 From: Jack Nam Date: Tue, 19 Mar 2024 12:41:08 -0700 Subject: [PATCH 01/70] Basic handling for new ACTIONABLETRACKEXPENSEWHISPER --- src/CONST.ts | 3 ++- src/languages/en.ts | 6 +++++ src/languages/es.ts | 6 +++++ src/libs/ReportActionsUtils.ts | 5 ++++ src/pages/home/report/ReportActionItem.tsx | 29 ++++++++++++++++++++++ src/types/onyx/OriginalMessage.ts | 1 + 6 files changed, 49 insertions(+), 1 deletion(-) diff --git a/src/CONST.ts b/src/CONST.ts index 43ccd6062505..183c2b2beefd 100755 --- a/src/CONST.ts +++ b/src/CONST.ts @@ -611,9 +611,10 @@ const CONST = { LIMIT: 50, // OldDot Actions render getMessage from Web-Expensify/lib/Report/Action PHP files via getMessageOfOldDotReportAction in ReportActionsUtils.ts TYPE: { + ACTIONABLEJOINREQUEST: 'ACTIONABLEJOINREQUEST', ACTIONABLEMENTIONWHISPER: 'ACTIONABLEMENTIONWHISPER', + ACTIONABLETRACKEXPENSEWHISPER: 'ACTIONABLETRACKEXPENSEWHISPER', ADDCOMMENT: 'ADDCOMMENT', - ACTIONABLEJOINREQUEST: 'ACTIONABLEJOINREQUEST', APPROVED: 'APPROVED', CHANGEFIELD: 'CHANGEFIELD', // OldDot Action CHANGEPOLICY: 'CHANGEPOLICY', // OldDot Action diff --git a/src/languages/en.ts b/src/languages/en.ts index 9bf33638d880..45502177aa27 100755 --- a/src/languages/en.ts +++ b/src/languages/en.ts @@ -2371,6 +2371,12 @@ export default { accept: 'Accept', decline: 'Decline', }, + actionableMentionTrackExpense: { + request: 'Request someone to pay it', + categorize: 'Categorize it', + share: 'Share it with my accountant', + nothing: 'Nothing for now' + }, teachersUnitePage: { teachersUnite: 'Teachers Unite', joinExpensifyOrg: 'Join Expensify.org in eliminating injustice around the world and help teachers split their expenses for classrooms in need!', diff --git a/src/languages/es.ts b/src/languages/es.ts index b4d7465244b7..249717f3ef23 100644 --- a/src/languages/es.ts +++ b/src/languages/es.ts @@ -2840,6 +2840,12 @@ export default { accept: 'Aceptar', decline: 'Rechazar', }, + actionableMentionTrackExpense: { + request: 'Request someone to pay it', + categorize: 'Categorize it', + share: 'Share it with my accountant', + nothing: 'Nothing for now' + }, moderation: { flagDescription: 'Todos los mensajes marcados se enviarán a un moderador para su revisión.', chooseAReason: 'Elige abajo un motivo para reportarlo:', diff --git a/src/libs/ReportActionsUtils.ts b/src/libs/ReportActionsUtils.ts index 206c3ecd75a6..9a0cb2ac6fb5 100644 --- a/src/libs/ReportActionsUtils.ts +++ b/src/libs/ReportActionsUtils.ts @@ -943,6 +943,10 @@ function isActionableJoinRequest(reportAction: OnyxEntry): boolean return reportAction?.actionName === CONST.REPORT.ACTIONS.TYPE.ACTIONABLEJOINREQUEST; } +function isActionableTrackExpense(reportAction: OnyxEntry): boolean { + return reportAction?.actionName === CONST.REPORT.ACTIONS.TYPE.ACTIONABLETRACKEXPENSEWHISPER; +} + /** * Checks if any report actions correspond to a join request action that is still pending. * @param reportID @@ -1025,6 +1029,7 @@ export { isCurrentActionUnread, isActionableJoinRequest, isActionableJoinRequestPending, + isActionableTrackExpense, }; export type {LastVisibleMessage}; diff --git a/src/pages/home/report/ReportActionItem.tsx b/src/pages/home/report/ReportActionItem.tsx index 85e66cac3324..d41ac9ecf783 100644 --- a/src/pages/home/report/ReportActionItem.tsx +++ b/src/pages/home/report/ReportActionItem.tsx @@ -370,6 +370,35 @@ function ReportActionItem({ return []; } + if (ReportActionUtils.isActionableTrackExpense()) { + return [ + { + text: 'actionableMentionTrackExpense.request', + key: `${action.reportActionID}-actionableMentionTrackExpense-request`, + onPress: () => console.log('Track'), + isPrimary: true, + }, + { + text: 'actionableMentionTrackExpense.categorize', + key: `${action.reportActionID}-actionableMentionTrackExpense-categorize`, + onPress: () => console.log('Categorize'), + isPrimary: true, + }, + { + text: 'actionableMentionTrackExpense.share', + key: `${action.reportActionID}-actionableMentionTrackExpense-share`, + onPress: () => console.log('Share'), + isPrimary: true, + }, + { + text: 'actionableMentionTrackExpense.nothing', + key: `${action.reportActionID}-actionableMentionTrackExpense-nothing`, + onPress: () => console.log('Nothing'), + isPrimary: true, + }, + ]; + } + if (ReportActionsUtils.isActionableJoinRequest(action)) { return [ { diff --git a/src/types/onyx/OriginalMessage.ts b/src/types/onyx/OriginalMessage.ts index e3ba941482a0..9b28b5aae8af 100644 --- a/src/types/onyx/OriginalMessage.ts +++ b/src/types/onyx/OriginalMessage.ts @@ -25,6 +25,7 @@ type OriginalMessageActionName = | 'TASKREOPENED' | 'ACTIONABLEJOINREQUEST' | 'ACTIONABLEMENTIONWHISPER' + | 'ACTIONABLETRACKEXPENSEWHISPER' | ValueOf; type OriginalMessageApproved = { actionName: typeof CONST.REPORT.ACTIONS.TYPE.APPROVED; From cb398c2eba7a8adb1d8ffaf8cb814029e9121af6 Mon Sep 17 00:00:00 2001 From: Jack Nam Date: Tue, 19 Mar 2024 12:48:30 -0700 Subject: [PATCH 02/70] Show buttons --- src/pages/home/report/ContextMenu/ContextMenuActions.tsx | 5 ++++- src/pages/home/report/ReportActionItem.tsx | 4 ++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/src/pages/home/report/ContextMenu/ContextMenuActions.tsx b/src/pages/home/report/ContextMenu/ContextMenuActions.tsx index c5ab9bbff1f5..5687a5202bac 100644 --- a/src/pages/home/report/ContextMenu/ContextMenuActions.tsx +++ b/src/pages/home/report/ContextMenu/ContextMenuActions.tsx @@ -376,7 +376,10 @@ const ContextMenuActions: ContextMenuAction[] = [ } else if (ReportActionsUtils.isActionableMentionWhisper(reportAction)) { const mentionWhisperMessage = ReportActionsUtils.getActionableMentionWhisperMessage(reportAction); setClipboardMessage(mentionWhisperMessage); - } else if (reportAction?.actionName === CONST.REPORT.ACTIONS.TYPE.HOLD) { + } else if (ReportActionsUtils.isActionableTrackExpense(reportAction)) { + setClipboardMessage("What would you like to do with this expense?"); + } + else if (reportAction?.actionName === CONST.REPORT.ACTIONS.TYPE.HOLD) { Clipboard.setString(Localize.translateLocal('iou.heldRequest', {comment: reportAction.message?.[1]?.text ?? ''})); } else if (reportAction?.actionName === CONST.REPORT.ACTIONS.TYPE.UNHOLD) { Clipboard.setString(Localize.translateLocal('iou.unheldRequest')); diff --git a/src/pages/home/report/ReportActionItem.tsx b/src/pages/home/report/ReportActionItem.tsx index d41ac9ecf783..bda9a7241570 100644 --- a/src/pages/home/report/ReportActionItem.tsx +++ b/src/pages/home/report/ReportActionItem.tsx @@ -366,11 +366,11 @@ function ReportActionItem({ const isWhisperResolution = (action?.originalMessage as OriginalMessageActionableMentionWhisper['originalMessage'])?.resolution !== null; const isJoinChoice = (action?.originalMessage as OriginalMessageJoinPolicyChangeLog['originalMessage'])?.choice === ''; - if (!((ReportActionsUtils.isActionableMentionWhisper(action) && isWhisperResolution) || (ReportActionsUtils.isActionableJoinRequest(action) && isJoinChoice))) { + if (!((ReportActionsUtils.isActionableMentionWhisper(action) && isWhisperResolution) || (ReportActionsUtils.isActionableJoinRequest(action) && isJoinChoice) || ReportActionsUtils.isActionableTrackExpense(action))) { return []; } - if (ReportActionUtils.isActionableTrackExpense()) { + if (ReportActionsUtils.isActionableTrackExpense(action)) { return [ { text: 'actionableMentionTrackExpense.request', From bb4483fb5877b1121137e650c603896212d47844 Mon Sep 17 00:00:00 2001 From: Ishpaul Singh Date: Thu, 21 Mar 2024 02:15:17 +0530 Subject: [PATCH 03/70] adds a draft transaction while moving a tracked to request someone --- .../ActionableItemButtons.tsx | 8 +- src/languages/en.ts | 2 +- src/languages/es.ts | 2 +- src/libs/Permissions.ts | 2 +- src/libs/ReportUtils.ts | 12 +++ src/libs/TransactionUtils.ts | 4 +- .../report/ContextMenu/ContextMenuActions.tsx | 5 +- src/pages/home/report/ReportActionItem.tsx | 75 +++++++++++-------- 8 files changed, 68 insertions(+), 42 deletions(-) diff --git a/src/components/ReportActionItem/ActionableItemButtons.tsx b/src/components/ReportActionItem/ActionableItemButtons.tsx index 6ead20d3e643..8e5590537f51 100644 --- a/src/components/ReportActionItem/ActionableItemButtons.tsx +++ b/src/components/ReportActionItem/ActionableItemButtons.tsx @@ -10,10 +10,12 @@ type ActionableItem = { key: string; onPress: () => void; text: TranslationPaths; + isMediumSized?: boolean; }; type ActionableItemButtonsProps = { items: ActionableItem[]; + layout?: 'horizontal' | 'vertical'; }; function ActionableItemButtons(props: ActionableItemButtonsProps) { @@ -21,14 +23,14 @@ function ActionableItemButtons(props: ActionableItemButtonsProps) { const {translate} = useLocalize(); return ( - + {props.items?.map((item) => (