-
Notifications
You must be signed in to change notification settings - Fork 3k
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: update parent action for assignee report as well #24110
Conversation
@s77rt |
…shareDestination reports
Please take a look again. Thanks |
@s-alves10 Some of the previous comments are not resolved but marked as resolved. Please double check. |
@s-alves10 Let's write the code as if they are both strings. Parent report ids being returned as a number is a bug https://expensify.slack.com/archives/C01GTK53T8Q/p1691167905181059?thread_ts=1691167905.181059&cid=C01GTK53T8Q |
src/libs/ReportActionsUtils.js
Outdated
* @returns {Object} | ||
*/ | ||
function getParentReportActionForTask(taskReportID, reportID) { | ||
return _.find(allReportActions[reportID], (reportAction) => reportAction && `${reportAction.childReportID}` === `${taskReportID}`); |
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.
@s-alves10 Let's write the code as if they are both strings. Parent report ids being returned as a number is a bug https://expensify.slack.com/archives/C01GTK53T8Q/p1691167905181059?thread_ts=1691167905.181059&cid=C01GTK53T8Q
Got it. But if we don't convert them to string, comparison would return false and can't find the parent action in assignee report. childReportID
is a number as well.
I think we need to convert them to string unless the backend is fixed. What do you think?
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.
Indeed. We may need to wait for an outcome from that slack thread. But for now let's write the right code.
@s-alves10 Can you please avoid resolving any PR comment until you see a thumbs up or a confirmation that it can be resolved. |
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.
Overall the logic looks good. I think we may just need to make the code more readable. (will add another comment)
src/libs/ReportActionsUtils.js
Outdated
* @param {String} reportID | ||
* @returns {Object} | ||
*/ | ||
function getParentReportActionForTask(taskReportID, reportID) { |
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 function is not exclusive to tasks. Can we rename it to something else?
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.
Renamed to getParentReportActionInReport
@s-alves10 Can we re-write the const getOptimisticDataForParentReportAction = (reportID, lastVisibleActionCreated, type, parentReportID = 0, parentReportActionID = 0) => {
const report = getReport(reportID);
const parentReportAction = ReportActionsUtils.getParentReportAction(report);
if (_.isEmpty(parentReportAction)) {
return {};
}
const optimisticParentReportAction = updateOptimisticParentReportAction(parentReportAction, lastVisibleActionCreated, type);
if (!parentReportID) {
parentReportID = report.parentReportID;
}
if (!parentReportActionID) {
parentReportActionID = report.parentReportActionID;
}
return {
onyxMethod: Onyx.METHOD.MERGE,
key: `${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${parentReportID}`,
value: {
[parentReportActionID]: optimisticParentReportAction,
},
};
}; Then in const optimisticDataForParentReportAction = ReportUtils.getOptimisticDataForParentReportAction(taskReportID, completedTaskReportAction.created, CONST.RED_BRICK_ROAD_PENDING_ACTION.ADD); and the second time with the collected assignee report id (using const optimisticDataForClonedParentReportAction = ReportUtils.getOptimisticDataForParentReportAction(taskReportID, completedTaskReportAction.created, CONST.RED_BRICK_ROAD_PENDING_ACTION.ADD, assigneeChatReportID, clonedParentReportActionID); |
I've updated the code according to your change requests with one exception. I cannot remove string construction because that makes the solution not working |
@s-alves10 This comment is still unresolved #24110 (comment) Please check |
Done |
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.
just few non-blocking comments. will proceed with tests asap
Updated according to your suggestions |
@s-alves10 I don't see any update, did you forget to push the changes maybe? |
@s77rt |
src/libs/ReportUtils.js
Outdated
* @returns {Object} | ||
*/ | ||
function getTaskParentReportActionIDInAssigneeReport(taskReport) { | ||
const assigneeChatReportID = lodashGet(getChatByParticipants(taskReport.participantAccountIDs), 'reportID'); |
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.
const assigneeChatReportID = lodashGet(getChatByParticipants(taskReport.participantAccountIDs), 'reportID'); | |
const assigneeChatReportID = lodashGet(getChatByParticipants(isTaskAssignee(taskReport) ? [taskReport.ownerAccountID] : [taskReport.managerID]), 'reportID'); |
I think we have a case that we are not covering, if you are assigned a task by someone else and click the checkbox in the assignee report, nothing will happen. This is because getChatByParticipants
will look for a chat that have the assignee as a participant but since you are the assignee there won't be a chat with your self, instead there will be a chat the owner.
Kooha-2023-08-07-16-43-34.mp4
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.
@s77rt
I think we don't need to find assignee report in this case because there is no assignee report to update for the assignee himself. In our solution, getChatByParticipants
returns null
in this case and would work as expected.
Please tell me if I missed something
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.
because there is no assignee report to update for the assignee himself
There is an assignee report, it's shown in the above video
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.
Great catch. Code updated.
Thank you
Reviewer Checklist
Screenshots/VideosWebweb.mp4Mobile Web - Chromemweb-chrome.mp4Mobile Web - Safarimweb-safari.mp4Desktopdesktop.mp4iOSios.mp4Androidandroid.mp4 |
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.
LGTM! 🚀
@techievivek |
@s-alves10 Yes, I am taking a look, I have a few questions, can you please answer them in realtime? Thanks |
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.
Not very familiar with the data structure behind a thread/task so I have a few quick question to understand the changes.
yes |
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.
Great work 🚀
✋ This PR was not deployed to staging yet because QA is ongoing. It will be automatically deployed to staging after the next production release. |
🚀 Deployed to staging by https://github.com/techievivek in version: 1.3.52-0 🚀
|
🚀 Deployed to staging by https://github.com/techievivek in version: 1.3.52-0 🚀
|
🚀 Deployed to production by https://github.com/puneetlath in version: 1.3.52-5 🚀
|
const optimisticParentReportData = ReportUtils.getOptimisticDataForParentReportAction(taskReportID, reopenedTaskReportAction.created, CONST.RED_BRICK_ROAD_PENDING_ACTION.ADD); | ||
if (!_.isEmpty(optimisticParentReportData)) { | ||
optimisticData.push(optimisticParentReportData); | ||
const optimisticDataForParentReportAction = ReportUtils.getOptimisticDataForParentReportAction(taskReportID, reopenedTaskReportAction.created, CONST.RED_BRICK_ROAD_PENDING_ACTION.ADD); |
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.
Coming from #25548
This PR didn't account for the case where a reportAction
has more than one parent (i.e. if you change the asignee of the task), so only the first one was updated
More details in #25548 (comment)
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.
@eVoloshchak I didn't read the whole issue context but isn't the approved PR reintroducing the fixed bug here #23920?
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.
@s77rt, we aren't counting completing/opening a task as a reply anymore (recent BE update), so this logic isn't needed
I should have included that actually, so thank you
Details
Optimistically update parent action in assignee report as well
Fixed Issues
$ #23920
PROPOSAL: #23920 (comment)
Tests
Offline tests
QA Steps
PR Author Checklist
### Fixed Issues
section aboveTests
sectionOffline steps
sectionQA steps
sectiontoggleReport
and notonIconClick
)myBool && <MyComponent />
.src/languages/*
files and using the translation methodWaiting for Copy
label for a copy review on the original GH to get the correct copy.STYLE.md
) were followedAvatar
, I verified the components usingAvatar
are working as expected)/** comment above it */
this
properly so there are no scoping issues (i.e. foronClick={this.submit}
the methodthis.submit
should be bound tothis
in the constructor)this
are necessary to be bound (i.e. avoidthis.submit = this.submit.bind(this);
ifthis.submit
is never passed to a component event handler likeonClick
)StyleUtils.getBackgroundAndBorderStyle(themeColors.componentBG)
)Avatar
is modified, I verified thatAvatar
is working as expected in all cases)ScrollView
component to make it scrollable when more elements are added to the page.main
branch was merged into this PR after a review, I tested again and verified the outcome was still expected according to theTest
steps.Screenshots/Videos
Web
23920_mac_chrome.mp4
Mobile Web - Chrome
23920_android_chrome.mp4
Mobile Web - Safari
23920_ios_safari.mp4
Desktop
23920_mac_desktop.mp4
iOS
23920_ios_native.mp4
Android
23920_android_native.mp4