Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[feature]: Using the product as a copilot #48594

Merged
merged 52 commits into from
Sep 26, 2024
Merged
Show file tree
Hide file tree
Changes from 50 commits
Commits
Show all changes
52 commits
Select commit Hold shift + click to select a range
a2e0bbf
add delegate prop to OriginalMessage
allgandalf Sep 4, 2024
27d7bca
add delegate prop to OriginalMessage
allgandalf Sep 4, 2024
deca975
add delegate in original message
allgandalf Sep 4, 2024
daa0c9c
fix OriginalMessageSubmitted typo
allgandalf Sep 4, 2024
c18f61f
update optimistic actions to include delegate email
allgandalf Sep 4, 2024
f45020a
remove delegate component
allgandalf Sep 4, 2024
dd7947d
fix unit test
allgandalf Sep 4, 2024
e7162f3
fix lint
allgandalf Sep 5, 2024
2adb7f7
Merge branch 'main' into issue46926P2
allgandalf Sep 5, 2024
beb642d
remove usage of hook
allgandalf Sep 5, 2024
b6272e3
part 1: update reportactionitemsingle to display delegate details
allgandalf Sep 5, 2024
79192b2
Update Permissions.ts
allgandalf Sep 5, 2024
93957c6
Merge branch 'main' into issue46926P2
allgandalf Sep 6, 2024
3d136e4
part 2: add delegator name
allgandalf Sep 6, 2024
9a2f8b7
fix spanish translation
allgandalf Sep 6, 2024
4b13c3c
add delegator display name
allgandalf Sep 6, 2024
1c497da
fix system message
allgandalf Sep 6, 2024
96eb90f
fix grouping of messages
allgandalf Sep 6, 2024
fc3cae1
revert to previous check
allgandalf Sep 6, 2024
47a098e
get delegate account details
allgandalf Sep 6, 2024
e48b2b1
add delegateaccountID
allgandalf Sep 6, 2024
1b268e8
remove unused util
allgandalf Sep 6, 2024
4b784e7
cleanup
allgandalf Sep 6, 2024
53e5e61
fix lint
allgandalf Sep 6, 2024
d8cccb6
add delegate AccountID for IOU
allgandalf Sep 6, 2024
c500a0b
Update AvatarWithDelegateAvatar.tsx
allgandalf Sep 6, 2024
bda8982
Merge branch 'main' into issue46926P2
allgandalf Sep 15, 2024
a8a097f
Merge branch 'Expensify:main' into issue46926P2
allgandalf Sep 20, 2024
699edec
fix modified expense report actions
allgandalf Sep 20, 2024
d5eb8af
remove delegate from original Message (Deprecated)
allgandalf Sep 20, 2024
9229536
fix prettier
allgandalf Sep 20, 2024
d632c5f
add delegate for task
allgandalf Sep 20, 2024
80e28ae
fix lint
allgandalf Sep 20, 2024
90f28c6
Do not display delegate message on report preview
allgandalf Sep 20, 2024
35b5431
fix lint
allgandalf Sep 20, 2024
3171156
fix pay someone limited delegate action
allgandalf Sep 24, 2024
0a745a3
migrate from withOnyx
allgandalf Sep 24, 2024
fc19a5c
remove commented section
allgandalf Sep 24, 2024
e2b43f6
add delegate dependency
allgandalf Sep 24, 2024
24eff7d
fix offline case for pay expense
allgandalf Sep 24, 2024
f64cfbd
fix offline submission of expense
allgandalf Sep 24, 2024
6a51601
Merge branch 'main' into issue46926P2
allgandalf Sep 24, 2024
3b0742c
fix jest hopefully
allgandalf Sep 24, 2024
d36fd07
fix
allgandalf Sep 24, 2024
d851429
make delegateEmail accessible in reportUtils itself
allgandalf Sep 24, 2024
60f097a
remove whitespaces
allgandalf Sep 24, 2024
e5778d7
Check for delegate report action directly from actions
allgandalf Sep 24, 2024
33e8945
Merge branch 'main' into issue46926P2
allgandalf Sep 24, 2024
c081907
remove white space
allgandalf Sep 24, 2024
e92e7d5
Merge branch 'Expensify:main' into issue46926P2
allgandalf Sep 24, 2024
d5e3428
Update src/libs/ReportUtils.ts
allgandalf Sep 25, 2024
d47e156
Merge branch 'main' into issue46926P2
allgandalf Sep 26, 2024
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
1 change: 1 addition & 0 deletions src/languages/en.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4739,6 +4739,7 @@ export default {
}
},
genericError: 'Oops, something went wrong. Please try again.',
onBehalfOfMessage: (delegator: string) => `on behalf of ${delegator}`,
allgandalf marked this conversation as resolved.
Show resolved Hide resolved
accessLevel: 'Access level',
confirmCopilot: 'Confirm your copilot below.',
accessLevelDescription: 'Choose an access level below. Both Full and Limited access allow copilots to view all conversations and expenses.',
Expand Down
1 change: 1 addition & 0 deletions src/languages/es.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5256,6 +5256,7 @@ export default {
}
},
genericError: '¡Ups! Ha ocurrido un error. Por favor, inténtalo de nuevo.',
onBehalfOfMessage: (delegator: string) => `en nombre de ${delegator}`,
allgandalf marked this conversation as resolved.
Show resolved Hide resolved
accessLevel: 'Nivel de acceso',
confirmCopilot: 'Confirma tu copiloto a continuación.',
accessLevelDescription: 'Elige un nivel de acceso a continuación. Tanto el acceso Completo como el Limitado permiten a los copilotos ver todas las conversaciones y gastos.',
Expand Down
85 changes: 79 additions & 6 deletions src/libs/ReportUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,7 @@ type OptimisticAddCommentReportAction = Pick<
| 'childCommenterCount'
| 'childLastVisibleActionCreated'
| 'childOldestFourAccountIDs'
| 'delegateAccountID'
> & {isOptimisticAction: boolean};

