-
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
[HOLD for payment 2024-01-11] [$1000] Draft message doesn't remain when It is empty #25488
Comments
Triggered auto assignment to @flaviadefaria ( |
Bug0 Triage Checklist (Main S/O)
|
ProposalPlease re-state the problem that we are trying to solve in this issue.Draft message doesn't remain when It is empty What is the root cause of that problem?When the draft is made empty, we reset it to the original message: App/src/pages/home/report/ReportActionItemMessageEdit.js Lines 203 to 210 in a068ca5
This is because if the value is empty, we assume editing is not occurring and we unmount App/src/pages/home/report/ReportActionItem.js Lines 337 to 339 in f6fad4e
What changes do you think we should make in order to solve the problem?We should use a value of undefined to check that editing is not occurring. To achieve this, we should change: 1. Update deleteDraft to remove the Onyx record instead of making it an empty string: App/src/pages/home/report/ReportActionItemMessageEdit.js Lines 283 to 287 in 82ee577
2. Use _.isUndefined here: App/src/pages/home/report/ReportActionItem.js Line 422 in 82ee577
3. Always save the newDraft value, instead of using a fallback to the original message if the length is 0: App/src/pages/home/report/ReportActionItemMessageEdit.js Lines 265 to 270 in 82ee577
4. Update saveReportActionDraft here: - Onyx.merge(`${ONYXKEYS.COLLECTION.REPORT_ACTIONS_DRAFTS}${originalReportID}`, {[reportAction.reportActionID]: draftMessage});
+ Onyx.merge(`${ONYXKEYS.COLLECTION.REPORT_ACTIONS_DRAFTS}${originalReportID}`, {[reportAction.reportActionID]: { message: draftMessage }}); 5. Don't use empty string as default value and update key here: - return lodashGet(drafts, [draftKey, props.action.reportActionID], '');
+ return lodashGet(drafts, [draftKey, props.action.reportActionID, 'message']); 6. Migration to remove existing empty drafts See migration code
import Onyx from 'react-native-onyx';
import _ from 'underscore';
import Log from '@libs/Log';
import ONYXKEYS from '@src/ONYXKEYS';
/**
* This migration removes empty drafts from reportActionsDrafts.
*
* @returns {Promise}
*/
export default function () {
return new Promise((resolve) => {
const connectionID = Onyx.connect({
key: ONYXKEYS.COLLECTION.REPORT_ACTIONS_DRAFTS,
waitForCollectionCallback: true,
callback: (allReportActionsDrafts) => {
Onyx.disconnect(connectionID);
if (!allReportActionsDrafts) {
Log.info('[Migrate Onyx] Skipped migration RemoveEmptyReportActionsDrafts because there were no reportActionsDrafts');
return resolve();
}
const newReportActionsDrafts = {};
_.each(allReportActionsDrafts, (reportActionDrafts, onyxKey) => {
newReportActionsDrafts[onyxKey] = {};
// Whether there is at least one draft in this report that has to be migrated
let hasUnmigratedDraft = false;
_.each(reportActionDrafts, (reportActionDraft, reportActionID) => {
// If the draft is a string, it means it hasn't been migrated yet
if (_.isString(reportActionDraft)) {
hasUnmigratedDraft = true;
Log.info(`[Migrate Onyx] Migrating draft for report action ${reportActionID}`);
if (_.isEmpty(reportActionDraft)) {
Log.info(`[Migrate Onyx] Removing draft for report action ${reportActionID}`);
return;
}
newReportActionsDrafts[onyxKey][reportActionID] = {message: reportActionDraft};
} else {
// We've already migrated this draft, so keep the existing value
newReportActionsDrafts[onyxKey][reportActionID] = reportActionDraft;
}
});
if (_.isEmpty(newReportActionsDrafts[onyxKey])) {
// Clear if there are no drafts remaining
newReportActionsDrafts[onyxKey] = null;
} else if (!hasUnmigratedDraft) {
// All drafts for this report have already been migrated, there's no need to overwrite this onyx key with the same data
delete newReportActionsDrafts[onyxKey];
}
});
if (_.isEmpty(newReportActionsDrafts)) {
Log.info('[Migrate Onyx] Skipped migration RemoveEmptyReportActionsDrafts because there are no actions drafts to migrate');
return resolve();
}
Log.info(`[Migrate Onyx] Ran migration RemoveEmptyReportActionsDrafts and updated drafts for ${_.keys(newReportActionsDrafts).length} reports`);
// eslint-disable-next-line rulesdir/prefer-actions-set-data
return Onyx.multiSet(newReportActionsDrafts).then(resolve);
},
});
});
} What alternative solutions did you explore? (Optional)N/A |
Triggered auto assignment to @greg-schroeder ( |
Bug0 Triage Checklist (Main S/O)
|
@greg-schroeder I'm logging off now and will be OoO for the next week so reassigning this to you in the meantime. Thanks! |
Ok, sure! |
Hmmmmm. I don't know about this. Why would a user replace a message with an empty string, not save it, and then switch between reports? That doesn't seem like a use case that would be commonly encountered to me. I don't know that we should optimize for that. |
Started a discussion |
Job added to Upwork: https://www.upwork.com/jobs/~01adda4a6239a4a1af |
Triggered auto assignment to @adelekennedy ( |
Triggered auto assignment to Contributor-plus team member for initial proposal review - @mollfpr ( |
Team agreed it's worth moving over to External |
This is on staging, awaiting deploy to prod |
|
The solution for this issue has been 🚀 deployed to production 🚀 in version 1.4.21-4 and is now subject to a 7-day regression period 📆. Here is the list of pull requests that resolve this issue: If no regressions arise, payment will be issued on 2024-01-11. 🎊 After the hold period is over and BZ checklist items are completed, please complete any of the applicable payments for this issue, and check them off once done.
For reference, here are some details about the assignees on this issue:
|
BugZero Checklist: The PR fixing this issue has been merged! The following checklist (instructions) will need to be completed before the issue can be closed:
|
Issue is ready for payment but no BZ is assigned. @sonialiap you are the lucky winner! Please verify the payment summary looks correct and complete the checklist. Thanks! |
Payment SummaryBugZero Checklist (@sonialiap)
|
You can ignore this @sonialiap, it's a bug, I will handle payment |
No offending PR.
The regression test should be good.
@greg-schroeder No need to send me the offer; I'll make a manual request in NewDot. Thank you! |
reporter: $50 Offers sent to @dukenv0307 and @samh-nl, and you can do a manual request @mollfpr. |
filing regression test |
$500 payment approved for @mollfpr (c+) based on summary above. |
Thanks all! I'd just like to check on the accuracy of the bounty, as this issue stems from Aug last year. |
@greg-schroeder based on this announcement, the $250 reporting bonus still applies for issues opened before Aug 30, 2023. This issue was created on Aug 18, 2023, so I think it qualifies there. Could you send me another offer for $250, thanks! |
Bump |
Sorry all, let me review this one |
Hmm. This is tricky. The issue was reported/created in August before our first pricing changes, but no PR was created until late 2023, well after our payscale changed. I think we could probably honor the original reporting bonus given the date, but the work done on the PR took place well after the $500 baseline was established. That seems most fair to me. |
True, even though the initial proposal was made under a different premise. |
If you haven’t already, check out our contributing guidelines for onboarding and email [email protected] to request to join our Slack channel!
Action Performed:
Expected Result:
Draft message should be remained
Note that: When replacing draft message by another string, It will be remained
Actual Result:
Draft message doesn't remain
Workaround:
Can the user still use Expensify without this being fixed? Have you informed them of the workaround?
Platforms:
Which of our officially supported platforms is this issue occurring on?
Version Number: 1.3.55-0
Reproducible in staging?: y
Reproducible in production?: y
If this was caught during regression testing, add the test name, ID and link from TestRail:
Email or phone of affected tester (no customers):
Logs: https://stackoverflow.com/c/expensify/questions/4856
Notes/Photos/Videos: Any additional supporting documentation
Recording.5919.mp4
Screen.Recording.2023-08-09.at.10.15.13.1.mov
Expensify/Expensify Issue URL:
Issue reported by: @dukenv0307
Slack conversation: https://expensify.slack.com/archives/C049HHMV9SM/p1691551143871559
View all open jobs on GitHub
Upwork Automation - Do Not Edit
The text was updated successfully, but these errors were encountered: