Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/CONST.ts
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,7 @@ const CONST = {
DISPLAY_NAME: {
MAX_LENGTH: 50,
RESERVED_NAMES: ['Expensify', 'Concierge'],
EXPENSIFY_CONCIERGE: 'Expensify Concierge',
},

GPS: {
Expand Down Expand Up @@ -3747,7 +3748,7 @@ const CONST = {

ONBOARDING_INTRODUCTION: 'Let’s get you set up 🔧',
ONBOARDING_CHOICES: {...onboardingChoices},

ACTIONABLE_TRACK_EXPENSE_WHISPER_MESSAGE: 'What would you like to do with this expense?',
ONBOARDING_CONCIERGE: {
[onboardingChoices.EMPLOYER]:
'# Expensify is the fastest way to get paid back!\n' +
Expand Down
1 change: 1 addition & 0 deletions src/libs/API/parameters/TrackExpenseParams.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ type TrackExpenseParams = {
transactionThreadReportID: string;
createdReportActionIDForThread: string;
waypoints?: string;
actionableWhisperReportActionID?: string;
};

export default TrackExpenseParams;
40 changes: 40 additions & 0 deletions src/libs/ReportUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4117,6 +4117,45 @@ function buildOptimisticReportPreview(chatReport: OnyxEntry<Report>, iouReport:
};
}

/**
* Builds an optimistic ACTIONABLETRACKEXPENSEWHISPER action with a randomly generated reportActionID.
*/
function buildOptimisticActionableTrackExpenseWhisper(iouAction: OptimisticIOUReportAction, transactionID: string): ReportAction {
const currentTime = DateUtils.getDBTime();
const targetEmail = CONST.EMAIL.CONCIERGE;
const actorAccountID = PersonalDetailsUtils.getAccountIDsByLogins([targetEmail])[0];
const reportActionID = NumberUtils.rand64();
return {
actionName: CONST.REPORT.ACTIONS.TYPE.ACTIONABLE_TRACK_EXPENSE_WHISPER,
actorAccountID,
avatar: UserUtils.getDefaultAvatarURL(actorAccountID),
created: DateUtils.addMillisecondsFromDateTime(currentTime, 1),
lastModified: DateUtils.addMillisecondsFromDateTime(currentTime, 1),
message: [
{
html: CONST.ACTIONABLE_TRACK_EXPENSE_WHISPER_MESSAGE,
text: CONST.ACTIONABLE_TRACK_EXPENSE_WHISPER_MESSAGE,
whisperedTo: [],
type: CONST.REPORT.MESSAGE.TYPE.COMMENT,
},
],
originalMessage: {
lastModified: DateUtils.addMillisecondsFromDateTime(currentTime, 1),
transactionID,
},
person: [
{
text: CONST.DISPLAY_NAME.EXPENSIFY_CONCIERGE,
type: 'TEXT',
},
],
previousReportActionID: iouAction?.reportActionID,
reportActionID,
shouldShow: true,
pendingAction: CONST.RED_BRICK_ROAD_PENDING_ACTION.ADD,
Comment thread
tienifr marked this conversation as resolved.
};
}

/**
* Builds an optimistic modified expense action with a randomly generated reportActionID.
*/
Expand Down Expand Up @@ -6702,6 +6741,7 @@ export {
buildOptimisticMovedTrackedExpenseModifiedReportAction,
buildOptimisticRenamedRoomReportAction,
buildOptimisticReportPreview,
buildOptimisticActionableTrackExpenseWhisper,
buildOptimisticSubmittedReportAction,
buildOptimisticTaskCommentReportAction,
buildOptimisticTaskReport,
Expand Down
45 changes: 44 additions & 1 deletion src/libs/actions/IOU.ts
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ type TrackExpenseInformation = {
reportPreviewAction?: OnyxTypes.ReportAction;
transactionThreadReportID: string;
createdReportActionIDForThread: string;
actionableWhisperReportActionIDParam?: string;
onyxData: OnyxData;
};

Expand Down Expand Up @@ -1150,6 +1151,7 @@ function buildOnyxDataForTrackExpense(
policyTagList?: OnyxEntry<OnyxTypes.PolicyTagList>,
policyCategories?: OnyxEntry<OnyxTypes.PolicyCategories>,
existingTransactionThreadReportID?: string,
actionableTrackExpenseWhisper?: OnyxEntry<OnyxTypes.ReportAction>,
): [OnyxUpdate[], OnyxUpdate[], OnyxUpdate[]] {
const isScanRequest = TransactionUtils.isScanRequest(transaction);
const isDistanceRequest = TransactionUtils.isDistanceRequest(transaction);
Expand Down Expand Up @@ -1189,6 +1191,36 @@ function buildOnyxDataForTrackExpense(
},
},
);

if (actionableTrackExpenseWhisper && !iouReport) {
Comment thread
tienifr marked this conversation as resolved.
optimisticData.push({
onyxMethod: Onyx.METHOD.MERGE,
key: `${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${chatReport?.reportID}`,
value: {
[actionableTrackExpenseWhisper.reportActionID]: actionableTrackExpenseWhisper,
},
});
optimisticData.push({
onyxMethod: Onyx.METHOD.MERGE,
key: `${ONYXKEYS.COLLECTION.REPORT}${chatReport.reportID}`,
value: {
lastVisibleActionCreated: actionableTrackExpenseWhisper.created,
Comment thread
tienifr marked this conversation as resolved.
lastMessageText: CONST.ACTIONABLE_TRACK_EXPENSE_WHISPER_MESSAGE,
},
});
successData.push({
onyxMethod: Onyx.METHOD.MERGE,
key: `${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${chatReport?.reportID}`,
value: {
[actionableTrackExpenseWhisper.reportActionID]: {pendingAction: null, errors: null},
},
});
failureData.push({
onyxMethod: Onyx.METHOD.SET,
key: `${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${chatReport?.reportID}`,
value: {[actionableTrackExpenseWhisper.reportActionID]: {} as ReportAction},
});
}
}

if (iouReport) {
Expand Down Expand Up @@ -2156,6 +2188,11 @@ function getTrackExpenseInformation(
}
}

let actionableTrackExpenseWhisper: OnyxEntry<OnyxTypes.ReportAction> = null;
if (!isPolicyExpenseChat) {
actionableTrackExpenseWhisper = ReportUtils.buildOptimisticActionableTrackExpenseWhisper(iouAction, optimisticTransaction.transactionID);
}

// STEP 5: Build Onyx Data
const trackExpenseOnyxData = buildOnyxDataForTrackExpense(
chatReport,
Expand All @@ -2170,6 +2207,8 @@ function getTrackExpenseInformation(
policy,
policyTagList,
policyCategories,
undefined,
actionableTrackExpenseWhisper,
);

return {
Expand All @@ -2183,6 +2222,7 @@ function getTrackExpenseInformation(
reportPreviewAction: reportPreviewAction ?? undefined,
transactionThreadReportID: optimisticTransactionThread.reportID,
createdReportActionIDForThread: optimisticCreatedActionForTransactionThread.reportActionID,
actionableWhisperReportActionIDParam: actionableTrackExpenseWhisper?.reportActionID ?? '',
onyxData: {
optimisticData: [...optimisticData, ...trackExpenseOnyxData[0]],
successData: [...successData, ...trackExpenseOnyxData[1]],
Expand Down Expand Up @@ -3526,6 +3566,7 @@ function trackExpense(
reportPreviewAction,
transactionThreadReportID,
createdReportActionIDForThread,
actionableWhisperReportActionIDParam,
onyxData,
} = getTrackExpenseInformation(
currentChatReport,
Expand Down Expand Up @@ -3642,7 +3683,9 @@ function trackExpense(
createdReportActionIDForThread,
waypoints: validWaypoints ? JSON.stringify(validWaypoints) : undefined,
};

if (actionableWhisperReportActionIDParam) {
parameters.actionableWhisperReportActionID = actionableWhisperReportActionIDParam;
}
API.write(WRITE_COMMANDS.TRACK_EXPENSE, parameters, onyxData);
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/pages/home/report/ContextMenu/ContextMenuActions.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -361,7 +361,7 @@ const ContextMenuActions: ContextMenuAction[] = [
const mentionWhisperMessage = ReportActionsUtils.getActionableMentionWhisperMessage(reportAction);
setClipboardMessage(mentionWhisperMessage);
} else if (ReportActionsUtils.isActionableTrackExpense(reportAction)) {
setClipboardMessage('What would you like to do with this expense?');
setClipboardMessage(CONST.ACTIONABLE_TRACK_EXPENSE_WHISPER_MESSAGE);
} else if (reportAction?.actionName === CONST.REPORT.ACTIONS.TYPE.HOLD) {
Clipboard.setString(Localize.translateLocal('iou.heldExpense'));
} else if (reportAction?.actionName === CONST.REPORT.ACTIONS.TYPE.UNHOLD) {
Expand Down