type OptimisticReportAction = {
Expand Down Expand Up @@ -180,6 +181,7 @@ type OptimisticIOUReportAction = Pick<
| 'childReportID'
| 'childVisibleActionCount'
| 'childCommenterCount'
| 'delegateAccountID'
>;

type PartialReportAction = OnyxInputOrEntry<ReportAction> | Partial<ReportAction> | OptimisticIOUReportAction | OptimisticApprovedReportAction | OptimisticSubmittedReportAction | undefined;
Expand All @@ -196,12 +198,36 @@ type ReportOfflinePendingActionAndErrors = {

type OptimisticApprovedReportAction = Pick<
ReportAction<typeof CONST.REPORT.ACTIONS.TYPE.APPROVED>,
'actionName' | 'actorAccountID' | 'automatic' | 'avatar' | 'isAttachmentOnly' | 'originalMessage' | 'message' | 'person' | 'reportActionID' | 'shouldShow' | 'created' | 'pendingAction'
| 'actionName'
| 'actorAccountID'
| 'automatic'
| 'avatar'
| 'isAttachmentOnly'
| 'originalMessage'
| 'message'
| 'person'
| 'reportActionID'
| 'shouldShow'
| 'created'
| 'pendingAction'
| 'delegateAccountID'
>;

type OptimisticUnapprovedReportAction = Pick<
ReportAction<typeof CONST.REPORT.ACTIONS.TYPE.UNAPPROVED>,
'actionName' | 'actorAccountID' | 'automatic' | 'avatar' | 'isAttachmentOnly' | 'originalMessage' | 'message' | 'person' | 'reportActionID' | 'shouldShow' | 'created' | 'pendingAction'
| 'actionName'
| 'actorAccountID'
| 'automatic'
| 'avatar'
| 'isAttachmentOnly'
| 'originalMessage'
| 'message'
| 'person'
| 'reportActionID'
| 'shouldShow'
| 'created'
| 'pendingAction'
| 'delegateAccountID'
>;

type OptimisticSubmittedReportAction = Pick<
Expand All @@ -219,6 +245,7 @@ type OptimisticSubmittedReportAction = Pick<
| 'shouldShow'
| 'created'
| 'pendingAction'
| 'delegateAccountID'
>;

type OptimisticHoldReportAction = Pick<
Expand All @@ -233,7 +260,7 @@ type OptimisticCancelPaymentReportAction = Pick<

type OptimisticEditedTaskReportAction = Pick<
ReportAction,
'reportActionID' | 'actionName' | 'pendingAction' | 'actorAccountID' | 'automatic' | 'avatar' | 'created' | 'shouldShow' | 'message' | 'person'
'reportActionID' | 'actionName' | 'pendingAction' | 'actorAccountID' | 'automatic' | 'avatar' | 'created' | 'shouldShow' | 'message' | 'person' | 'delegateAccountID'
>;

type OptimisticClosedReportAction = Pick<
Expand All @@ -248,7 +275,7 @@ type OptimisticDismissedViolationReportAction = Pick<

type OptimisticCreatedReportAction = Pick<
ReportAction<typeof CONST.REPORT.ACTIONS.TYPE.CREATED>,
'actorAccountID' | 'automatic' | 'avatar' | 'created' | 'message' | 'person' | 'reportActionID' | 'shouldShow' | 'pendingAction' | 'actionName'
'actorAccountID' | 'automatic' | 'avatar' | 'created' | 'message' | 'person' | 'reportActionID' | 'shouldShow' | 'pendingAction' | 'actionName' | 'delegateAccountID'
>;

type OptimisticRenamedReportAction = Pick<
Expand Down Expand Up @@ -321,6 +348,7 @@ type OptimisticTaskReportAction = Pick<
| 'previousMessage'
| 'errors'
| 'linkMetadata'
| 'delegateAccountID'
>;

type OptimisticWorkspaceChats = {
Expand All @@ -340,7 +368,19 @@ type OptimisticWorkspaceChats = {

type OptimisticModifiedExpenseReportAction = Pick<
ReportAction<typeof CONST.REPORT.ACTIONS.TYPE.MODIFIED_EXPENSE>,
'actionName' | 'actorAccountID' | 'automatic' | 'avatar' | 'created' | 'isAttachmentOnly' | 'message' | 'originalMessage' | 'person' | 'pendingAction' | 'reportActionID' | 'shouldShow'
| 'actionName'
| 'actorAccountID'
| 'automatic'
| 'avatar'
| 'created'
| 'isAttachmentOnly'
| 'message'
| 'originalMessage'
| 'person'
| 'pendingAction'
| 'reportActionID'
| 'shouldShow'
| 'delegateAccountID'
> & {reportID?: string};

type OptimisticTaskReport = Pick<
Expand Down Expand Up @@ -636,6 +676,14 @@ Onyx.connect({
callback: (value) => (onboarding = value),
});

let delegateEmail = '';
Onyx.connect({
key: ONYXKEYS.ACCOUNT,
callback: (value) => {
delegateEmail = value?.delegatedAccess?.delegate ?? '';
},
});

function getCurrentUserAvatar(): AvatarSource | undefined {
return currentUserPersonalDetails?.avatar;
}
Expand Down Expand Up @@ -4130,7 +4178,7 @@ function buildOptimisticAddCommentReportAction(
const isAttachmentOnly = file && !text;
const isAttachmentWithText = !!text && file !== undefined;
const accountID = actorAccountID ?? currentUserAccountID ?? -1;

const delegateAccountDetails = PersonalDetailsUtils.getPersonalDetailByEmail(delegateEmail);
allgandalf marked this conversation as resolved.
Show resolved Hide resolved
// Remove HTML from text when applying optimistic offline comment
return {
commentText,
Expand Down Expand Up @@ -4166,6 +4214,7 @@ function buildOptimisticAddCommentReportAction(
pendingAction: CONST.RED_BRICK_ROAD_PENDING_ACTION.ADD,
shouldShow: true,
isOptimisticAction: true,
delegateAccountID: delegateAccountDetails?.accountID,
},
};
}
Expand Down Expand Up @@ -4590,6 +4639,8 @@ function buildOptimisticIOUReportAction(
type,
};

const delegateAccountDetails = PersonalDetailsUtils.getPersonalDetailByEmail(delegateEmail);

if (type === CONST.IOU.REPORT_ACTION_TYPE.PAY) {
// In pay someone flow, we store amount, comment, currency in IOUDetails when type = pay
if (isSendMoneyFlow) {
Expand Down Expand Up @@ -4641,6 +4692,7 @@ function buildOptimisticIOUReportAction(
shouldShow: true,
created,
pendingAction: CONST.RED_BRICK_ROAD_PENDING_ACTION.ADD,
delegateAccountID: delegateAccountDetails?.accountID,
};
}

Expand All @@ -4653,6 +4705,7 @@ function buildOptimisticApprovedReportAction(amount: number, currency: string, e
currency,
expenseReportID,
};
const delegateAccountDetails = PersonalDetailsUtils.getPersonalDetailByEmail(delegateEmail);

return {
actionName: CONST.REPORT.ACTIONS.TYPE.APPROVED,
Expand All @@ -4673,13 +4726,15 @@ function buildOptimisticApprovedReportAction(amount: number, currency: string, e
shouldShow: true,
created: DateUtils.getDBTime(),
pendingAction: CONST.RED_BRICK_ROAD_PENDING_ACTION.ADD,
delegateAccountID: delegateAccountDetails?.accountID,
};
}

/**
* Builds an optimistic APPROVED report action with a randomly generated reportActionID.
*/
function buildOptimisticUnapprovedReportAction(amount: number, currency: string, expenseReportID: string): OptimisticUnapprovedReportAction {
const delegateAccountDetails = PersonalDetailsUtils.getPersonalDetailByEmail(delegateEmail);
return {
actionName: CONST.REPORT.ACTIONS.TYPE.UNAPPROVED,
actorAccountID: currentUserAccountID,
Expand All @@ -4703,6 +4758,7 @@ function buildOptimisticUnapprovedReportAction(amount: number, currency: string,
shouldShow: true,
created: DateUtils.getDBTime(),
pendingAction: CONST.RED_BRICK_ROAD_PENDING_ACTION.ADD,
delegateAccountID: delegateAccountDetails?.accountID,
};
}

Expand Down Expand Up @@ -4759,6 +4815,8 @@ function buildOptimisticSubmittedReportAction(amount: number, currency: string,
expenseReportID,
};

const delegateAccountDetails = PersonalDetailsUtils.getPersonalDetailByEmail(delegateEmail);

return {
actionName: CONST.REPORT.ACTIONS.TYPE.SUBMITTED,
actorAccountID: currentUserAccountID,
Expand All @@ -4779,6 +4837,7 @@ function buildOptimisticSubmittedReportAction(amount: number, currency: string,
shouldShow: true,
created: DateUtils.getDBTime(),
pendingAction: CONST.RED_BRICK_ROAD_PENDING_ACTION.ADD,
delegateAccountID: delegateAccountDetails?.accountID,
};
}

Expand Down Expand Up @@ -4879,6 +4938,8 @@ function buildOptimisticModifiedExpenseReportAction(
updatedTransaction?: OnyxInputOrEntry<Transaction>,
): OptimisticModifiedExpenseReportAction {
const originalMessage = getModifiedExpenseOriginalMessage(oldTransaction, transactionChanges, isFromExpenseReport, policy, updatedTransaction);
const delegateAccountDetails = PersonalDetailsUtils.getPersonalDetailByEmail(delegateEmail);

return {
actionName: CONST.REPORT.ACTIONS.TYPE.MODIFIED_EXPENSE,
actorAccountID: currentUserAccountID,
Expand Down Expand Up @@ -4906,6 +4967,7 @@ function buildOptimisticModifiedExpenseReportAction(
reportActionID: NumberUtils.rand64(),
reportID: transactionThread?.reportID,
shouldShow: true,
delegateAccountID: delegateAccountDetails?.accountID,
};
}

Expand All @@ -4915,6 +4977,8 @@ function buildOptimisticModifiedExpenseReportAction(
* @param movedToReportID - The reportID of the report the transaction is moved to
*/
function buildOptimisticMovedTrackedExpenseModifiedReportAction(transactionThreadID: string, movedToReportID: string): OptimisticModifiedExpenseReportAction {
const delegateAccountDetails = PersonalDetailsUtils.getPersonalDetailByEmail(delegateEmail);

return {
actionName: CONST.REPORT.ACTIONS.TYPE.MODIFIED_EXPENSE,
actorAccountID: currentUserAccountID,
Expand Down Expand Up @@ -4944,6 +5008,7 @@ function buildOptimisticMovedTrackedExpenseModifiedReportAction(transactionThrea
reportActionID: NumberUtils.rand64(),
reportID: transactionThreadID,
shouldShow: true,
delegateAccountID: delegateAccountDetails?.accountID,
};
}

Expand Down Expand Up @@ -5019,6 +5084,8 @@ function buildOptimisticTaskReportAction(
html: message,
whisperedTo: [],
};
const delegateAccountDetails = PersonalDetailsUtils.getPersonalDetailByEmail(delegateEmail);

return {
actionName,
actorAccountID,
Expand All @@ -5045,6 +5112,7 @@ function buildOptimisticTaskReportAction(
created: DateUtils.getDBTimeWithSkew(Date.now() + createdOffset),
isFirstItem: false,
pendingAction: CONST.RED_BRICK_ROAD_PENDING_ACTION.ADD,
delegateAccountID: delegateAccountDetails?.accountID,
};
}

Expand Down Expand Up @@ -5374,6 +5442,7 @@ function buildOptimisticEditedTaskFieldReportAction({title, description}: Task):
} else if (field) {
changelog = `removed the ${field}`;
}
const delegateAccountDetails = PersonalDetailsUtils.getPersonalDetailByEmail(delegateEmail);

return {
reportActionID: NumberUtils.rand64(),
Expand All @@ -5398,10 +5467,13 @@ function buildOptimisticEditedTaskFieldReportAction({title, description}: Task):
avatar: getCurrentUserAvatar(),
created: DateUtils.getDBTime(),
shouldShow: false,
delegateAccountID: delegateAccountDetails?.accountID,
};
}

function buildOptimisticChangedTaskAssigneeReportAction(assigneeAccountID: number): OptimisticEditedTaskReportAction {
const delegateAccountDetails = PersonalDetailsUtils.getPersonalDetailByEmail(delegateEmail);

return {
reportActionID: NumberUtils.rand64(),
actionName: CONST.REPORT.ACTIONS.TYPE.TASK_EDITED,
Expand All @@ -5425,6 +5497,7 @@ function buildOptimisticChangedTaskAssigneeReportAction(assigneeAccountID: numbe
avatar: getCurrentUserAvatar(),
created: DateUtils.getDBTime(),
shouldShow: false,
delegateAccountID: delegateAccountDetails?.accountID,
};
}

Expand Down
Loading
Loading