-
Notifications
You must be signed in to change notification settings - Fork 3.1k
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
Fix - Domain Card - User can edit the date in expenses related to the assigned domain card #39244
Changes from all commits
e0f0296
ffb9548
fa33be8
ad2e907
d6662a1
7b28f8e
d830864
81fa80d
48548d8
594a11b
808c534
eee3608
757b672
fcb497d
e449083
6363886
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -10,6 +10,7 @@ import useLocalize from '@hooks/useLocalize'; | |||||||||||||||||||||||||||||||||||||||
import useThemeStyles from '@hooks/useThemeStyles'; | ||||||||||||||||||||||||||||||||||||||||
import * as IOUUtils from '@libs/IOUUtils'; | ||||||||||||||||||||||||||||||||||||||||
import Navigation from '@libs/Navigation/Navigation'; | ||||||||||||||||||||||||||||||||||||||||
import * as ReportUtils from '@libs/ReportUtils'; | ||||||||||||||||||||||||||||||||||||||||
import * as TransactionUtils from '@libs/TransactionUtils'; | ||||||||||||||||||||||||||||||||||||||||
import * as IOU from '@userActions/IOU'; | ||||||||||||||||||||||||||||||||||||||||
import CONST from '@src/CONST'; | ||||||||||||||||||||||||||||||||||||||||
|
@@ -26,6 +27,12 @@ type IOURequestStepDateOnyxProps = { | |||||||||||||||||||||||||||||||||||||||
/** The draft transaction that holds data to be persisted on the current transaction */ | ||||||||||||||||||||||||||||||||||||||||
splitDraftTransaction: OnyxEntry<OnyxTypes.Transaction>; | ||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||
/** The actions from the parent report */ | ||||||||||||||||||||||||||||||||||||||||
reportActions: OnyxEntry<OnyxTypes.ReportActions>; | ||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||
/** Session info for the currently logged in user. */ | ||||||||||||||||||||||||||||||||||||||||
session: OnyxEntry<OnyxTypes.Session>; | ||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||
/** The policy of the report */ | ||||||||||||||||||||||||||||||||||||||||
policy: OnyxEntry<OnyxTypes.Policy>; | ||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||
|
@@ -37,27 +44,39 @@ type IOURequestStepDateOnyxProps = { | |||||||||||||||||||||||||||||||||||||||
}; | ||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||
type IOURequestStepDateProps = IOURequestStepDateOnyxProps & | ||||||||||||||||||||||||||||||||||||||||
WithWritableReportOrNotFoundProps<typeof SCREENS.MONEY_REQUEST.STEP_WAYPOINT> & { | ||||||||||||||||||||||||||||||||||||||||
/** Holds data related to Expense view state, rather than the underlying Expense data. */ | ||||||||||||||||||||||||||||||||||||||||
WithWritableReportOrNotFoundProps<typeof SCREENS.MONEY_REQUEST.STEP_DATE> & { | ||||||||||||||||||||||||||||||||||||||||
/** Holds data related to Money Request view state, rather than the underlying Money Request data. */ | ||||||||||||||||||||||||||||||||||||||||
transaction: OnyxEntry<OnyxTypes.Transaction>; | ||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||
/** The report linked to the transaction */ | ||||||||||||||||||||||||||||||||||||||||
report: OnyxEntry<Report>; | ||||||||||||||||||||||||||||||||||||||||
}; | ||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||
function IOURequestStepDate({ | ||||||||||||||||||||||||||||||||||||||||
route: { | ||||||||||||||||||||||||||||||||||||||||
params: {action, iouType, reportID, backTo}, | ||||||||||||||||||||||||||||||||||||||||
params: {action, iouType, reportID, backTo, reportActionID}, | ||||||||||||||||||||||||||||||||||||||||
}, | ||||||||||||||||||||||||||||||||||||||||
transaction, | ||||||||||||||||||||||||||||||||||||||||
splitDraftTransaction, | ||||||||||||||||||||||||||||||||||||||||
policy, | ||||||||||||||||||||||||||||||||||||||||
policyTags, | ||||||||||||||||||||||||||||||||||||||||
policyCategories, | ||||||||||||||||||||||||||||||||||||||||
reportActions, | ||||||||||||||||||||||||||||||||||||||||
report, | ||||||||||||||||||||||||||||||||||||||||
session, | ||||||||||||||||||||||||||||||||||||||||
}: IOURequestStepDateProps) { | ||||||||||||||||||||||||||||||||||||||||
const styles = useThemeStyles(); | ||||||||||||||||||||||||||||||||||||||||
const {translate} = useLocalize(); | ||||||||||||||||||||||||||||||||||||||||
const isEditing = action === CONST.IOU.ACTION.EDIT; | ||||||||||||||||||||||||||||||||||||||||
// In the split flow, when editing we use SPLIT_TRANSACTION_DRAFT to save draft value | ||||||||||||||||||||||||||||||||||||||||
const isEditingSplitBill = iouType === CONST.IOU.TYPE.SPLIT && isEditing; | ||||||||||||||||||||||||||||||||||||||||
const currentCreated = isEditingSplitBill && !lodashIsEmpty(splitDraftTransaction) ? TransactionUtils.getCreated(splitDraftTransaction) : TransactionUtils.getCreated(transaction); | ||||||||||||||||||||||||||||||||||||||||
const parentReportAction = reportActions?.[(isEditingSplitBill ? reportActionID : report?.parentReportActionID) ?? 0]; | ||||||||||||||||||||||||||||||||||||||||
const canEditingSplitBill = | ||||||||||||||||||||||||||||||||||||||||
isEditingSplitBill && session && parentReportAction && session.accountID === parentReportAction.actorAccountID && TransactionUtils.areRequiredFieldsEmpty(transaction); | ||||||||||||||||||||||||||||||||||||||||
const canEditMoneyRequest = isEditing && ReportUtils.canEditFieldOfMoneyRequest(parentReportAction ?? null, CONST.EDIT_REQUEST_FIELD.DATE); | ||||||||||||||||||||||||||||||||||||||||
// eslint-disable-next-line rulesdir/no-negated-variables | ||||||||||||||||||||||||||||||||||||||||
const shouldShowNotFound = !IOUUtils.isValidMoneyRequestType(iouType) || (isEditing && !canEditMoneyRequest && !canEditingSplitBill); | ||||||||||||||||||||||||||||||||||||||||
Comment on lines
+74
to
+79
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why is this change required @FitseTLT? I think this is getting way too complicated. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah I know. But we need to do it if we want to fix deep link access u mentioned. This is what we did to tag and category pages. It is basically displaying not found page when users are not allowed to edit the date and the logic for permission to edit the field, I took it the logic we use to enable the clicking of the date field in the money request view. App/src/components/ReportActionItem/MoneyRequestView.tsx Lines 143 to 144 in 20be55b
But an additional case we need to consider is for SplitBillDetailsPage (When we create split request with receipt), and for that the logic is taken from App/src/pages/iou/SplitBillDetailsPage.tsx Lines 79 to 80 in 20be55b
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @FitseTLT Isn't There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. App/src/pages/iou/request/step/IOURequestStepTag.tsx Lines 70 to 84 in 63223bc
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Can you please answer above? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nope it is not enough because we have to include the case of split detail page that is what I have included and I have given you a perfect similar example done for tag. |
||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||
const navigateBack = () => { | ||||||||||||||||||||||||||||||||||||||||
Navigation.goBack(backTo); | ||||||||||||||||||||||||||||||||||||||||
|
@@ -94,7 +113,7 @@ function IOURequestStepDate({ | |||||||||||||||||||||||||||||||||||||||
<StepScreenWrapper | ||||||||||||||||||||||||||||||||||||||||
headerTitle={translate('common.date')} | ||||||||||||||||||||||||||||||||||||||||
onBackButtonPress={navigateBack} | ||||||||||||||||||||||||||||||||||||||||
shouldShowNotFoundPage={!IOUUtils.isValidMoneyRequestType(iouType)} // TODO: Check why is this even here | ||||||||||||||||||||||||||||||||||||||||
shouldShowNotFoundPage={shouldShowNotFound} | ||||||||||||||||||||||||||||||||||||||||
shouldShowWrapper | ||||||||||||||||||||||||||||||||||||||||
testID={IOURequestStepDate.displayName} | ||||||||||||||||||||||||||||||||||||||||
> | ||||||||||||||||||||||||||||||||||||||||
|
@@ -127,6 +146,20 @@ const IOURequestStepDateWithOnyx = withOnyx<IOURequestStepDateProps, IOURequestS | |||||||||||||||||||||||||||||||||||||||
return `${ONYXKEYS.COLLECTION.SPLIT_TRANSACTION_DRAFT}${transactionID}`; | ||||||||||||||||||||||||||||||||||||||||
}, | ||||||||||||||||||||||||||||||||||||||||
}, | ||||||||||||||||||||||||||||||||||||||||
reportActions: { | ||||||||||||||||||||||||||||||||||||||||
key: ({ | ||||||||||||||||||||||||||||||||||||||||
route: { | ||||||||||||||||||||||||||||||||||||||||
params: {action, iouType}, | ||||||||||||||||||||||||||||||||||||||||
}, | ||||||||||||||||||||||||||||||||||||||||
report, | ||||||||||||||||||||||||||||||||||||||||
}) => { | ||||||||||||||||||||||||||||||||||||||||
let reportID; | ||||||||||||||||||||||||||||||||||||||||
if (action === CONST.IOU.ACTION.EDIT) { | ||||||||||||||||||||||||||||||||||||||||
reportID = iouType === CONST.IOU.TYPE.SPLIT ? report?.reportID : report?.parentReportID; | ||||||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||||||
return `${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${reportID ?? '0'}`; | ||||||||||||||||||||||||||||||||||||||||
}, | ||||||||||||||||||||||||||||||||||||||||
}, | ||||||||||||||||||||||||||||||||||||||||
policy: { | ||||||||||||||||||||||||||||||||||||||||
key: ({report}) => `${ONYXKEYS.COLLECTION.POLICY}${report ? report.policyID : '0'}`, | ||||||||||||||||||||||||||||||||||||||||
}, | ||||||||||||||||||||||||||||||||||||||||
|
@@ -136,6 +169,9 @@ const IOURequestStepDateWithOnyx = withOnyx<IOURequestStepDateProps, IOURequestS | |||||||||||||||||||||||||||||||||||||||
policyTags: { | ||||||||||||||||||||||||||||||||||||||||
key: ({report}) => `${ONYXKEYS.COLLECTION.POLICY_TAGS}${report ? report.policyID : '0'}`, | ||||||||||||||||||||||||||||||||||||||||
}, | ||||||||||||||||||||||||||||||||||||||||
session: { | ||||||||||||||||||||||||||||||||||||||||
key: ONYXKEYS.SESSION, | ||||||||||||||||||||||||||||||||||||||||
}, | ||||||||||||||||||||||||||||||||||||||||
})(IOURequestStepDate); | ||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||
// eslint-disable-next-line rulesdir/no-negated-variables | ||||||||||||||||||||||||||||||||||||||||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why do we need to change this condition @FitseTLT?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This was taken from here
App/src/libs/ReportUtils.ts
Lines 2623 to 2624 in 004b3af
As we took this
App/src/libs/ReportUtils.ts
Lines 2619 to 2621 in 004b3af
out of its code block
I had to centralize the condition in one if